Example usage for android.os Bundle putCharSequence

List of usage examples for android.os Bundle putCharSequence

Introduction

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

Prototype

@Override
public void putCharSequence(@Nullable String key, @Nullable CharSequence value) 

Source Link

Document

Inserts a CharSequence value into the mapping of this Bundle, replacing any existing value for the given key.

Usage

From source file:com.sonetel.ui.dialpad.DialerFragment.java

@Override
public void onVisibilityChanged(boolean visible) {
    if (visible && getResources().getBoolean(R.bool.use_dual_panes)) {
        // That's far to be optimal we should consider uncomment tests for reusing fragment
        // if (autoCompleteFragment == null) {
        autoCompleteFragment = new DialerAutocompleteDetailsFragment();

        if (digits != null) {
            Bundle bundle = new Bundle();
            bundle.putCharSequence(DialerAutocompleteDetailsFragment.EXTRA_FILTER_CONSTRAINT,
                    digits.getText().toString());

            autoCompleteFragment.setArguments(bundle);

        }//w w  w . j a v  a 2 s .  c om
        // }
        // if
        // (getFragmentManager().findFragmentByTag(TAG_AUTOCOMPLETE_SIDE_FRAG)
        // != autoCompleteFragment) {
        // Execute a transaction, replacing any existing fragment
        // with this one inside the frame.
        FragmentTransaction ft = getFragmentManager().beginTransaction();
        ft.replace(R.id.details, autoCompleteFragment, TAG_AUTOCOMPLETE_SIDE_FRAG);
        ft.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE);
        ft.commitAllowingStateLoss();

        // }
    }
}

From source file:de.mrapp.android.dialog.decorator.WizardDialogDecorator.java

@Override
public final void onSaveInstanceState(@NonNull final Bundle outState) {
    outState.putInt(TAB_POSITION_EXTRA, getTabPosition().getValue());
    outState.putBoolean(TAB_LAYOUT_ENABLED_EXTRA, isTabLayoutEnabled());
    outState.putBoolean(TAB_LAYOUT_SHOWN_EXTRA, isTabLayoutShown());
    outState.putInt(TAB_INDICATOR_HEIGHT_EXTRA, getTabIndicatorHeight());
    outState.putInt(TAB_INDICATOR_COLOR_EXTRA, getTabIndicatorColor());
    outState.putInt(TAB_TEXT_COLOR_EXTRA, getTabTextColor());
    outState.putInt(TAB_SELECTED_TEXT_COLOR_EXTRA, getTabSelectedTextColor());
    outState.putBoolean(SWIPE_ENABLED_EXTRA, isSwipeEnabled());
    outState.putBoolean(BUTTON_BAR_SHOWN_EXTRA, isButtonBarShown());
    outState.putInt(BUTTON_TEXT_COLOR_EXTRA, getButtonTextColor());
    outState.putBoolean(SHOW_BUTTON_BAR_DIVIDER_EXTRA, isButtonBarDividerShown());
    outState.putInt(BUTTON_BAR_DIVIDER_COLOR_EXTRA, getButtonBarDividerColor());
    outState.putCharSequence(BACK_BUTTON_TEXT_EXTRA, getBackButtonText());
    outState.putCharSequence(NEXT_BUTTON_TEXT_EXTRA, getNextButtonText());
    outState.putCharSequence(FINISH_BUTTON_TEXT_EXTRA, getFinishButtonText());
    outState.putParcelableArrayList(VIEW_PAGER_ITEMS_EXTRA,
            getDialog().getRetainInstance() ? null : viewPagerItems);
}

From source file:com.geecko.QuickLyric.fragment.LyricsViewFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    if (mLyrics != null)
        try {/*  ww w.j a  va2s.c o m*/
            outState.putByteArray("lyrics", mLyrics.toBytes());
        } catch (IOException e) {
            e.printStackTrace();
        }
    View searchView = getActivity().findViewById(R.id.search_view);
    if (searchView instanceof SearchView) {
        outState.putString("searchQuery", ((SearchView) searchView).getQuery().toString());
        outState.putBoolean("searchFocused", searchView.hasFocus());
    }

    outState.putBoolean("refreshFabEnabled", getActivity().findViewById(R.id.refresh_fab).isEnabled());

    EditText editedLyrics = (EditText) getActivity().findViewById(R.id.edit_lyrics);
    if (editedLyrics.getVisibility() == View.VISIBLE) {
        EditText editedTitle = (EditText) getActivity().findViewById(R.id.song);
        EditText editedArtist = (EditText) getActivity().findViewById(R.id.artist);
        outState.putCharSequence("editedLyrics", editedLyrics.getText());
        outState.putCharSequence("editedTitle", editedTitle.getText());
        outState.putCharSequence("editedArtist", editedArtist.getText());
    }
}

