Example usage for android.os Bundle EMPTY

List of usage examples for android.os Bundle EMPTY

Introduction

In this page you can find the example usage for android.os Bundle EMPTY.

Prototype

Bundle EMPTY

To view the source code for android.os Bundle EMPTY.

Click Source Link

Usage

From source file:com.android.mail.ui.ConversationViewFragment.java

/**
 * Can be overridden in case a subclass needs to load something other than
 * the messages of a conversation.//www .j av  a 2 s . c om
 */
protected void loadContent() {
    getLoaderManager().initLoader(MESSAGE_LOADER, Bundle.EMPTY, getMessageLoaderCallbacks());
}

From source file:com.tct.mail.browse.MessageHeaderView.java

private void render(boolean measureOnly) {
    if (mMessageHeaderItem == null) {
        return;//from   ww w  .  j a v a  2 s. c o m
    }

    Timer t = new Timer();
    t.start(HEADER_RENDER_TAG);

    mRecipientSummaryValid = false;
    mExpandedDetailsValid = false;

    mMessage = mMessageHeaderItem.getMessage();

    final Account account = getAccount();
    final boolean alwaysShowImagesForAccount = (account != null)
            && (account.settings.showImages == Settings.ShowImages.ALWAYS);

    final boolean alwaysShowImagesForMessage = mMessage.shouldShowImagePrompt();

    if (!alwaysShowImagesForMessage) {
        // we don't need the "Show picture" prompt if the user allows images for this message
        mShowImagePrompt = false;
    } else if (mCallbacks.isSecure()) {
        // in a secure view we always display the "Show picture" prompt
        mShowImagePrompt = true;
    } else {
        // otherwise honor the account setting for automatically showing pictures
        mShowImagePrompt = !alwaysShowImagesForAccount;
    }

    setExpanded(mMessageHeaderItem.isExpanded());

    mFrom = mMessage.getFromAddresses();
    mTo = mMessage.getToAddresses();
    mCc = mMessage.getCcAddresses();
    mBcc = mMessage.getBccAddresses();
    mReplyTo = mMessage.getReplyToAddresses();
    //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/25/2014,FR 631895(porting from  FR487417)
    mId = mMessage.getId();
    //[FEATURE]-Add-END by TSCD.chao zhang
    /**
     * Turns draft mode on or off. Draft mode hides message operations other
     * than "edit", hides contact photo, hides presence, and changes the
     * sender name to "Draft".
     */
    mIsDraft = mMessage.draftType != UIProvider.DraftType.NOT_A_DRAFT;
    mSendingState = mMessage.sendingState;
    // TS: chao.zhang 2015-09-29 EMAIL FEATURE-585337 ADD_S
    //NOTE: Only display draft mode during message send failed.
    if (!mIsDraft || (mSendingState != UIProvider.ConversationSendingState.OTHER
            && mSendingState != UIProvider.ConversationSendingState.SEND_ERROR)) {
        mIsDraft = false;
    }
    // TS: chao.zhang 2015-09-29 EMAIL FEATURE-585337 ADD_E
    // If this was a sent message AND:
    // 1. the account has a custom from, the cursor will populate the
    // selected custom from as the fromAddress when a message is sent but
    // not yet synced.
    // 2. the account has no custom froms, fromAddress will be empty, and we
    // can safely fall back and show the account name as sender since it's
    // the only possible fromAddress.
    String from = mMessage.getFrom();
    if (TextUtils.isEmpty(from)) {
        from = (account != null) ? account.getEmailAddress() : "";
    }
    mSender = getAddress(from);

    // TS: junwei-xu 2015-09-06 EMAIL BUGFIX-526192 DEL_S
    // TS: junwei-xu 2015-06-19 EMAIL BUGFIX_965608 ADD_S
    /*
    if (mPriority != null) {
    mPriority.setImageLevel(getPriorityOptionValue(mMessage.mPriority));
    }
    */
    /*
    //[FEATURE]-Add-BEGIN by TSCD.chao zhang,04/17/2014,FR 631895(porting from FR514398)
    final Conversation conversation = mMessage.getConversation();
    if (conversation != null) {
      mMessage.mPriority=conversation.flagPriority;
    if(mPriority!=null){
        mPriority.setImageLevel(getPriorityOptionValue(conversation.flagPriority));
    }
     //[FEATURE]-Add-END by TSCD.chao zhang
    }
    */
    // TS: junwei-xu 2015-06-19 EMAIL BUGFIX_965608 ADD_E
    // TS: junwei-xu 2015-09-06 EMAIL BUGFIX-526192 DEL_E
    //TS: Gantao 2015-06-15 EMAIL BUGFIX_1001086 MOD_S
    updateChildVisibility(false);
    //TS: Gantao 2015-06-15 EMAIL BUGFIX_1001086 MOD_E

    final String snippet;
    if (mIsDraft || mSendingState != UIProvider.ConversationSendingState.OTHER) {
        snippet = makeSnippet(mMessage.snippet);
    } else {
        snippet = mMessage.snippet;
    }
    mSnippet = snippet == null ? null : getBidiFormatter().unicodeWrap(snippet);

    mSenderNameView.setText(getHeaderTitle());
    setRecipientSummary();
    setDateText();
    mSnippetView.setText(mSnippet);
    setAddressOnContextMenu();

    if (mUpperDateView != null) {
        mUpperDateView.setText(mMessageHeaderItem.getTimestampShort());
    }

    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID MOD_S
    final Integer attachmentLoaderId = getAttachmentLoaderId();

    // Destroy the loader if we are attempting to load a different
    // attachment
    // TS: zhaotianyong 2015-02-17 EMAIL BUGFIX_933187 MOD_S
    // TS: wenggangjin 2015-01-15 EMAIL BUGFIX_881446 MOD_S
    if (mOldAttachmentLoaderId != null
            && (!Objects.equal(mOldAttachmentLoaderId, attachmentLoaderId) || mIsDraft)) {// TS:
                                                                                                                             // chenyanhua
                                                                                                                             // 2015-03-02
                                                                                                                             // EMAIL
                                                                                                                             // BUGFIX_936358
                                                                                                                             // MOD
                                                                                                                             // TS: wenggangjin 2015-01-15 EMAIL BUGFIX_881446 MOD_E
                                                                                                                             // TS: zhaotianyong 2015-02-17 EMAIL BUGFIX_933187 MOD_E // reback
                                                                                                                             // the BUGFIX_881446
        mLoaderManager.destroyLoader(mOldAttachmentLoaderId);

        // Resets the footer view. This step is only done if the
        // attachmentsListUri changes so that we don't
        // repeat the work of layout and measure when
        // we're only updating the attachments.
        // TS: Gantao 2015-06-15 EMAIL BUGFIX_1001086 MOD_S
        mAttachmentBarListLayout.removeAllViewsInLayout();
        mAttachmentBarScorll.setVisibility(View.GONE);
    }
    mOldAttachmentLoaderId = attachmentLoaderId;

    // kick off load of Attachment objects in background thread
    // but don't do any Loader work if we're only measuring
    if (!measureOnly && attachmentLoaderId != null) {
        LogUtils.i(LOG_TAG, "binding footer view, calling initLoader for message %d", attachmentLoaderId);
        mLoaderManager.initLoader(attachmentLoaderId, Bundle.EMPTY, this);
    }
    //[Defect]-Del-BEGINbySCDTABLET.qiao-yang@tcl.com,05/12/2016,2004459,
    if (mAttachmentBarListLayout.getChildCount() == 0 /*&& mMessage.hasAttachments*/) { // TS:
        // Gantao
        // 2016-02-23
        // EMAIL
        // BUGFIX_1649841
        // MOD
        renderAttachments(false);
    }
    //[Defect]-Del-ENDbySCDTABLET.qiao-yang@tcl.com
    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID MOD_E

    if (measureOnly) {
        // avoid leaving any state around that would interfere with future regular bind() calls
        unbind();
    } else {
        updateContactInfo();
        if (!mObservingContactInfo) {
            mContactInfoSource.registerObserver(mContactInfoObserver);
            mObservingContactInfo = true;
        }
    }

    t.pause(HEADER_RENDER_TAG);
}

