Example usage for android.os Bundle getCharSequence

List of usage examples for android.os Bundle getCharSequence

Introduction

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

Prototype

@Override
@Nullable
public CharSequence getCharSequence(@Nullable String key) 

Source Link

Document

Returns the value associated with the given key, or null if no mapping of the desired type exists for the given key or a null value is explicitly associated with the key.

Usage

From source file:com.osecurityapp.PubSubActivity.java

/**
 * Initializes the Toolbar for use with the activity.
 *//*from www . jav a2 s  .  co m*/
private void setupToolbar(final Bundle savedInstanceState) {
    toolbar = (Toolbar) findViewById(R.id.toolbar);
    // Set up the activity to use this toolbar. As a side effect this sets the Toolbar's title
    // to the activity's title.
    setSupportActionBar(toolbar);

    if (savedInstanceState != null) {
        // Some IDEs such as Android Studio complain about possible NPE without this check.
        assert getSupportActionBar() != null;

        // Restore the Toolbar's title.
        getSupportActionBar().setTitle(savedInstanceState.getCharSequence(BUNDLE_KEY_TOOLBAR_TITLE));
    }
}

From source file:de.geeksfactory.opacclient.frontend.OpacActivity.java

@Override
public void onCreate(Bundle savedInstanceState) {
    supportRequestWindowFeature(android.view.Window.FEATURE_INDETERMINATE_PROGRESS);

    super.onCreate(savedInstanceState);

    setContentView(getContentView());/*www.  ja v a 2  s  .co  m*/
    app = (OpacClient) getApplication();

    aData = new AccountDataSource(this);
    setupDrawer();

    if (savedInstanceState != null) {
        setTwoPane(savedInstanceState.getBoolean("twoPane"));
        if (savedInstanceState.containsKey("title")) {
            setTitle(savedInstanceState.getCharSequence("title"));
        }
        if (savedInstanceState.containsKey("fragment")) {
            fragment = (Fragment) getSupportFragmentManager().getFragment(savedInstanceState, "fragment");
            getSupportFragmentManager().beginTransaction().replace(R.id.content_frame, fragment).commit();
        }
    }
}

From source file:can.yrt.onebusaway.ReportStopProblemFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // Set the stop name.
    Bundle args = getArguments();/*  ww  w .j  a v a  2  s . c o  m*/
    final TextView stopName = (TextView) view.findViewById(R.id.stop_name);
    stopName.setText(MyTextUtils.toTitleCase(args.getString(STOP_NAME)));

    //
    // The code spinner
    //
    mCodeView = (Spinner) view.findViewById(R.id.report_problem_code);
    ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.report_stop_problem_code,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mCodeView.setAdapter(adapter);

    // Comment
    mUserComment = (TextView) view.findViewById(R.id.report_problem_comment);

    if (savedInstanceState != null) {
        int position = savedInstanceState.getInt(CODE);
        mCodeView.setSelection(position);

        CharSequence comment = savedInstanceState.getCharSequence(USER_COMMENT);
        mUserComment.setText(comment);
    }
}

From source file:org.onebusaway.android.ui.ReportStopProblemFragment.java

@Override
public void onViewCreated(View view, Bundle savedInstanceState) {
    // Set the stop name.
    Bundle args = getArguments();//from  ww  w  . j  ava 2  s .c  o  m
    final TextView stopName = (TextView) view.findViewById(R.id.stop_name);
    stopName.setText(MyTextUtils.toTitleCase(args.getString(STOP_NAME)));

    //
    // The code spinner
    //
    mCodeView = (Spinner) view.findViewById(R.id.report_problem_code);
    ArrayAdapter<?> adapter = ArrayAdapter.createFromResource(getActivity(), R.array.report_stop_problem_code,
            android.R.layout.simple_spinner_item);
    adapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item);
    mCodeView.setAdapter(adapter);

    // Comment
    mUserComment = (TextView) view.findViewById(R.id.report_problem_comment);

    if (savedInstanceState != null) {
        int position = savedInstanceState.getInt(CODE);
        mCodeView.setSelection(position);

        CharSequence comment = savedInstanceState.getCharSequence(USER_COMMENT);
        mUserComment.setText(comment);
    }

    SPINNER_TO_CODE = new String[] { null, ObaReportProblemWithStopRequest.NAME_WRONG,
            ObaReportProblemWithStopRequest.NUMBER_WRONG, ObaReportProblemWithStopRequest.LOCATION_WRONG,
            ObaReportProblemWithStopRequest.ROUTE_OR_TRIP_MISSING, ObaReportProblemWithStopRequest.OTHER };
}