From source file:cn.edu.zafu.corepage.base.BaseActivity.java

/**
 * ??/*from w  ww  .  java  2  s . c  o  m*/
 *
 * @param outState Bundle
 */
@Override
protected void onSaveInstanceState(Bundle outState) {
    Field[] fields = this.getClass().getDeclaredFields();
    Field.setAccessible(fields, true);
    Annotation[] ans;
    for (Field f : fields) {
        ans = f.getDeclaredAnnotations();
        for (Annotation an : ans) {
            if (an instanceof SaveWithActivity) {
                try {
                    Object o = f.get(this);
                    if (o == null) {
                        continue;
                    }
                    String fieldName = f.getName();
                    if (o instanceof Integer) {
                        outState.putInt(fieldName, f.getInt(this));
                    } else if (o instanceof String) {
                        outState.putString(fieldName, (String) f.get(this));
                    } else if (o instanceof Long) {
                        outState.putLong(fieldName, f.getLong(this));
                    } else if (o instanceof Short) {
                        outState.putShort(fieldName, f.getShort(this));
                    } else if (o instanceof Boolean) {
                        outState.putBoolean(fieldName, f.getBoolean(this));
                    } else if (o instanceof Byte) {
                        outState.putByte(fieldName, f.getByte(this));
                    } else if (o instanceof Character) {
                        outState.putChar(fieldName, f.getChar(this));
                    } else if (o instanceof CharSequence) {
                        outState.putCharSequence(fieldName, (CharSequence) f.get(this));
                    } else if (o instanceof Float) {
                        outState.putFloat(fieldName, f.getFloat(this));
                    } else if (o instanceof Double) {
                        outState.putDouble(fieldName, f.getDouble(this));
                    } else if (o instanceof String[]) {
                        outState.putStringArray(fieldName, (String[]) f.get(this));
                    } else if (o instanceof Parcelable) {
                        outState.putParcelable(fieldName, (Parcelable) f.get(this));
                    } else if (o instanceof Serializable) {
                        outState.putSerializable(fieldName, (Serializable) f.get(this));
                    } else if (o instanceof Bundle) {
                        outState.putBundle(fieldName, (Bundle) f.get(this));
                    }
                } catch (IllegalArgumentException e) {
                    e.printStackTrace();
                } catch (IllegalAccessException e) {
                    e.printStackTrace();
                }
            }
        }
    }

    super.onSaveInstanceState(outState);
}

From source file:de.mrapp.android.preference.activity.PreferenceActivity.java

@CallSuper
@Override// www.j av  a  2  s.c  om
protected void onSaveInstanceState(final Bundle outState) {
    super.onSaveInstanceState(outState);
    outState.putBundle(CURRENT_BUNDLE_EXTRA, currentBundle);
    outState.putCharSequence(CURRENT_TITLE_EXTRA, currentTitle);
    outState.putCharSequence(CURRENT_SHORT_TITLE_EXTRA, currentShortTitle);
    outState.putParcelable(CURRENT_PREFERENCE_HEADER_EXTRA, currentHeader);
    outState.putParcelableArrayList(PREFERENCE_HEADERS_EXTRA, getListAdapter().getAllItems());

    if (preferenceScreenFragment != null && preferenceScreenFragment.isAdded()) {
        getFragmentManager().putFragment(outState, PREFERENCE_SCREEN_FRAGMENT_EXTRA, preferenceScreenFragment);
    }
}

From source file:com.free.searcher.MainFragment.java

