Example usage for android.os Bundle getShort

List of usage examples for android.os Bundle getShort

Introduction

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

Prototype

@Override
public short getShort(String key, short 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.

Usage

From source file:info.wncwaterfalls.app.ResultsActivity.java

@Override
protected void onCreate(Bundle savedInstanceState) {
    setTheme(R.style.Theme_AppCompat);/*  w  w w .j a  va  2s .c  o  m*/
    super.onCreate(savedInstanceState);

    // See if Google Play Services - and thus the Map tab - should be available
    SharedPreferences settings = getSharedPreferences(PREFS_NAME, 0);
    boolean userPrefSkipPlayServices = settings.getBoolean(USER_PREF_SKIP_PLAY_SERVICES, false);

    // Restore or ingest our state from the saved state or the intent's extras
    Bundle instanceConfig;

    Intent intent = getIntent();
    instanceConfig = savedInstanceState != null ? savedInstanceState : intent.getExtras();

    Short defaultShort = 0;

    searchTerm = instanceConfig.getString(SearchActivity.EXTRA_SEARCH_TERM);
    searchTrailLength = instanceConfig.getShort(SearchActivity.EXTRA_SEARCH_TRAIL_LENGTH, defaultShort);
    searchTrailDifficulty = instanceConfig.getShort(SearchActivity.EXTRA_SEARCH_TRAIL_DIFFICULTY, defaultShort);
    searchTrailClimb = instanceConfig.getShort(SearchActivity.EXTRA_SEARCH_TRAIL_CLIMB, defaultShort);
    searchLocationDistance = instanceConfig.getShort(SearchActivity.EXTRA_SEARCH_LOCATION_DISTANCE,
            defaultShort);
    searchLocationRelto = instanceConfig.getString(SearchActivity.EXTRA_SEARCH_LOCATION_RELTO);
    searchLocationReltoTxt = instanceConfig.getString(SearchActivity.EXTRA_SEARCH_LOCATION_RELTO_TXT);
    searchOnlyShared = instanceConfig.getBoolean(SearchActivity.EXTRA_ONLY_SHARED, false);

    mSearchMode = instanceConfig.getShort(SearchActivity.EXTRA_SEARCH_MODE, defaultShort);
    if (mSearchMode == SearchActivity.SEARCH_MODE_LOCATION && !userPrefSkipPlayServices) {
        // Create a location client for getting the current location.
        mLocationClient = new LocationClient(this, this, this);

        // Display Map tab
        showListTab = false;
    }

    // Set up tabs
    actionBar = getSupportActionBar();
    actionBar.setNavigationMode(ActionBar.NAVIGATION_MODE_TABS);
    actionBar.setDisplayHomeAsUpEnabled(false);

    ActionBar.Tab tab1 = actionBar.newTab();
    tab1.setText("List");
    tab1.setTabListener(new TabListener<ResultsListFragment>(this, "ResultsList", ResultsListFragment.class));
    actionBar.addTab(tab1, showListTab);

    if (!userPrefSkipPlayServices) {
        ActionBar.Tab tab2 = actionBar.newTab();
        tab2.setText("Map");
        tab2.setTabListener(new TabListener<ResultsMapFragment>(this, "ResultsMap", ResultsMapFragment.class));
        actionBar.addTab(tab2, !showListTab);
    }
}