From source file:de.msal.shoutemo.ui.onlineusers.OnlineUsersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_onlineusers, container, false);

    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.onlineusers_swipe);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.autemo_pink, R.color.autemo_yellow_bright,
            R.color.autemo_green_secondary, R.color.autemo_blue);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override/*from  w  w  w  .j  a va  2  s  .c  o m*/
        public void onRefresh() {
            refreshTriggeredBySwipe = true;
            new GetOnlineUsersTask().execute();
        }
    });

    mAdapter = new OnlineUsersAdapter(getActivity(), new LinkedList<Author>());
    mListView = (ListView) view.findViewById(android.R.id.list);
    mListView.setOnItemClickListener(new OnlineUseresClickListener());

    if (savedInstanceState != null) {
        mTitle = savedInstanceState.getCharSequence(INSTANCESTATE_TITLE);
        mAuthors = savedInstanceState.getParcelableArrayList(INSTANCESTATE_AUTHORS);
        mAdapter.addAll(mAuthors);
        mListView.setAdapter(mAdapter);
    } else {
        new GetOnlineUsersTask().execute();
    }

    mCallback.setTitle(mTitle);
    return view;
}

From source file:org.mariotaku.twidere.activity.ComposeActivity.java

@Override
public void onCreate(final Bundle savedInstanceState) {
    mLocationManager = (LocationManager) getSystemService(Context.LOCATION_SERVICE);
    mPreferences = getSharedPreferences(SHARED_PREFERENCES_NAME, Context.MODE_PRIVATE);
    mTwitterWrapper = getTwidereApplication().getTwitterWrapper();
    mResolver = getContentResolver();//from  w ww .j av  a2s  .c  o m
    super.onCreate(savedInstanceState);
    final long[] account_ids = getAccountIds(this);
    if (account_ids.length <= 0) {
        final Intent intent = new Intent(INTENT_ACTION_TWITTER_LOGIN);
        intent.setClass(this, SignInActivity.class);
        startActivity(intent);
        finish();
        return;
    }
    setContentView(R.layout.compose);
    getSupportActionBar().setDisplayHomeAsUpEnabled(true);

    final Bundle bundle = savedInstanceState != null ? savedInstanceState : getIntent().getExtras();
    final long account_id = bundle != null ? bundle.getLong(INTENT_KEY_ACCOUNT_ID) : -1;
    mAccountIds = bundle != null ? bundle.getLongArray(INTENT_KEY_IDS) : null;
    mInReplyToStatusId = bundle != null ? bundle.getLong(INTENT_KEY_IN_REPLY_TO_ID) : -1;
    mInReplyToScreenName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME) : null;
    mInReplyToName = bundle != null ? bundle.getString(INTENT_KEY_IN_REPLY_TO_NAME) : null;
    mIsImageAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_IMAGE_ATTACHED) : false;
    mIsPhotoAttached = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_PHOTO_ATTACHED) : false;
    mImageUri = bundle != null ? (Uri) bundle.getParcelable(INTENT_KEY_IMAGE_URI) : null;
    final String[] mentions = bundle != null ? bundle.getStringArray(INTENT_KEY_MENTIONS) : null;
    final int notification_id = bundle != null ? bundle.getInt(INTENT_KEY_NOTIFICATION_ID, -1) : -1;
    if (notification_id != -1) {
        mTwitterWrapper.clearNotification(notification_id);
    }
    final String account_screen_name = getAccountScreenName(this, account_id);
    int text_selection_start = -1;
    if (mInReplyToStatusId > 0) {
        if (bundle != null && bundle.getString(INTENT_KEY_TEXT) != null
                && (mentions == null || mentions.length < 1)) {
            mText = bundle.getString(INTENT_KEY_TEXT);
        } else if (mentions != null) {
            final StringBuilder builder = new StringBuilder();
            for (final String mention : mentions) {
                if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_screen_name)) {
                    builder.append('@' + account_screen_name + ' ');
                } else if (!mention.equalsIgnoreCase(account_screen_name)) {
                    builder.append('@' + mention + ' ');
                }
            }
            mText = builder.toString();
            text_selection_start = mText.indexOf(' ') + 1;
        }

        mIsQuote = bundle != null ? bundle.getBoolean(INTENT_KEY_IS_QUOTE, false) : false;

        final boolean display_screen_name = NAME_DISPLAY_OPTION_SCREEN_NAME
                .equals(mPreferences.getString(PREFERENCE_KEY_NAME_DISPLAY_OPTION, NAME_DISPLAY_OPTION_BOTH));
        if (mInReplyToScreenName != null && mInReplyToName != null) {
            setTitle(getString(mIsQuote ? R.string.quote_user : R.string.reply_to,
                    display_screen_name ? mInReplyToScreenName : mInReplyToName));
        }
        if (mAccountIds == null || mAccountIds.length == 0) {
            mAccountIds = new long[] { account_id };
        }
    } else {
        if (mentions != null) {
            final StringBuilder builder = new StringBuilder();
            for (final String mention : mentions) {
                if (mentions.length == 1 && mentions[0].equalsIgnoreCase(account_screen_name)) {
                    builder.append('@' + account_screen_name + ' ');
                } else if (!mention.equalsIgnoreCase(account_screen_name)) {
                    builder.append('@' + mention + ' ');
                }
            }
            mText = builder.toString();
        }
        if (mAccountIds == null || mAccountIds.length == 0) {
            final long[] ids_in_prefs = ArrayUtils
                    .fromString(mPreferences.getString(PREFERENCE_KEY_COMPOSE_ACCOUNTS, null), ',');
            final long[] intersection = ArrayUtils.intersection(ids_in_prefs, account_ids);
            mAccountIds = intersection.length > 0 ? intersection : account_ids;
        }
        final String action = getIntent().getAction();
        if (Intent.ACTION_SEND.equals(action) || Intent.ACTION_SEND_MULTIPLE.equals(action)) {
            setTitle(R.string.share);
            final Bundle extras = getIntent().getExtras();
            if (extras != null) {
                if (mText == null) {
                    final CharSequence extra_subject = extras.getCharSequence(Intent.EXTRA_SUBJECT);
                    final CharSequence extra_text = extras.getCharSequence(Intent.EXTRA_TEXT);
                    mText = getShareStatus(this, parseString(extra_subject), parseString(extra_text));
                } else {
                    mText = bundle.getString(INTENT_KEY_TEXT);
                }
                if (mImageUri == null) {
                    final Uri extra_stream = extras.getParcelable(Intent.EXTRA_STREAM);
                    final String content_type = getIntent().getType();
                    if (extra_stream != null && content_type != null && content_type.startsWith("image/")) {
                        final String real_path = getImagePathFromUri(this, extra_stream);
                        final File file = real_path != null ? new File(real_path) : null;
                        if (file != null && file.exists()) {
                            mImageUri = Uri.fromFile(file);
                            mIsImageAttached = true;
                            mIsPhotoAttached = false;
                        } else {
                            mImageUri = null;
                            mIsImageAttached = false;
                        }
                    }
                }
            }
        } else if (bundle != null) {
            if (bundle.getString(INTENT_KEY_TEXT) != null) {
                mText = bundle.getString(INTENT_KEY_TEXT);
            }
        }
    }

    final File image_file = mImageUri != null && "file".equals(mImageUri.getScheme())
            ? new File(mImageUri.getPath())
            : null;
    final boolean image_file_valid = image_file != null && image_file.exists();
    mImageThumbnailPreview.setVisibility(image_file_valid ? View.VISIBLE : View.GONE);
    if (image_file_valid) {
        reloadAttachedImageThumbnail(image_file);
    }

    mImageThumbnailPreview.setOnClickListener(this);
    mImageThumbnailPreview.setOnLongClickListener(this);
    mMenuBar.setOnMenuItemClickListener(this);
    mMenuBar.inflate(R.menu.menu_compose);
    final Menu menu = mMenuBar.getMenu();
    final MenuItem extensions = menu.findItem(MENU_EXTENSIONS_SUBMENU);
    if (extensions != null) {
        final Intent intent = new Intent(INTENT_ACTION_EXTENSION_COMPOSE);
        final Bundle extras = new Bundle();
        final String screen_name = mAccountIds != null && mAccountIds.length > 0
                ? getAccountScreenName(this, mAccountIds[0])
                : null;
        extras.putString(INTENT_KEY_TEXT, parseString(mEditText.getText()));
        extras.putString(INTENT_KEY_IN_REPLY_TO_SCREEN_NAME, mInReplyToScreenName);
        extras.putString(INTENT_KEY_IN_REPLY_TO_NAME, mInReplyToName);
        extras.putString(INTENT_KEY_SCREEN_NAME, screen_name);
        extras.putLong(INTENT_KEY_IN_REPLY_TO_ID, mInReplyToStatusId);
        intent.putExtras(extras);
        addIntentToSubMenu(this, extensions.getSubMenu(), intent);
    }
    mMenuBar.show();
    if (mPreferences.getBoolean(PREFERENCE_KEY_QUICK_SEND, false)) {
        mEditText.setOnEditorActionListener(this);
    }
    mEditText.addTextChangedListener(this);
    if (mText != null) {
        mEditText.setText(mText);
        if (mIsQuote) {
            mEditText.setSelection(0);
        } else if (text_selection_start != -1 && text_selection_start < mEditText.length()
                && mEditText.length() > 0) {
            mEditText.setSelection(text_selection_start, mEditText.length() - 1);
        } else if (mEditText.length() > 0) {
            mEditText.setSelection(mEditText.length());
        }
    }
    setMenu();
    mColorIndicator.setColors(getAccountColors(this, mAccountIds));
    mContentModified = savedInstanceState != null ? savedInstanceState.getBoolean(INTENT_KEY_CONTENT_MODIFIED)
            : false;
    mIsPossiblySensitive = savedInstanceState != null
            ? savedInstanceState.getBoolean(INTENT_KEY_IS_POSSIBLY_SENSITIVE)
            : false;
}

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