From source file:org.thoughtcrime.securesms.conversation.ConversationFragment.java

private void moveToMessagePosition(int position, @Nullable Runnable onMessageNotFound) {
    Log.d(TAG, "Moving to message position: " + position + "  activeOffset: " + activeOffset + "  cursorCount: "
            + getListAdapter().getCursorCount());

    if (position >= activeOffset && position >= 0 && position < getListAdapter().getCursorCount()) {
        int offset = activeOffset > 0 ? activeOffset - 1 : 0;
        list.scrollToPosition(position - offset);
        getListAdapter().pulseHighlightItem(position - offset);
    } else if (position < 0) {
        Log.w(TAG, "Tried to navigate to message, but it wasn't found.");
        if (onMessageNotFound != null) {
            onMessageNotFound.run();/*  ww w .j a  v a 2  s.c om*/
        }
    } else {
        Log.i(TAG, "Message was outside of the loaded range. Need to restart the loader.");

        firstLoad = true;
        startingPosition = position;
        getLoaderManager().restartLoader(0, Bundle.EMPTY, ConversationFragment.this);
    }
}

From source file:com.chen.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  w w .j  av  a 2 s  .co m*/
        }
    }
    if (!handled) {
        LogUtils.w(LOG_TAG, "Starting a LOADER_ACCOUNT_INBOX for %s", mAccount);
        restartOptionalLoader(LOADER_ACCOUNT_INBOX, mFolderCallbacks, Bundle.EMPTY);
    }
    final int mode = mViewMode.getMode();
    if (mode == ViewMode.UNKNOWN || mode == ViewMode.WAITING_FOR_ACCOUNT_INITIALIZATION) {
        mViewMode.enterConversationListMode();
    }
}

