Example usage for android.os Bundle keySet

List of usage examples for android.os Bundle keySet

Introduction

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

Prototype

public Set<String> keySet() 

Source Link

Document

Returns a Set containing the Strings used as keys in this Bundle.

Usage

From source file:com.wareninja.opensource.common.wsrequest.WebServiceNew.java

public String getJsonFromParams2(Bundle params) {

    Map<String, Object> paramsMap = new LinkedHashMap<String, Object>();

    String valStr;/*from  ww w .ja  v  a2  s . c o m*/
    Object valObj;
    for (String key : params.keySet()) {

        valObj = params.get(key);
        if (valObj instanceof String) {

            // ugly check if the string value is JSONObj or JSONArr
            valStr = "" + valObj;
            // if (LOGGING.DEBUG) Log.d(TAG, "valStr->"+valStr);
            valObj = null;
            try {
                valObj = new JSONObject(valStr);

                // note: very ugly hack just for tag loco part!
                if (valStr.contains("{") && valStr.contains("lat") && valStr.contains("lng")) {

                    LinkedHashMap<String, Object> tempMap = new LinkedHashMap<String, Object>();
                    tempMap.put("lng", ((JSONObject) valObj).get("lng"));
                    tempMap.put("lat", ((JSONObject) valObj).get("lat"));
                    JSONObject tempJson = new JSONObject(tempMap);

                    if (LOGGING.DEBUG)
                        Log.d(TAG, "tempJson->" + tempJson + "| len:" + tempJson.length());
                    if (LOGGING.DEBUG)
                        Log.d(TAG, "valObj(before)->" + valObj);

                    if (tempJson.length() > 0) {
                        valObj = tempJson;
                    }

                    if (LOGGING.DEBUG)
                        Log.d(TAG, "valObj(after)->" + valObj);
                }
            } catch (JSONException ex) {
                valObj = null;
            }

            if (valObj == null) {
                try {
                    valObj = new JSONArray(valStr);
                } catch (JSONException ex) {
                    valObj = null;
                }
            }
            if (valObj == null)
                valObj = valStr;
        }

        if (valObj != null)
            paramsMap.put(key, valObj);
    }

    return getJsonFromParams(paramsMap);
}

From source file:de.kuschku.quasseldroid_ng.ui.chat.MainActivity.java

@Subscribe(threadMode = ThreadMode.MAIN, sticky = true)
public void onEventMainThread(CoreSetupRequiredEvent event) {
    if (coreSetupCancelled) {
        finish();/* w ww  . j a  v  a2 s .c o m*/
    } else if (coreSetupResult != null) {
        context.provider().event.removeStickyEvent(CoreSetupRequiredEvent.class);

        Account account = manager.account(context.settings().preferenceLastAccount.get());
        Bundle config = coreSetupResult.getBundle("config");
        Map<String, QVariant> configData = new HashMap<>();
        for (String key : config.keySet()) {
            configData.put(key, new QVariant<>(config.get(key)));
        }
        context.provider().dispatch(new HandshakeFunction(new CoreSetupData(new SetupData(account.user,
                account.pass, coreSetupResult.getString("selectedBackend"), configData))));
    } else {
        Intent intent = new Intent(getApplicationContext(), CoreSetupActivity.class);
        intent.putExtra("storageBackends", context.client().core().getStorageBackendsAsBundle());
        startActivityForResult(intent, REQUEST_CODE_CORESETUP);
    }
}

From source file:ro.tudorluca.gpstracks.android.MainActivity.java

/**
 * Updates fields based on data stored in the bundle.
 *
 * @param savedInstanceState The activity state saved in the Bundle.
 *///from  w ww.  ja  v a 2 s  .c  o m
private void updateValuesFromBundle(Bundle savedInstanceState) {
    Log.i(TAG, "Updating values from bundle");
    if (savedInstanceState != null) {
        // Update the value of mRequestingLocationUpdates from the Bundle, and make sure that
        // the Start Updates and Stop Updates buttons are correctly enabled or disabled.
        if (savedInstanceState.keySet().contains(REQUESTING_LOCATION_UPDATES_KEY)) {
            mRequestingLocationUpdates = savedInstanceState.getBoolean(REQUESTING_LOCATION_UPDATES_KEY);
            setButtonsEnabledState();
        }

        // Update the value of mCurrentLocation from the Bundle and update the UI to show the
        // correct latitude and longitude.
        if (savedInstanceState.keySet().contains(LOCATION_KEY)) {
            // Since LOCATION_KEY was found in the Bundle, we can be sure that mCurrentLocation
            // is not null.
            mCurrentLocation = savedInstanceState.getParcelable(LOCATION_KEY);
        }

        // Update the value of mLastUpdateTime from the Bundle and update the UI.
        if (savedInstanceState.keySet().contains(LAST_UPDATED_TIME_STRING_KEY)) {
            mLastUpdateTime = savedInstanceState.getString(LAST_UPDATED_TIME_STRING_KEY);
        }
        updateUI();
    }
}

From source file:com.wareninja.android.opensource.mongolab_sdk.common.WebService.java

public String webGet(String methodName, Bundle params) {
    Map<String, String> reqParams = new HashMap<String, String>();

    // TODO: do checks to avoid fups!
    for (String key : params.keySet()) {
        // reqParams.put(key, params.getString(key));
        reqParams.put(key, params.get(key) + "");
    }/*  w  w  w.jav  a  2s. com*/

    return webGet(methodName, reqParams);
}