@Override
public final void onRestoreInstanceState(@NonNull final Bundle savedInstanceState) {
    setTitleColor(savedInstanceState.getInt(TITLE_COLOR_EXTRA));
    setMessageColor(savedInstanceState.getInt(MESSAGE_COLOR_EXTRA));
    setTitle(savedInstanceState.getCharSequence(TITLE_EXTRA));
    setMessage(savedInstanceState.getCharSequence(MESSAGE_EXTRA));

    if (savedInstanceState.containsKey(ICON_BITMAP_EXTRA)) {
        setIcon((Bitmap) savedInstanceState.getParcelable(ICON_BITMAP_EXTRA));
    } else if (savedInstanceState.containsKey(ICON_ID_EXTRA)) {
        setIcon(savedInstanceState.getInt(ICON_ID_EXTRA));
    } else if (savedInstanceState.containsKey(ICON_ATTRIBUTE_ID_EXTRA)) {
        setIconAttribute(savedInstanceState.getInt(ICON_ATTRIBUTE_ID_EXTRA));
    }//from   w  w  w  . j  a  v a2s.  c  o m

    if (savedInstanceState.containsKey(BACKGROUND_BITMAP_EXTRA)) {
        setBackground(savedInstanceState.getInt(BACKGROUND_BITMAP_EXTRA));
    } else if (savedInstanceState.containsKey(BACKGROUND_ID_EXTRA)) {
        setBackground(savedInstanceState.getInt(BACKGROUND_ID_EXTRA));
    } else if (savedInstanceState.containsKey(BACKGROUND_COLOR_EXTRA)) {
        setBackgroundColor(savedInstanceState.getInt(BACKGROUND_COLOR_EXTRA));
    }
}