@Override
public void onSaveInstanceState(Bundle outState) {
    super.onSaveInstanceState(outState);
    Log.i("SearcheFragment.onSaveInstanceState();", outState + ", " + actionBar.getTabCount());
    outState.putInt("level selected", actionBar.getSelectedNavigationIndex());
    outState.putStringArray("selectedFiles", selectedFiles);

    outState.putSerializable("files", files);

    outState.putString("currentZipFileName", currentZipFileName);
    if (extractFile != null) {
        extractFile.close();// w w  w.j a  v  a  2  s .c om
    }
    outState.putString("currentSearching", currentSearching);

    outState.putString("load", load);

    Log.d("load", load + " xxx");
    outState.putString("currentUrl", currentUrl);
    //      outState.putString("source", HtmlSourceViewJavaScriptInterface.source);
    outState.putCharSequence("query",
            (mSearchView != null && mSearchView.getQuery() != null) ? mSearchView.getQuery() : "");
    status = statusView.getText();
    outState.putCharSequence("status", status);

    locX = webView.getScrollX();
    outState.putInt("locX", locX);
    locY = webView.getScrollY();
    outState.putInt("locY", locY);

    outState.putString("home", home);

    webView.saveState((webViewBundle = new Bundle()));
    outState.putBundle("webViewBundle", webViewBundle);
    Log.d("frag.onSaveInstanceState();", outState + "");
    /**
     try {
     outState.putString("readTextFiles", Util.listToString(readTextFiles, false, ";;;"));
     outState.putString("initFolderFiles", Util.listToString(initFolderFiles, false, ";;;"));
     } catch (Throwable t) {
     t.printStackTrace();
     }
     **/
}

From source file:com.android.mail.compose.ComposeActivity.java

private void saveState(Bundle state) {
    // We have no accounts so there is nothing to compose, and therefore, nothing to save.
    if (mAccounts == null || mAccounts.length == 0) {
        return;//from   ww w  . ja  v  a 2  s .c  om
    }
    // The framework is happy to save and restore the selection but only if it also saves and
    // restores the contents of the edit text. That's a lot of text to put in a bundle so we do
    // this manually.
    View focus = getCurrentFocus();
    if (focus != null && focus instanceof EditText) {
        EditText focusEditText = (EditText) focus;
        state.putInt(EXTRA_FOCUS_SELECTION_START, focusEditText.getSelectionStart());
        state.putInt(EXTRA_FOCUS_SELECTION_END, focusEditText.getSelectionEnd());
    }

    final List<ReplyFromAccount> replyFromAccounts = mFromSpinner.getReplyFromAccounts();
    final int selectedPos = mFromSpinner.getSelectedItemPosition();
    final ReplyFromAccount selectedReplyFromAccount = (replyFromAccounts != null && replyFromAccounts.size() > 0
            && replyFromAccounts.size() > selectedPos) ? replyFromAccounts.get(selectedPos) : null;
    if (selectedReplyFromAccount != null) {
        state.putString(EXTRA_SELECTED_REPLY_FROM_ACCOUNT, selectedReplyFromAccount.serialize().toString());
        state.putParcelable(Utils.EXTRA_ACCOUNT, selectedReplyFromAccount.account);
    } else {
        state.putParcelable(Utils.EXTRA_ACCOUNT, mAccount);
    }

    if (mDraftId == UIProvider.INVALID_MESSAGE_ID && mRequestId != 0) {
        // We don't have a draft id, and we have a request id,
        // save the request id.
        state.putInt(EXTRA_REQUEST_ID, mRequestId);
    }

    // We want to restore the current mode after a pause
    // or rotation.
    int mode = getMode();
    state.putInt(EXTRA_ACTION, mode);

    final Message message = createMessage(selectedReplyFromAccount, mRefMessage, mode,
            removeComposingSpans(mBodyView.getText()));
    if (mDraft != null) {
        message.id = mDraft.id;
        message.serverId = mDraft.serverId;
        message.uri = mDraft.uri;
    }
    state.putParcelable(EXTRA_MESSAGE, message);

    if (mRefMessage != null) {
        state.putParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE, mRefMessage);
    } else if (message.appendRefMessageContent) {
        // If we have no ref message but should be appending
        // ref message content, we have orphaned quoted text. Save it.
        state.putCharSequence(EXTRA_QUOTED_TEXT, mQuotedTextView.getQuotedTextIfIncluded());
    }
    state.putBoolean(EXTRA_SHOW_CC, mCcBccView.isCcVisible());
    state.putBoolean(EXTRA_SHOW_BCC, mCcBccView.isBccVisible());
    state.putBoolean(EXTRA_RESPONDED_INLINE, mRespondedInline);
    state.putBoolean(EXTRA_SAVE_ENABLED, mSave != null && mSave.isEnabled());
    state.putParcelableArrayList(EXTRA_ATTACHMENT_PREVIEWS, mAttachmentsView.getAttachmentPreviews());

    state.putParcelable(EXTRA_VALUES, mExtraValues);

    state.putBoolean(EXTRA_TEXT_CHANGED, mTextChanged);
    // On configuration changes, we don't actually need to parse the body html ourselves because
    // the framework can correctly restore the body EditText to its exact original state.
    state.putBoolean(EXTRA_SKIP_PARSING_BODY, isChangingConfigurations());
}