From source file:com.android.mail.ui.AbstractActivityController.java

/**
 * Load the default inbox associated with the current account.
 *//*from w w  w  .  j  av  a  2  s  .c  o  m*/
protected void loadAccountInbox() {
    boolean handled = false;
    if (mFolderWatcher != null) {
        final Folder inbox = mFolderWatcher.getDefaultInbox(mAccount);
        if (inbox != null) {
            onFolderChanged(inbox, false /* force */);
            handled = true;
        }
    }
    if (!handled) {
        LogUtils.d(LOG_TAG, "Starting a LOADER_ACCOUNT_INBOX for %s", mAccount);
        restartOptionalLoader(LOADER_ACCOUNT_INBOX, mFolderCallbacks, Bundle.EMPTY);
    }
    final int mode = mViewMode.getMode();
    if (mode == ViewMode.UNKNOWN || mode == ViewMode.WAITING_FOR_ACCOUNT_INITIALIZATION) {
        mViewMode.enterConversationListMode();
    }
}

From source file:com.chen.mail.ui.FolderListFragment.java

/**
 * Sets the current account to the one provided here.
 * @param account the current account to set to.
 *//*  w w  w .  j  a  va 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) {
        // We no longer have proper folder objects. Let the new ones come in
        mCursorAdapter.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;
    } 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.chen.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/*from w ww  . j  a  v  a 2  s. c  om*/
 */
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.
    mActionBarView.setFolder(mFolder);

    // 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);
    }
    final Bundle args = new Bundle(2);
    args.putParcelable(BUNDLE_ACCOUNT_KEY, mAccount);
    args.putParcelable(BUNDLE_FOLDER_KEY, mFolder);
    lm.initLoader(LOADER_CONVERSATION_LIST, args, mListCursorCallbacks);
}

From source file:com.android.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/*from   ww w.  j a v a 2 s.  co  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);

    // 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);
    }
    final Bundle args = new Bundle(2);
    args.putParcelable(BUNDLE_ACCOUNT_KEY, mAccount);
    args.putParcelable(BUNDLE_FOLDER_KEY, mFolder);
    args.putBoolean(BUNDLE_IGNORE_INITIAL_CONVERSATION_LIMIT_KEY, mIgnoreInitialConversationLimit);
    mIgnoreInitialConversationLimit = false;
    lm.initLoader(LOADER_CONVERSATION_LIST, args, mListCursorCallbacks);
}

From source file:com.chen.mail.ui.AbstractActivityController.java

/**
 * The mail activity calls other activities for two specific reasons:
 * <ul>/*from  w ww .  j  av  a2  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
        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;
    }
}

From source file:com.android.mail.ui.AbstractActivityController.java

/**
 * The mail activity calls other activities for two specific reasons:
 * <ul>/*from  w  w w .  j  a  v  a2s . c  om*/
 *     <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
        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 (ViewMode.isSearchMode(mViewMode.getMode())) {
            mActivity.setResult(resultCode, data);
            mActivity.finish();
        } else 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;
    case VOICE_SEARCH_REQUEST_CODE:
        if (resultCode == Activity.RESULT_OK) {
            final ArrayList<String> matches = data.getStringArrayListExtra(RecognizerIntent.EXTRA_RESULTS);
            if (!matches.isEmpty()) {
                // not sure how dependable the API is, but it's all we have.
                // take the top choice.
                mSearchViewController.onSearchPerformed(matches.get(0));
            }
        }
        break;
    }
}