List of usage examples for android.os Bundle putAll
public void putAll(Bundle bundle)
From source file:de.mrapp.android.preference.activity.PreferenceActivity.java
/** * Notifies all registered listeners that the user wants to navigate to the previous step of the * wizard./*from ww w . j a va 2 s.com*/ * * @return A bundle, which may contain key-value pairs, which have been acquired in the wizard, * if navigating to the previous step of the wizard should be allowed, as an instance of the * class {@link Bundle}, null otherwise */ private Bundle notifyOnPreviousStep() { Bundle result = null; for (WizardListener listener : wizardListeners) { Bundle bundle = listener.onPreviousStep(getListAdapter().indexOf(currentHeader), currentHeader, preferenceScreenFragment, currentBundle); if (bundle != null) { if (result == null) { result = new Bundle(); } result.putAll(bundle); } } return result; }
From source file:cgeo.geocaching.CacheListActivity.java
private void switchListById(final int id, @NonNull final AfterLoadAction action) { if (id < 0) { return;// w w w . j av a 2 s . c o m } final Bundle extras = new Bundle(); extras.putSerializable(BUNDLE_ACTION_KEY, action); if (id == PseudoList.HISTORY_LIST.id) { type = CacheListType.HISTORY; getSupportLoaderManager().destroyLoader(CacheListType.OFFLINE.getLoaderId()); currentLoader = (AbstractSearchLoader) getSupportLoaderManager() .restartLoader(CacheListType.HISTORY.getLoaderId(), extras, this); } else { if (id == PseudoList.ALL_LIST.id) { listId = id; title = res.getString(R.string.list_all_lists); } else { final StoredList list = DataStore.getList(id); listId = list.id; title = list.title; } type = CacheListType.OFFLINE; getSupportLoaderManager().destroyLoader(CacheListType.HISTORY.getLoaderId()); extras.putAll(OfflineGeocacheListLoader.getBundleForList(listId)); currentLoader = (OfflineGeocacheListLoader) getSupportLoaderManager() .restartLoader(CacheListType.OFFLINE.getLoaderId(), extras, this); Settings.setLastDisplayedList(listId); } initAdapter(); showProgress(true); showFooterLoadingCaches(); adapter.setSelectMode(false); invalidateOptionsMenuCompatible(); }
From source file:de.vanita5.twittnuker.util.Utils.java
public static Fragment createFragmentForIntent(final Context context, final Intent intent) { final long start = System.currentTimeMillis(); intent.setExtrasClassLoader(context.getClassLoader()); final Bundle extras = intent.getExtras(); final Uri uri = intent.getData(); final Fragment fragment; if (uri == null) return null; final Bundle args = new Bundle(); if (extras != null) { args.putAll(extras); }// w ww . j a v a 2 s .c o m switch (matchLinkId(uri)) { case LINK_ID_STATUS: { fragment = new StatusFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id)); } break; } case LINK_ID_USER: { fragment = new UserProfileFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } break; } case LINK_ID_USER_LIST_MEMBERSHIPS: { fragment = new UserListMembershipsListFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } break; } case LINK_ID_USER_TIMELINE: { fragment = new UserTimelineFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } if (isEmpty(paramScreenName) && isEmpty(param_user_id)) return null; break; } case LINK_ID_USER_FAVORITES: { fragment = new UserFavoritesFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); } if (!args.containsKey(EXTRA_SCREEN_NAME) && !args.containsKey(EXTRA_USER_ID)) return null; break; } case LINK_ID_USER_FOLLOWERS: { fragment = new UserFollowersFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } if (isEmpty(paramScreenName) && isEmpty(param_user_id)) return null; break; } case LINK_ID_USER_FRIENDS: { fragment = new UserFriendsFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } if (isEmpty(paramScreenName) && isEmpty(param_user_id)) return null; break; } case LINK_ID_USER_BLOCKS: { fragment = new UserBlocksListFragment(); break; } case LINK_ID_MUTES_USERS: { fragment = new MutesUsersListFragment(); break; } case LINK_ID_DIRECT_MESSAGES_CONVERSATION: { fragment = new DirectMessagesConversationFragment(); final String paramRecipientId = uri.getQueryParameter(QUERY_PARAM_RECIPIENT_ID); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final long conversationId = ParseUtils.parseLong(paramRecipientId); if (conversationId > 0) { args.putLong(EXTRA_RECIPIENT_ID, conversationId); } else if (paramScreenName != null) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } break; } case LINK_ID_USER_LIST: { fragment = new UserListDetailsFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(param_list_id) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id))) return null; args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_USER_LISTS: { fragment = new UserListsListFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } if (isEmpty(paramScreenName) && isEmpty(param_user_id)) return null; break; } case LINK_ID_USER_LIST_TIMELINE: { fragment = new UserListTimelineFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(param_list_id) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id))) return null; args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_USER_LIST_MEMBERS: { fragment = new UserListMembersFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(param_list_id) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id))) return null; args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_USER_LIST_SUBSCRIBERS: { fragment = new UserListSubscribersFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String param_list_id = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(param_list_id) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(param_user_id))) return null; args.putInt(EXTRA_LIST_ID, ParseUtils.parseInt(param_list_id)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_SAVED_SEARCHES: { fragment = new SavedSearchesListFragment(); break; } case LINK_ID_USER_MENTIONS: { fragment = new UserMentionsFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); if (!args.containsKey(EXTRA_SCREEN_NAME) && !isEmpty(paramScreenName)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (isEmpty(args.getString(EXTRA_SCREEN_NAME))) return null; break; } case LINK_ID_INCOMING_FRIENDSHIPS: { fragment = new IncomingFriendshipsFragment(); break; } case LINK_ID_USERS: { fragment = new UsersListFragment(); break; } case LINK_ID_STATUSES: { fragment = new StatusesListFragment(); break; } case LINK_ID_STATUS_RETWEETERS: { fragment = new StatusRetweetersListFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id)); } break; } case LINK_ID_STATUS_FAVORITERS: { fragment = new StatusFavoritersListFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id)); } break; } case LINK_ID_STATUS_REPLIES: { fragment = new StatusRepliesListFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId)); } if (!args.containsKey(EXTRA_SCREEN_NAME)) { final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); args.putString(EXTRA_SCREEN_NAME, paramScreenName); } break; } case LINK_ID_SEARCH: { final String param_query = uri.getQueryParameter(QUERY_PARAM_QUERY); if (isEmpty(param_query)) return null; args.putString(EXTRA_QUERY, param_query); fragment = new SearchFragment(); break; } default: { return null; } } final String param_account_id = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID); if (param_account_id != null) { args.putLong(EXTRA_ACCOUNT_ID, ParseUtils.parseLong(param_account_id)); } else { final String param_account_name = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_NAME); if (param_account_name != null) { args.putLong(EXTRA_ACCOUNT_ID, getAccountId(context, param_account_name)); } else { final long account_id = getDefaultAccountId(context); if (isMyAccount(context, account_id)) { args.putLong(EXTRA_ACCOUNT_ID, account_id); } } } fragment.setArguments(args); if (isDebugBuild()) { Log.d(LOGTAG, String.format("createFragmentForIntent used %d ms", System.currentTimeMillis() - start)); } return fragment; }
From source file:org.getlantern.firetweet.util.Utils.java
public static Fragment createFragmentForIntent(final Context context, final int linkId, final Intent intent) { intent.setExtrasClassLoader(context.getClassLoader()); final Bundle extras = intent.getExtras(); final Uri uri = intent.getData(); final Fragment fragment; if (uri == null) return null; final Bundle args = new Bundle(); if (extras != null) { args.putAll(extras); }//from ww w. j av a2 s . com switch (linkId) { case LINK_ID_STATUS: { fragment = new StatusFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String param_status_id = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(param_status_id)); } break; } case LINK_ID_USER: { fragment = new UserFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } break; } case LINK_ID_USER_LIST_MEMBERSHIPS: { fragment = new UserListMembershipsListFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); } break; } case LINK_ID_USER_TIMELINE: { fragment = new UserTimelineFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); } if (isEmpty(paramScreenName) && isEmpty(paramUserId)) return null; break; } case LINK_ID_USER_MEDIA_TIMELINE: { fragment = new UserMediaTimelineFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); } if (isEmpty(paramScreenName) && isEmpty(paramUserId)) return null; break; } case LINK_ID_USER_FAVORITES: { fragment = new UserFavoritesFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); } if (!args.containsKey(EXTRA_SCREEN_NAME) && !args.containsKey(EXTRA_USER_ID)) return null; break; } case LINK_ID_USER_FOLLOWERS: { fragment = new UserFollowersFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } if (isEmpty(paramScreenName) && isEmpty(param_user_id)) return null; break; } case LINK_ID_USER_FRIENDS: { fragment = new UserFriendsFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String param_user_id = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(param_user_id)); } if (isEmpty(paramScreenName) && isEmpty(param_user_id)) return null; break; } case LINK_ID_USER_BLOCKS: { fragment = new UserBlocksListFragment(); break; } case LINK_ID_MUTES_USERS: { fragment = new MutesUsersListFragment(); break; } case LINK_ID_DIRECT_MESSAGES_CONVERSATION: { fragment = new MessagesConversationFragment(); final String paramRecipientId = uri.getQueryParameter(QUERY_PARAM_RECIPIENT_ID); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final long conversationId = ParseUtils.parseLong(paramRecipientId); if (conversationId > 0) { args.putLong(EXTRA_RECIPIENT_ID, conversationId); } else if (paramScreenName != null) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } break; } case LINK_ID_USER_LIST: { fragment = new UserListFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(paramListId) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId))) return null; args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_USER_LISTS: { fragment = new UserListsFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); if (!args.containsKey(EXTRA_SCREEN_NAME)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (!args.containsKey(EXTRA_USER_ID)) { args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); } if (isEmpty(paramScreenName) && isEmpty(paramUserId)) return null; break; } case LINK_ID_USER_LIST_TIMELINE: { fragment = new UserListTimelineFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(paramListId) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId))) return null; args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_USER_LIST_MEMBERS: { fragment = new UserListMembersFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(paramListId) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId))) return null; args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_USER_LIST_SUBSCRIBERS: { fragment = new UserListSubscribersFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); final String paramUserId = uri.getQueryParameter(QUERY_PARAM_USER_ID); final String paramListId = uri.getQueryParameter(QUERY_PARAM_LIST_ID); final String paramListName = uri.getQueryParameter(QUERY_PARAM_LIST_NAME); if (isEmpty(paramListId) && (isEmpty(paramListName) || isEmpty(paramScreenName) && isEmpty(paramUserId))) return null; args.putLong(EXTRA_LIST_ID, ParseUtils.parseLong(paramListId)); args.putLong(EXTRA_USER_ID, ParseUtils.parseLong(paramUserId)); args.putString(EXTRA_SCREEN_NAME, paramScreenName); args.putString(EXTRA_LIST_NAME, paramListName); break; } case LINK_ID_SAVED_SEARCHES: { fragment = new SavedSearchesListFragment(); break; } case LINK_ID_USER_MENTIONS: { fragment = new UserMentionsFragment(); final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); if (!args.containsKey(EXTRA_SCREEN_NAME) && !isEmpty(paramScreenName)) { args.putString(EXTRA_SCREEN_NAME, paramScreenName); } if (isEmpty(args.getString(EXTRA_SCREEN_NAME))) return null; break; } case LINK_ID_INCOMING_FRIENDSHIPS: { fragment = new IncomingFriendshipsFragment(); break; } case LINK_ID_USERS: { fragment = new UsersListFragment(); break; } case LINK_ID_STATUSES: { fragment = new StatusesListFragment(); break; } case LINK_ID_STATUS_RETWEETERS: { fragment = new StatusRetweetersListFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId)); } break; } case LINK_ID_STATUS_FAVORITERS: { fragment = new StatusFavoritersListFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId)); } break; } case LINK_ID_STATUS_REPLIES: { fragment = new StatusRepliesListFragment(); if (!args.containsKey(EXTRA_STATUS_ID)) { final String paramStatusId = uri.getQueryParameter(QUERY_PARAM_STATUS_ID); args.putLong(EXTRA_STATUS_ID, ParseUtils.parseLong(paramStatusId)); } if (!args.containsKey(EXTRA_SCREEN_NAME)) { final String paramScreenName = uri.getQueryParameter(QUERY_PARAM_SCREEN_NAME); args.putString(EXTRA_SCREEN_NAME, paramScreenName); } break; } case LINK_ID_SEARCH: { final String param_query = uri.getQueryParameter(QUERY_PARAM_QUERY); if (isEmpty(param_query)) return null; args.putString(EXTRA_QUERY, param_query); fragment = new SearchFragment(); break; } default: { return null; } } final String paramAccountId = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_ID); if (paramAccountId != null) { args.putLong(EXTRA_ACCOUNT_ID, ParseUtils.parseLong(paramAccountId)); } else { final String paramAccountName = uri.getQueryParameter(QUERY_PARAM_ACCOUNT_NAME); if (paramAccountName != null) { args.putLong(EXTRA_ACCOUNT_ID, getAccountId(context, paramAccountName)); } else { final long accountId = getDefaultAccountId(context); if (isMyAccount(context, accountId)) { args.putLong(EXTRA_ACCOUNT_ID, accountId); } } } fragment.setArguments(args); return fragment; }
From source file:com.android.launcher3.Launcher.java
/** * Add the views for a widget to the workspace. * * Implementation of the method from LauncherModel.Callbacks. *///ww w .ja v a 2 s.c o m public void bindAppWidget(final LauncherAppWidgetInfo item) { Runnable r = new Runnable() { public void run() { bindAppWidget(item); } }; if (waitUntilResume(r)) { return; } if (mIsSafeModeEnabled) { bindSafeModeWidget(item); return; } final long start = DEBUG_WIDGETS ? SystemClock.uptimeMillis() : 0; if (DEBUG_WIDGETS) { Log.d(TAG, "bindAppWidget: " + item); } final LauncherAppWidgetProviderInfo appWidgetInfo; if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY)) { // If the provider is not ready, bind as a pending widget. appWidgetInfo = null; } else if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) { // The widget id is not valid. Try to find the widget based on the provider info. appWidgetInfo = mAppWidgetManager.findProvider(item.providerName, item.user); } else { appWidgetInfo = mAppWidgetManager.getLauncherAppWidgetInfo(item.appWidgetId); } // If the provider is ready, but the width is not yet restored, try to restore it. if (!item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_PROVIDER_NOT_READY) && (item.restoreStatus != LauncherAppWidgetInfo.RESTORE_COMPLETED)) { if (appWidgetInfo == null) { if (DEBUG_WIDGETS) { Log.d(TAG, "Removing restored widget: id=" + item.appWidgetId + " belongs to component " + item.providerName + ", as the povider is null"); } LauncherModel.deleteItemFromDatabase(this, item); return; } // If we do not have a valid id, try to bind an id. if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_NOT_VALID)) { if (!item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_ID_ALLOCATED)) { // Id has not been allocated yet. Allocate a new id. item.appWidgetId = mAppWidgetHost.allocateAppWidgetId(); item.restoreStatus |= LauncherAppWidgetInfo.FLAG_ID_ALLOCATED; // Also try to bind the widget. If the bind fails, the user will be shown // a click to setup UI, which will ask for the bind permission. PendingAddWidgetInfo pendingInfo = new PendingAddWidgetInfo(this, appWidgetInfo); pendingInfo.spanX = item.spanX; pendingInfo.spanY = item.spanY; pendingInfo.minSpanX = item.minSpanX; pendingInfo.minSpanY = item.minSpanY; Bundle options = WidgetHostViewLoader.getDefaultOptionsForWidget(this, pendingInfo); boolean isDirectConfig = item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG); if (isDirectConfig && item.bindOptions != null) { Bundle newOptions = item.bindOptions.getExtras(); if (options != null) { newOptions.putAll(options); } options = newOptions; } boolean success = mAppWidgetManager.bindAppWidgetIdIfAllowed(item.appWidgetId, appWidgetInfo, options); // We tried to bind once. If we were not able to bind, we would need to // go through the permission dialog, which means we cannot skip the config // activity. item.bindOptions = null; item.restoreStatus &= ~LauncherAppWidgetInfo.FLAG_DIRECT_CONFIG; // Bind succeeded if (success) { // If the widget has a configure activity, it is still needs to set it up, // otherwise the widget is ready to go. item.restoreStatus = (appWidgetInfo.configure == null) || isDirectConfig ? LauncherAppWidgetInfo.RESTORE_COMPLETED : LauncherAppWidgetInfo.FLAG_UI_NOT_READY; } LauncherModel.updateItemInDatabase(this, item); } } else if (item.hasRestoreFlag(LauncherAppWidgetInfo.FLAG_UI_NOT_READY) && (appWidgetInfo.configure == null)) { // The widget was marked as UI not ready, but there is no configure activity to // update the UI. item.restoreStatus = LauncherAppWidgetInfo.RESTORE_COMPLETED; LauncherModel.updateItemInDatabase(this, item); } } if (item.restoreStatus == LauncherAppWidgetInfo.RESTORE_COMPLETED) { if (DEBUG_WIDGETS) { Log.d(TAG, "bindAppWidget: id=" + item.appWidgetId + " belongs to component " + appWidgetInfo.provider); } // Verify that we own the widget if (appWidgetInfo == null) { FileLog.e(TAG, "Removing invalid widget: id=" + item.appWidgetId); deleteWidgetInfo(item); return; } item.minSpanX = appWidgetInfo.minSpanX; item.minSpanY = appWidgetInfo.minSpanY; addAppWidgetToWorkspace(mAppWidgetHost.createView(this, item.appWidgetId, appWidgetInfo), item, appWidgetInfo, false); } else { PendingAppWidgetHostView view = new PendingAppWidgetHostView(this, item, false); view.updateIcon(mIconCache); view.updateAppWidget(null); view.setOnClickListener(this); addAppWidgetToWorkspace(view, item, null, false); } mWorkspace.requestLayout(); if (DEBUG_WIDGETS) { Log.d(TAG, "bound widget id=" + item.appWidgetId + " in " + (SystemClock.uptimeMillis() - start) + "ms"); } }
From source file:xyz.klinker.blur.launcher3.Launcher.java
@Override protected void onSaveInstanceState(Bundle outState) { // Catches the case where our activity is created and immediately destroyed and our views // are not yet fully bound. In this case, we can't trust the state of our activity and // instead save our previous state (which hasn't yet been consumed / applied, a fact we // know as it's not null) if (isWorkspaceLoading() && mSavedState != null) { outState.putAll(mSavedState); return;//from w w w.j a v a2s .co m } if (mWorkspace.getChildCount() > 0) { outState.putInt(RUNTIME_STATE_CURRENT_SCREEN, mWorkspace.getCurrentPageOffsetFromCustomContent()); } super.onSaveInstanceState(outState); outState.putInt(RUNTIME_STATE, mState.ordinal()); // We close any open folder since it will not be re-opened, and we need to make sure // this state is reflected. closeFolder(false); if (mPendingAddInfo.container != ItemInfo.NO_ID && mPendingAddInfo.screenId > -1 && mWaitingForResult) { outState.putLong(RUNTIME_STATE_PENDING_ADD_CONTAINER, mPendingAddInfo.container); outState.putLong(RUNTIME_STATE_PENDING_ADD_SCREEN, mPendingAddInfo.screenId); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_X, mPendingAddInfo.cellX); outState.putInt(RUNTIME_STATE_PENDING_ADD_CELL_Y, mPendingAddInfo.cellY); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_X, mPendingAddInfo.spanX); outState.putInt(RUNTIME_STATE_PENDING_ADD_SPAN_Y, mPendingAddInfo.spanY); outState.putParcelable(RUNTIME_STATE_PENDING_ADD_WIDGET_INFO, mPendingAddWidgetInfo); outState.putInt(RUNTIME_STATE_PENDING_ADD_WIDGET_ID, mPendingAddWidgetId); } // Save the current widgets tray? // TODO(hyunyoungs) if (mLauncherCallbacks != null) { mLauncherCallbacks.onSaveInstanceState(outState); } }
From source file:xyz.klinker.blur.launcher3.Launcher.java
public View getOrCreateQsbBar() { if (launcherCallbacksProvidesSearch()) { return mLauncherCallbacks.getQsbBar(); }//from ww w . j a va2 s . co m if (mQsb == null) { AppWidgetProviderInfo searchProvider = Utilities.getSearchWidgetProvider(this); if (searchProvider == null) { return null; } Bundle opts = new Bundle(); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_HOST_CATEGORY, AppWidgetProviderInfo.WIDGET_CATEGORY_SEARCHBOX); // Determine the min and max dimensions of the widget. LauncherAppState app = LauncherAppState.getInstance(); DeviceProfile portraitProfile = app.getInvariantDeviceProfile().portraitProfile; DeviceProfile landscapeProfile = app.getInvariantDeviceProfile().landscapeProfile; float density = getResources().getDisplayMetrics().density; Point searchDimens = portraitProfile.getSearchBarDimensForWidgetOpts(getResources()); int maxHeight = (int) (searchDimens.y / density); int minHeight = maxHeight; int maxWidth = (int) ((searchDimens.x / density) / 5) * 3; int minWidth = maxWidth; if (!landscapeProfile.isVerticalBarLayout()) { searchDimens = landscapeProfile.getSearchBarDimensForWidgetOpts(getResources()); maxHeight = (int) Math.max(maxHeight, searchDimens.y / density); minHeight = (int) Math.min(minHeight, searchDimens.y / density); maxWidth = (int) Math.max(maxWidth, searchDimens.x / density); minWidth = (int) Math.min(minWidth, searchDimens.x / density); } opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_HEIGHT, maxHeight); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_HEIGHT, minHeight); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MAX_WIDTH, maxWidth); opts.putInt(AppWidgetManager.OPTION_APPWIDGET_MIN_WIDTH, minWidth); if (LOGD) { Log.d(TAG, "QSB widget options: maxHeight=" + maxHeight + " minHeight=" + minHeight + " maxWidth=" + maxWidth + " minWidth=" + minWidth); } if (mLauncherCallbacks != null) { opts.putAll(mLauncherCallbacks.getAdditionalSearchWidgetOptions()); } int widgetId = mSharedPrefs.getInt(QSB_WIDGET_ID, -1); AppWidgetProviderInfo widgetInfo = mAppWidgetManager.getAppWidgetInfo(widgetId); if (!searchProvider.provider.flattenToString().equals(mSharedPrefs.getString(QSB_WIDGET_PROVIDER, null)) || (widgetInfo == null) || !widgetInfo.provider.equals(searchProvider.provider)) { // A valid widget is not already bound. if (widgetId > -1) { mAppWidgetHost.deleteAppWidgetId(widgetId); widgetId = -1; } // Try to bind a new widget widgetId = View.generateViewId(); mSharedPrefs.edit().putInt(QSB_WIDGET_ID, widgetId) .putString(QSB_WIDGET_PROVIDER, searchProvider.provider.flattenToString()).apply(); } mAppWidgetHost.setQsbWidgetId(widgetId); if (widgetId != -1) { mQsb = mAppWidgetHost.createView(this, widgetId, searchProvider); mQsb.setId(R.id.qsb_widget); mQsb.updateAppWidgetOptions(opts); // on tablets, we don't need this widget taking up the whole screen. It looks better // with some padding on the sides if (getResources().getBoolean(R.bool.reduce_search_width)) { Display display = getWindowManager().getDefaultDisplay(); Point size = new Point(); display.getSize(size); mQsb.setPadding(size.x / 8, 0, size.x / 8, 0); } else { mQsb.setPadding(0, 0, 0, 0); } mSearchDropTargetBar.addView(mQsb); mSearchDropTargetBar.setQsbSearchBar(mQsb); if (AppSettings.getInstance(this).showSearchBar) { createClickableSearch(1); } else { mQsb.getLayoutParams().width = 0; } } } return mQsb; }