From source file:com.he5ed.lib.cloudprovider.picker.PickerFragment.java

@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container, Bundle savedInstanceState) {
    // Inflate the layout for this fragment
    View rootView = inflater.inflate(R.layout.cp_fragment_picker, container, false);
    mEmptyView = (LinearLayout) rootView.findViewById(android.R.id.empty);
    if (savedInstanceState != null) {
        switch (savedInstanceState.getInt("empty_view_visibility")) {
        case View.VISIBLE:
            mEmptyView.setVisibility(View.VISIBLE);
            ImageView icon = (ImageView) mEmptyView.findViewById(R.id.empty_icon_image_view);
            TextView title = (TextView) mEmptyView.findViewById(R.id.empty_title_text_view);
            TextView detail = (TextView) mEmptyView.findViewById(R.id.empty_detail_text_view);
            Bitmap bitmap = savedInstanceState.getParcelable("icon_drawable");
            icon.setImageBitmap(bitmap);
            title.setText(savedInstanceState.getCharSequence("title_text"));
            detail.setText(savedInstanceState.getCharSequence("detail_text"));
            break;
        case View.INVISIBLE:
            mEmptyView.setVisibility(View.INVISIBLE);
            break;
        case View.GONE:
            mEmptyView.setVisibility(View.GONE);
            break;
        }//from  ww  w .  j a va 2  s  .  c o  m
    }
    RecyclerListView recyclerView = (RecyclerListView) rootView.findViewById(R.id.recyler_view);
    recyclerView.setEmptyView(mEmptyView);
    recyclerView.setLayoutManager(new LinearLayoutManager(getContext()));
    recyclerView.setAdapter(mAdapter);

    return rootView;
}