From source file:com.wareninja.android.opensource.mongolab_sdk.common.WebService.java

public String webDelete(String methodName, Bundle params) {
    Map<String, String> reqParams = new HashMap<String, String>();

    // TODO: do checks to avoid fups!
    for (String key : params.keySet()) {
        // reqParams.put(key, params.getString(key));
        reqParams.put(key, params.get(key) + "");
    }//from   w  w  w  .  j  a  v a  2s.  c o m

    return webDelete(methodName, reqParams);
}

From source file:com.kakao.auth.authorization.authcode.KakaoWebViewDialog.java

public KakaoWebViewDialog(final Context context, final String url, Bundle extras, final boolean isUsingTimer,
        final OnWebViewCompleteListener listener) {
    super(context, DEFAULT_THEME);
    this.url = url;
    this.isUsingTimer = isUsingTimer;
    this.onCompleteListener = listener;
    this.headers.put(CommonProtocol.KA_HEADER_KEY, SystemInfo.getKAHeader());
    if (extras != null && extras.size() > 0) {
        for (String key : extras.keySet()) {
            headers.put(key, extras.getString(key));
        }//from w ww  . j av  a2  s  .  c  o m
    }
}

From source file:com.gawdl3y.android.tasktimer.adapters.NewFragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);/*from w  w  w . j  a v a  2 s  .  c  o  m*/
        mItemIds = bundle.getIntArray("itemids");
        if (mItemIds == null) {
            mItemIds = new int[] {};
        }
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int i = 0; i < fss.length; i++) {
                mSavedState.add((Fragment.SavedState) fss[i]);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:com.vincestyling.traversaless.FragmentStatePagerAdapter.java

@Override
public void restoreState(Parcelable state, ClassLoader loader) {
    if (state != null) {
        Bundle bundle = (Bundle) state;
        bundle.setClassLoader(loader);/*from  w  ww. j  a  v a  2  s. c  o m*/
        Parcelable[] fss = bundle.getParcelableArray("states");
        mSavedState.clear();
        mFragments.clear();
        if (fss != null) {
            for (int pos = 0; pos < fss.length; pos++) {
                Parcelable fs = fss[pos];
                mSavedState
                        .add(fs != null ? new SavedStateInfo(getItemIdentifier(pos), (Fragment.SavedState) fs)
                                : null);
            }
        }
        Iterable<String> keys = bundle.keySet();
        for (String key : keys) {
            if (key.startsWith("f")) {
                int index = Integer.parseInt(key.substring(1));
                Fragment f = mFragmentManager.getFragment(bundle, key);
                if (f != null) {
                    while (mFragments.size() <= index) {
                        mFragments.add(null);
                    }
                    f.setMenuVisibility(false);
                    mFragments.set(index, f);
                } else {
                    Log.w(TAG, "Bad fragment at key " + key);
                }
            }
        }
    }
}

From source file:tobiass.statedebt.Main.java

protected void onCreate(Bundle savedInstanceState) {
    super.onCreate(savedInstanceState);
    ActionBarSherlock abs = getSherlock();
    abs.setContentView(R.layout.main);/*from  ww  w . j  ava2s  .  com*/

    // Making sure the ActionBar is created before accessing the Spinner
    // navigation-related stuff.
    setTheme(R.style.Theme_Sherlock_Light_DarkActionBar);

    setTitle(null);

    SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(this);
    if (prefs.getInt("version", 3) != 4) {
        deleteFile(LoadCountries.countriesFile);
    }
    prefs.edit().putInt("version", 4).commit();

    // Looking up all Views
    t = (TextView) findViewById(R.id.text);
    stats = (LinearLayout) findViewById(R.id.stats);
    text1 = (TextView) findViewById(R.id.text1);
    text2 = (TextView) findViewById(R.id.text2);
    text3 = (TextView) findViewById(R.id.text3);
    text4 = (TextView) findViewById(R.id.text4);
    text5 = (TextView) findViewById(R.id.text5);
    text6 = (TextView) findViewById(R.id.text6);

    loading = (ViewSwitcher) findViewById(R.id.root);

    adView = (AdView) findViewById(R.id.adview);
    adView.loadAd(adRequest);

    // If 'text1' doesn't exist in the current layout, the device is in
    // portrait mode
    portrait = text1 == null;
    cache = new ArrayList<Country>();

    if (savedInstanceState != null) {
        if (savedInstanceState.containsKey("cache")) {

            // Before the activity is destroyed, the country cache is
            // bundled into savedInstanceState.

            Bundle b = savedInstanceState.getBundle("cache");
            Iterator<String> i = b.keySet().iterator();
            while (i.hasNext()) {
                Country c = new Country(b.getBundle(i.next()));
                cache.add(c);
            }
        }

        // Variable defines which country should get selected as soon as
        // preperation is done.

        isConverted = savedInstanceState.getBoolean("isConverted", false);
        initToCountry = savedInstanceState.getInt("country", -1);
    }

    // Cache is empty? We need to get a list of all countries.
    if (cache.size() == 0) {

        // Run the asynchronous process of getting a list of countries.
        LoadCountries lc = new LoadCountries();
        lc.execute();
    } else {
        // Fill the navigation Spinner with countries
        setupActionbar();
    }
}