From source file:com.tct.mail.compose.ComposeActivity.java

private void saveState(Bundle state) {
    //TS: lin-zhou 2015-9-28 EMAIL BUGFIX_666151 ADD_S
    //Note:When click doSend but not send and turn screen,restore the flag
    doSend = false;//from   ww  w.  j a  va 2s. c o  m
    //TS: lin-zhou 2015-9-28 EMAIL BUGFIX_666151 ADD_E
    // We have no accounts so there is nothing to compose, and therefore, nothing to save.
    if (mAccounts == null || mAccounts.length == 0) {
        return;
    }
    // The framework is happy to save and restore the selection but only if it also saves and
    // restores the contents of the edit text. That's a lot of text to put in a bundle so we do
    // this manually.
    View focus = getCurrentFocus();
    if (focus != null && focus instanceof EditText) {
        EditText focusEditText = (EditText) focus;
        state.putInt(EXTRA_FOCUS_SELECTION_START, focusEditText.getSelectionStart());
        state.putInt(EXTRA_FOCUS_SELECTION_END, focusEditText.getSelectionEnd());
    }

    final List<ReplyFromAccount> replyFromAccounts = mFromSpinner.getReplyFromAccounts();
    final int selectedPos = mFromSpinner.getSelectedItemPosition();
    final ReplyFromAccount selectedReplyFromAccount = (replyFromAccounts != null && replyFromAccounts.size() > 0
            && replyFromAccounts.size() > selectedPos) ? replyFromAccounts.get(selectedPos) : null;
    if (selectedReplyFromAccount != null) {
        state.putString(EXTRA_SELECTED_REPLY_FROM_ACCOUNT, selectedReplyFromAccount.serialize().toString());
        state.putParcelable(Utils.EXTRA_ACCOUNT, selectedReplyFromAccount.account);
    } else {
        state.putParcelable(Utils.EXTRA_ACCOUNT, mAccount);
    }

    if (mDraftId == UIProvider.INVALID_MESSAGE_ID && mRequestId != 0) {
        // We don't have a draft id, and we have a request id,
        // save the request id.
        state.putInt(EXTRA_REQUEST_ID, mRequestId);
    }

    // We want to restore the current mode after a pause
    // or rotation.
    int mode = getMode();
    state.putInt(EXTRA_ACTION, mode);

    final Message message = createMessage(selectedReplyFromAccount, mRefMessage, mode,
            removeComposingSpans(mBodyView.getText()));
    if (mDraft != null) {
        message.id = mDraft.id;
        message.serverId = mDraft.serverId;
        message.uri = mDraft.uri;
    }
    state.putParcelable(EXTRA_MESSAGE, message);

    if (mRefMessage != null) {
        state.putParcelable(EXTRA_IN_REFERENCE_TO_MESSAGE, mRefMessage);
    } else if (message.appendRefMessageContent) {
        // If we have no ref message but should be appending
        // ref message content, we have orphaned quoted text. Save it.
        state.putCharSequence(EXTRA_QUOTED_TEXT, mQuotedTextView.getQuotedTextIfIncluded());
    }
    state.putBoolean(EXTRA_SHOW_CC, mCcBccView.isCcVisible());
    state.putBoolean(EXTRA_SHOW_BCC, mCcBccView.isBccVisible());
    state.putBoolean(EXTRA_RESPONDED_INLINE, mRespondedInline);
    state.putBoolean(EXTRA_SAVE_ENABLED, mSave != null && mSave.isEnabled());
    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_S
    //        state.putParcelableArrayList(
    //                EXTRA_ATTACHMENT_PREVIEWS, mAttachmentsView.getAttachmentPreviews());
    //TS: Gantao 2015-08-27 EMAIL FEATURE_ID DEL_E

    state.putParcelable(EXTRA_VALUES, mExtraValues);
}