From source file:de.msal.shoutemo.fragments.OnlineUsersFragment.java

@Override
public View onCreateView(LayoutInflater inflater, @Nullable ViewGroup container,
        @Nullable Bundle savedInstanceState) {
    View view = inflater.inflate(R.layout.fragment_onlineusers, container, false);

    mSwipeRefreshLayout = (SwipeRefreshLayout) view.findViewById(R.id.onlineusers_swipe);
    mSwipeRefreshLayout.setColorSchemeResources(R.color.autemo_pink, R.color.autemo_yellow_bright,
            R.color.autemo_green_secondary, R.color.autemo_blue);
    mSwipeRefreshLayout.setOnRefreshListener(new SwipeRefreshLayout.OnRefreshListener() {
        @Override//from  ww  w .  jav  a 2 s .co m
        public void onRefresh() {
            refreshTriggeredBySwipe = true;
            new GetOnlineUsersTask().execute();
        }
    });

    mAdapter = new OnlineUsersAdapter(getActivity(), new LinkedList<Author>());
    mAdapter.setOnUserClickListener(new OnlineUseresClickListener());
    RecyclerView recyclerView = (RecyclerView) view.findViewById(android.R.id.list);
    recyclerView.setLayoutManager(new LinearLayoutManager(getActivity()));
    recyclerView.setAdapter(mAdapter);

    if (savedInstanceState != null) {
        mTitle = savedInstanceState.getCharSequence(INSTANCESTATE_TITLE);
        mAuthors = savedInstanceState.getParcelableArrayList(INSTANCESTATE_AUTHORS);
        mAdapter.addAll(mAuthors);
    } else {
        new GetOnlineUsersTask().execute();
    }

    getActivity().setTitle(mTitle);
    return view;
}

From source file:jp.co.noxi.app.NXAlertDialog.java

private void setNeutralButton(AlertDialog.Builder builder) {
    final Bundle args = getArguments();
    final CharSequence naturalButtonText = args.getCharSequence(ARG_NEUTRAL_BUTTON);
    if (naturalButtonText == null) {
        return;/*from w w w  . j a  v  a2  s  . com*/
    }
    builder.setNeutralButton(naturalButtonText, new DialogInterface.OnClickListener() {
        @Override
        public void onClick(DialogInterface dialog, int which) {
            final OnClickListener listener = findListenerByTag(OnClickListener.class,
                    ARG_NEUTRAL_BUTTON_LISTENER);
            if (listener != null) {
                listener.onClickNeutral(NXAlertDialog.this);
            }
        }
    });
}