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
public CharSequence getCharSequence(@Nullable String key, CharSequence defaultValue) 

Source Link

Document

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

Usage

From source file:android.support.v17.leanback.app.GuidedStepTestSupportFragment.java

@Override
public void onCreate(Bundle savedInstanceState) {
    if (savedInstanceState != null) {
        mTestName = savedInstanceState.getCharSequence(KEY_TEST_NAME, null);
    }//from  ww w . j  av  a2s  . com
    mProvider = sTestMap.get(mTestName);
    if (mProvider == null) {
        throw new IllegalArgumentException("you must setupTest()");
    }
    mProvider.mFragment = this;
    super.onCreate(savedInstanceState);
    mProvider.onCreate(savedInstanceState);
}

From source file:com.tomeokin.lspush.ui.widget.dialog.BaseDialogFragment.java

protected Builder applyArgsSetting(Builder builder) {
    Bundle args = getArguments();
    if (args != null) {
        CharSequence field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_TITLE, null);
        if (field != null) {
            builder.setTitle(field);/*  w  w w . j  a  va  2s .c om*/
        }
        field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_MESSAGE, null);
        if (field != null) {
            builder.setTitle(field);
        }

        // it also contain builder setting
        hasCancelListener = args.getBoolean(BaseDialogBuilder.EXTRA_ENABLE_CANCEL_LISTENING, hasCancelListener);
        hasDismissListener = args.getBoolean(BaseDialogBuilder.EXTRA_ENABLE_DISMISS_LISTENING,
                hasDismissListener);
        hasActionClickListener = args.getBoolean(BaseDialogBuilder.EXTRA_ENABLE_ACTION_CLICK_LISTENING,
                hasActionClickListener);

        DialogInterface.OnClickListener listener = hasActionClickListener ? this : null;
        field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_NEUTRAL_TEXT, null);
        if (field != null) {
            builder.addNeutralButton(field, listener);
        }
        field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_NEGATIVE_TEXT, null);
        if (field != null) {
            builder.addNegativeButton(field, listener);
        }
        field = args.getCharSequence(BaseDialogBuilder.EXTRA_DIALOG_POSITIVE_TEXT, null);
        if (field != null) {
            builder.addPositiveButton(field, listener);
        }

        CharSequence[] items = args.getCharSequenceArray(BaseDialogBuilder.EXTRA_DIALOG_LIST_ITEMS);
        if (items != null) {
            builder.setItems(new ArrayAdapter<>(getContext(), android.R.layout.simple_list_item_1, items),
                    this);
        }

        boolean flag = args.getBoolean(BaseDialogBuilder.EXTRA_DIALOG_CANCELABLE, true);
        builder.setCancelable(flag);
        flag = args.getBoolean(BaseDialogBuilder.EXTRA_DIALOG_CANCELED_ON_TOUCH_OUTSIDE, true);
        builder.setCanceledOnTouchOutside(flag);
    }
    return builder;
}

From source file:com.hartcode.hartweather.list.WeatherListActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);

    Model model = new Model();
    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    String temp_unit_string = prefs.getString(getString(R.string.pref_temp_unit_key),
            Unit.Fahrenheit.toString());
    if (temp_unit_string != null) {
        this.units = Unit.valueOf(temp_unit_string);
    }// w ww  . j  av a  2  s  . co m

    this.connectivityManager = (ConnectivityManager) getSystemService(Context.CONNECTIVITY_SERVICE);

    String api_key = getString(R.string.openweathermap_apikey);
    IWeatherAPI weatherapi = new OpenWeatherMapWeatherAPI(api_key, this.units,
            Locale.getDefault().getCountry());

    List<INetworkView> networkViews = new ArrayList<>();
    this.networkDataChangeHandler = new NetworkViewHandler(networkViews, getResources());

    this.networkManager = new NetworkManager(weatherapi, model, this, this);

    setContentView(R.layout.activity_weather_list);
    Toolbar toolbar = (Toolbar) findViewById(R.id.toolbar);
    setSupportActionBar(toolbar);

    this.weatherListActivityFragment = (WeatherListActivityFragment) getSupportFragmentManager()
            .findFragmentById(R.id.fragment);
    this.weatherListActivityFragment.setData(model, networkManager);
    networkViews.add(this.weatherListActivityFragment);

    floatingActionButton = (FloatingActionButton) findViewById(R.id.fab);
    floatingActionButton.setOnClickListener(this);
    if (savedInstanceState != null) {
        this.isSearchShown = savedInstanceState
                .getBoolean(getString(R.string.saved_instance_is_search_shown_key), false);
        this.searchText = savedInstanceState.getCharSequence(getString(R.string.saved_instance_search_text_key),
                getString(R.string.default_saved_instance_search_text));

    }
}