List of usage examples for android.os Bundle EMPTY
Bundle EMPTY
To view the source code for android.os Bundle EMPTY.
Click Source Link
From source file:com.chen.mail.ui.AbstractActivityController.java
/** * The application can be started from the following entry points: * <ul>//from w ww .j a v a 2 s.co m * <li>Launcher: you tap on the Gmail icon in the launcher. This is what most users think of * as Starting the app?.</li> * <li>Shortcut: Users can make a shortcut to take them directly to a label.</li> * <li>Widget: Shows the contents of a synced label, and allows: * <ul> * <li>Viewing the list (tapping on the title)</li> * <li>Composing a new message (tapping on the new message icon in the title. This * launches the {@link ComposeActivity}. * </li> * <li>Viewing a single message (tapping on a list element)</li> * </ul> * * </li> * <li>Tapping on a notification: * <ul> * <li>Shows message list if more than one message</li> * <li>Shows the conversation if the notification is for a single message</li> * </ul> * </li> * <li>...and most importantly, the activity life cycle can tear down the application and * restart it: * <ul> * <li>Rotate the application: it is destroyed and recreated.</li> * <li>Navigate away, and return from recent applications.</li> * </ul> * </li> * <li>Add a new account: fires off an intent to add an account, * and returns in {@link #onActivityResult(int, int, android.content.Intent)} .</li> * <li>Re-authenticate your account: again returns in onActivityResult().</li> * <li>Composing can happen from many entry points: third party applications fire off an * intent to compose email, and launch directly into the {@link ComposeActivity} * .</li> * </ul> * {@inheritDoc} */ @Override public boolean onCreate(Bundle savedState) { initializeActionBar(); initializeDevLoggingService(); // Allow shortcut keys to function for the ActionBar and menus. mActivity.setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT); mResolver = mActivity.getContentResolver(); mNewEmailReceiver = new SuppressNotificationReceiver(); mRecentFolderList.initialize(mActivity); mVeiledMatcher.initialize(this); // the "open drawer description" argument is for when the drawer is open // so tell the user that interacting will cause the drawer to close // and vice versa for the "close drawer description" argument mDrawerToggle = new ActionBarDrawerToggle((Activity) mActivity, mDrawerContainer, R.drawable.ic_drawer, R.string.drawer_close, R.string.drawer_open); mDrawerListener = new MailDrawerListener(); mDrawerContainer.setDrawerListener(mDrawerListener); mDrawerContainer.setDrawerShadow(mContext.getResources().getDrawable(R.drawable.drawer_shadow), Gravity.START); mDrawerToggle.setDrawerIndicatorEnabled(isDrawerEnabled()); // All the individual UI components listen for ViewMode changes. This // simplifies the amount of logic in the AbstractActivityController, but increases the // possibility of timing-related bugs. mViewMode.addListener(this); mPagerController = new ConversationPagerController(mActivity, this); mToastBar = (ActionableToastBar) mActivity.findViewById(R.id.toast_bar); attachActionBar(); FolderSelectionDialog.setDialogDismissed(); mDrawIdler.setRootView(mActivity.getWindow().getDecorView()); final Intent intent = mActivity.getIntent(); // Immediately handle a clean launch with intent, and any state restoration // that does not rely on restored fragments or loader data // any state restoration that relies on those can be done later in // onRestoreInstanceState, once fragments are up and loader data is re-delivered if (savedState != null) { if (savedState.containsKey(SAVED_ACCOUNT)) { setAccount((Account) savedState.getParcelable(SAVED_ACCOUNT)); } if (savedState.containsKey(SAVED_FOLDER)) { final Folder folder = savedState.getParcelable(SAVED_FOLDER); final String query = savedState.getString(SAVED_QUERY, null); setListContext(folder, query); } if (savedState.containsKey(SAVED_ACTION)) { mDialogAction = savedState.getInt(SAVED_ACTION); } mDialogFromSelectedSet = savedState.getBoolean(SAVED_ACTION_FROM_SELECTED, false); mViewMode.handleRestore(savedState); } else if (intent != null) { handleIntent(intent); } // Create the accounts loader; this loads the account switch spinner. mActivity.getLoaderManager().initLoader(LOADER_ACCOUNT_CURSOR, Bundle.EMPTY, mAccountCallbacks); return true; }
From source file:com.tct.mail.ui.FolderListFragment.java
/** * Sets the current account to the one provided here. * @param account the current account to set to. *//* www .j a va2 s . co m*/ private void setSelectedAccount(Account account) { final boolean changed = (account != null) && (mCurrentAccount == null || !mCurrentAccount.uri.equals(account.uri)); mCurrentAccount = account; if (changed) { // Verify that the new account supports sending application feedback updateFooterItems(); // We no longer have proper folder objects. Let the new ones come in mFolderAdapter.setCursor(null); // If currentAccount is different from the one we set, restart the loader. Look at the // comment on {@link AbstractActivityController#restartOptionalLoader} to see why we // don't just do restartLoader. final LoaderManager manager = getLoaderManager(); manager.destroyLoader(FOLDER_LIST_LOADER_ID); manager.restartLoader(FOLDER_LIST_LOADER_ID, Bundle.EMPTY, this); manager.destroyLoader(ALL_FOLDER_LIST_LOADER_ID); manager.restartLoader(ALL_FOLDER_LIST_LOADER_ID, Bundle.EMPTY, this); // An updated cursor causes the entire list to refresh. No need to refresh the list. // But we do need to blank out the current folder, since the account might not be // synced. mSelectedFolderUri = FolderUri.EMPTY; mCurrentFolderForUnreadCheck = null; // also set/update the mini-drawer if (mMiniDrawerEnabled) { //foobar mMiniDrawerView.refresh(); } } else if (account == null) { // This should never happen currently, but is a safeguard against a very incorrect // non-null account -> null account transition. LogUtils.e(LOG_TAG, "FLF.setSelectedAccount(null) called! Destroying existing loader."); final LoaderManager manager = getLoaderManager(); manager.destroyLoader(FOLDER_LIST_LOADER_ID); manager.destroyLoader(ALL_FOLDER_LIST_LOADER_ID); } }
From source file:com.tct.mail.ui.AbstractActivityController.java
@Override public void loadAccountInbox() { boolean handled = false; if (mFolderWatcher != null) { final Folder inbox = mFolderWatcher.getDefaultInbox(mAccount); if (inbox != null) { onFolderChanged(inbox, false /* force */); handled = true;//from w ww . j av a 2 s . c o m } } if (!handled) { LogUtils.d(LOG_TAG, "Starting a LOADER_ACCOUNT_INBOX for %s", mAccount); restartOptionalLoader(LOADER_ACCOUNT_INBOX, mFolderCallbacks, Bundle.EMPTY); //TS: chaozhang 2015-6-26 EMAIL BUGFIX_1022808 ADD_S LogUtils.d(LOG_TAG, "Restart a LOADER_ACCOUNT_INBOX"); // if the inbox has not be prepared when we change to new account, we must revert everything /// that depends on a mailbox. such as loader, actionbar @{ final LoaderManager lm = mActivity.getLoaderManager(); lm.destroyLoader(LOADER_FOLDER_CURSOR); // Also destroy the loader LOADER_CONVERSATION_LIST. lm.destroyLoader(LOADER_CONVERSATION_LIST); mInbox = null; mFolder = null; mActionBarController.setFolder(mFolder); perhapsEnterWaitMode(); return; //TS: chaozhang 2015-6-26 EMAIL BUGFIX_1022808 ADD_E } final int mode = mViewMode.getMode(); if (mode == ViewMode.UNKNOWN || mode == ViewMode.WAITING_FOR_ACCOUNT_INITIALIZATION) { mViewMode.enterConversationListMode(); } }
From source file:com.android.mail.ui.FolderListFragment.java
/** * Sets the current account to the one provided here. * @param account the current account to set to. *//*from w w w. java 2s. c o m*/ private void setSelectedAccount(Account account) { final boolean changed = (account != null) && (mCurrentAccount == null || !mCurrentAccount.uri.equals(account.uri)); mCurrentAccount = account; if (changed) { // Verify that the new account supports sending application feedback updateFooterItems(); // We no longer have proper folder objects. Let the new ones come in mFolderAdapter.setCursor(null); // If currentAccount is different from the one we set, restart the loader. Look at the // comment on {@link AbstractActivityController#restartOptionalLoader} to see why we // don't just do restartLoader. final LoaderManager manager = getLoaderManager(); manager.destroyLoader(FOLDER_LIST_LOADER_ID); manager.restartLoader(FOLDER_LIST_LOADER_ID, Bundle.EMPTY, this); manager.destroyLoader(ALL_FOLDER_LIST_LOADER_ID); manager.restartLoader(ALL_FOLDER_LIST_LOADER_ID, Bundle.EMPTY, this); // An updated cursor causes the entire list to refresh. No need to refresh the list. // But we do need to blank out the current folder, since the account might not be // synced. mSelectedFolderUri = FolderUri.EMPTY; mCurrentFolderForUnreadCheck = null; // also set/update the mini-drawer if (mMiniDrawerAccountsAdapter != null) { mMiniDrawerAccountsAdapter.setAccounts(getAllAccounts(), mCurrentAccount); } } else if (account == null) { // This should never happen currently, but is a safeguard against a very incorrect // non-null account -> null account transition. LogUtils.e(LOG_TAG, "FLF.setSelectedAccount(null) called! Destroying existing loader."); final LoaderManager manager = getLoaderManager(); manager.destroyLoader(FOLDER_LIST_LOADER_ID); manager.destroyLoader(ALL_FOLDER_LIST_LOADER_ID); } }
From source file:com.android.mail.ui.AbstractActivityController.java
/** * The application can be started from the following entry points: * <ul>/*from ww w . ja v a 2 s .com*/ * <li>Launcher: you tap on the Gmail icon in the launcher. This is what most users think of * as Starting the app?.</li> * <li>Shortcut: Users can make a shortcut to take them directly to a label.</li> * <li>Widget: Shows the contents of a synced label, and allows: * <ul> * <li>Viewing the list (tapping on the title)</li> * <li>Composing a new message (tapping on the new message icon in the title. This * launches the {@link ComposeActivity}. * </li> * <li>Viewing a single message (tapping on a list element)</li> * </ul> * * </li> * <li>Tapping on a notification: * <ul> * <li>Shows message list if more than one message</li> * <li>Shows the conversation if the notification is for a single message</li> * </ul> * </li> * <li>...and most importantly, the activity life cycle can tear down the application and * restart it: * <ul> * <li>Rotate the application: it is destroyed and recreated.</li> * <li>Navigate away, and return from recent applications.</li> * </ul> * </li> * <li>Add a new account: fires off an intent to add an account, * and returns in {@link #onActivityResult(int, int, android.content.Intent)} .</li> * <li>Re-authenticate your account: again returns in onActivityResult().</li> * <li>Composing can happen from many entry points: third party applications fire off an * intent to compose email, and launch directly into the {@link ComposeActivity} * .</li> * </ul> * {@inheritDoc} */ @Override public void onCreate(Bundle savedState) { initializeActionBar(); initializeDevLoggingService(); // Allow shortcut keys to function for the ActionBar and menus. mActivity.setDefaultKeyMode(Activity.DEFAULT_KEYS_SHORTCUT); mResolver = mActivity.getContentResolver(); mNewEmailReceiver = new SuppressNotificationReceiver(); mRecentFolderList.initialize(mActivity); mVeiledMatcher.initialize(this); mFloatingComposeButton = mActivity.findViewById(R.id.compose_button); mFloatingComposeButton.setOnClickListener(this); if (isDrawerEnabled()) { mDrawerToggle = new ActionBarDrawerToggle(mActivity, mDrawerContainer, R.string.drawer_open, R.string.drawer_close); mDrawerContainer.setDrawerListener(mDrawerListener); mDrawerContainer.setDrawerShadow(mContext.getResources().getDrawable(R.drawable.drawer_shadow), Gravity.START); // Disable default drawer indicator as we are setting the drawer indicator icons. // TODO(shahrk): Once we can disable/enable drawer animation, go back to using // drawer indicators. mDrawerToggle.setDrawerIndicatorEnabled(false); mDrawerToggle.setHomeAsUpIndicator(R.drawable.ic_menu_wht_24dp); } else { final ActionBar ab = mActivity.getSupportActionBar(); ab.setHomeAsUpIndicator(R.drawable.ic_menu_wht_24dp); ab.setHomeActionContentDescription(R.string.drawer_open); ab.setDisplayHomeAsUpEnabled(true); } // All the individual UI components listen for ViewMode changes. This // simplifies the amount of logic in the AbstractActivityController, but increases the // possibility of timing-related bugs. mViewMode.addListener(this); mPagerController = new ConversationPagerController(mActivity, this); mToastBar = findActionableToastBar(mActivity); attachActionBar(); mDrawIdler.setRootView(mActivity.getWindow().getDecorView()); final Intent intent = mActivity.getIntent(); mSearchViewController = new MaterialSearchViewController(mActivity, this, intent, savedState); addConversationListLayoutListener(mSearchViewController); // Immediately handle a clean launch with intent, and any state restoration // that does not rely on restored fragments or loader data // any state restoration that relies on those can be done later in // onRestoreInstanceState, once fragments are up and loader data is re-delivered if (savedState != null) { if (savedState.containsKey(SAVED_ACCOUNT)) { setAccount((Account) savedState.getParcelable(SAVED_ACCOUNT)); } if (savedState.containsKey(SAVED_FOLDER)) { final Folder folder = savedState.getParcelable(SAVED_FOLDER); final String query = savedState.getString(SAVED_QUERY, null); setListContext(folder, query); } if (savedState.containsKey(SAVED_ACTION)) { mDialogAction = savedState.getInt(SAVED_ACTION); } mDialogFromSelectedSet = savedState.getBoolean(SAVED_ACTION_FROM_SELECTED, false); mViewMode.handleRestore(savedState); } else if (intent != null) { handleIntent(intent); } // Create the accounts loader; this loads the account switch spinner. mActivity.getLoaderManager().initLoader(LOADER_ACCOUNT_CURSOR, Bundle.EMPTY, mAccountCallbacks); }
From source file:com.tct.mail.ui.AbstractActivityController.java
/** * Sets the current folder if it is different from the object provided here. This method does * NOT notify the folder observers that a change has happened. Observers are notified when we * get an updated folder from the loaders, which will happen as a consequence of this method * (since this method starts/restarts the loaders). * @param folder The folder to assign/* ww w . j av a 2s . c o m*/ */ private void updateFolder(Folder folder) { if (folder == null || !folder.isInitialized()) { LogUtils.e(LOG_TAG, new Error(), "AAC.setFolder(%s): Bad input", folder); return; } if (folder.equals(mFolder)) { LogUtils.d(LOG_TAG, "AAC.setFolder(%s): Input matches mFolder", folder); return; } final boolean wasNull = mFolder == null; LogUtils.d(LOG_TAG, "AbstractActivityController.setFolder(%s)", folder.name); final LoaderManager lm = mActivity.getLoaderManager(); // updateFolder is called from AAC.onLoadFinished() on folder changes. We need to // ensure that the folder is different from the previous folder before marking the // folder changed. setHasFolderChanged(folder); mFolder = folder; // We do not need to notify folder observers yet. Instead we start the loaders and // when the load finishes, we will get an updated folder. Then, we notify the // folderObservers in onLoadFinished. mActionBarController.setFolder(mFolder); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-S mActivity.invalidateOptionsMenu(); //TS: junwei-xu 2015-09-02 EMAIL BUGFIX-546917 ADD-E // Only when we switch from one folder to another do we want to restart the // folder and conversation list loaders (to trigger onCreateLoader). // The first time this runs when the activity is [re-]initialized, we want to re-use the // previous loader's instance and data upon configuration change (e.g. rotation). // If there was not already an instance of the loader, init it. if (lm.getLoader(LOADER_FOLDER_CURSOR) == null) { lm.initLoader(LOADER_FOLDER_CURSOR, Bundle.EMPTY, mFolderCallbacks); } else { lm.restartLoader(LOADER_FOLDER_CURSOR, Bundle.EMPTY, mFolderCallbacks); } if (!wasNull && lm.getLoader(LOADER_CONVERSATION_LIST) != null) { // If there was an existing folder AND we have changed // folders, we want to restart the loader to get the information // for the newly selected folder lm.destroyLoader(LOADER_CONVERSATION_LIST); } /// TCT: Fix the empty view will always flash out here. no need show empty view when folde changing, // folders, we want to restart the loader to get the information /// cause loadConversationListData would always destroy loader,and the cursor always be empty when do this. @{ // for the newly selected folder final ConversationListFragment conversationList = getConversationListFragment(); // TS: zheng.zou 2015-05-8 EMAIL BUGFIX-976970 DEL_S // lm.destroyLoader(LOADER_CONVERSATION_LIST); // TS: zheng.zou 2015-05-8 EMAIL BUGFIX-976970 DEL_E if (conversationList != null) { conversationList.getListView().setEmptyView(null); } loadConversationListData(true); }
From source file:com.tct.mail.ui.AbstractActivityController.java
/** * The mail activity calls other activities for two specific reasons: * <ul>/*from w w w .ja v a 2 s . c o m*/ * <li>To add an account. And receives the result {@link #ADD_ACCOUNT_REQUEST_CODE}</li> * <li>To update the password on a current account. The result {@link * #REAUTHENTICATE_REQUEST_CODE} is received.</li> * </ul> * @param requestCode * @param resultCode * @param data */ @Override public void onActivityResult(int requestCode, int resultCode, Intent data) { switch (requestCode) { case ADD_ACCOUNT_REQUEST_CODE: // We were waiting for the user to create an account // TS: zhonghua.tuo 2015-03-18 EMAIL BUGFIX-948923 ADD_S mFirstLoadAccount = true; // TS: zhonghua.tuo 2015-03-18 EMAIL BUGFIX-948923 ADD_E if (resultCode == Activity.RESULT_OK) { // restart the loader to get the updated list of accounts mActivity.getLoaderManager().initLoader(LOADER_ACCOUNT_CURSOR, Bundle.EMPTY, mAccountCallbacks); } else { // The user failed to create an account, just exit the app mActivity.finish(); } break; case REAUTHENTICATE_REQUEST_CODE: if (resultCode == Activity.RESULT_OK) { // The user successfully authenticated, attempt to refresh the list final Uri refreshUri = mFolder != null ? mFolder.refreshUri : null; if (refreshUri != null) { startAsyncRefreshTask(refreshUri); } } break; case CHANGE_NAVIGATION_REQUEST_CODE: if (resultCode == Activity.RESULT_OK && data != null) { // We have have received a result that indicates we need to navigate to a // different folder or account. This happens if someone navigates using the // drawer on the search results activity. final Folder folder = data.getParcelableExtra(EXTRA_FOLDER); final Account account = data.getParcelableExtra(EXTRA_ACCOUNT); if (folder != null) { onFolderSelected(folder); mViewMode.enterConversationListMode(); } else if (account != null) { switchToDefaultInboxOrChangeAccount(account); mViewMode.enterConversationListMode(); } } break; } }
From source file:com.android.mail.browse.ConversationCursor.java
@Override public Bundle getExtras() { return mUnderlyingCursor != null ? mUnderlyingCursor.getExtras() : Bundle.EMPTY; }
From source file:com.android.mail.browse.ConversationCursor.java
@Override public Bundle respond(Bundle extras) { if (mUnderlyingCursor != null) { return mUnderlyingCursor.respond(extras); }/*from w w w . j a v a2 s.com*/ return Bundle.EMPTY; }
From source file:com.android.mail.compose.ComposeActivity.java
private void initAttachmentsFromIntent(Intent intent) { Bundle extras = intent.getExtras();/*from w ww . j av a 2 s .co m*/ if (extras == null) { extras = Bundle.EMPTY; } final String action = intent.getAction(); if (!mAttachmentsChanged) { long totalSize = 0; if (extras.containsKey(EXTRA_ATTACHMENTS)) { final String[] uris = (String[]) extras.getSerializable(EXTRA_ATTACHMENTS); final ArrayList<Uri> parsedUris = Lists.newArrayListWithCapacity(uris.length); for (String uri : uris) { parsedUris.add(Uri.parse(uri)); } totalSize += handleAttachmentUrisFromIntent(parsedUris); } if (extras.containsKey(Intent.EXTRA_STREAM)) { if (Intent.ACTION_SEND_MULTIPLE.equals(action)) { final ArrayList<Uri> uris = extras.getParcelableArrayList(Intent.EXTRA_STREAM); totalSize += handleAttachmentUrisFromIntent(uris); } else { final Uri uri = extras.getParcelable(Intent.EXTRA_STREAM); final ArrayList<Uri> uris = Lists.newArrayList(uri); totalSize += handleAttachmentUrisFromIntent(uris); } } if (totalSize > 0) { mAttachmentsChanged = true; updateSaveUi(); Analytics.getInstance().sendEvent("send_intent_with_attachments", Integer.toString(getAttachments().size()), null, totalSize); } } }