List of usage examples for android.os Bundle keySet
public Set<String> keySet()
From source file:com.github.paradam.infinitepager.InfiniteFragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/* w w w .j a va2s.c o m*/ Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); if (fss != null) { for (Parcelable ss : fss) { mSavedState.add((Fragment.SavedState) ss); } } int currentPrimaryItem = bundle.getInt("currentPrimaryItem"); Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = null; try { f = mFragmentManager.getFragment(bundle, key); } catch (Exception e) { e.printStackTrace(); } if (f != null) { while (mFragments.size() <= index) { mFragments.add(null); } FragmentCompat.setMenuVisibility(f, index == currentPrimaryItem); FragmentCompat.setUserVisibleHint(f, index == currentPrimaryItem); mFragments.set(index, f); } else { Log.w(TAG, "Bad fragment at key " + key); } } } } }
From source file:com.kevinread.sortablefragmentpager.SortableFragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from ww w . ja v a2 s . c om*/ mItemIds = bundle.getLongArray("itemids"); if (mItemIds == null) { mItemIds = new long[] {}; } 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); } } } checkForIdChanges(); } }
From source file:br.fapema.morholt.android.wizardpager.wizard.basic.FixedFragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/* ww w . jav a2 s .c o m*/ Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); ArrayList<String> tags = bundle.getStringArrayList("tags"); if (tags != null) { mSavedFragmentTags = tags; } else { mSavedFragmentTags.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.webalcove.travelbook.FixedFragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from w ww .jav a 2s.c om*/ Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); ArrayList<String> tags = bundle.getStringArrayList("tags"); if (tags != null) { mSavedFragmentTags = tags; } else { mSavedFragmentTags.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.wareninja.android.opensource.mongolab_sdk.common.WebService.java
public String getJsonFromParams(Bundle params) {// this has some fup on // TagLoco action, couldnt // find what!!! Map<String, Object> paramsMap = new LinkedHashMap<String, Object>(); String valStr;/*w ww.ja va 2s . 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; valObj = null; try { valObj = new JSONObject(valStr); } 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:com.google.android.gms.location.sample.locationupdates.MainActivity.java
/** * Updates fields based on data stored in the bundle. * * @param savedInstanceState The activity state saved in the Bundle. *///from w ww .j a 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.github.paradam.support.v4.infinitepager.InfiniteFragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);// w w w . jav a2 s . c o m Parcelable[] fss = bundle.getParcelableArray("states"); mSavedState.clear(); mFragments.clear(); if (fss != null) { for (Parcelable ss : fss) { mSavedState.add((Fragment.SavedState) ss); } } int currentPrimaryItem = bundle.getInt("currentPrimaryItem"); Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith("f")) { int index = Integer.parseInt(key.substring(1)); Fragment f = null; try { f = mFragmentManager.getFragment(bundle, key); } catch (Exception e) { Log.e(TAG, e.getMessage(), e); } if (f != null) { while (mFragments.size() <= index) { mFragments.add(null); } f.setMenuVisibility(currentPrimaryItem == index); f.setUserVisibleHint(currentPrimaryItem == index); mFragments.set(index, f); } else { Log.w(TAG, "Bad fragment at key " + key); } } } } }
From source file:com.googlemapapp.MainActivity.java
/** * Updates fields based on data stored in the bundle. * * @param savedInstanceState The activity state saved in the Bundle. *//*from w w w. ja v a 2 s. co 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.facebook.share.ShareApi.java
private void stageOpenGraphAction(final Bundle parameters, final CollectionMapper.OnMapperCompleteListener onOpenGraphActionStagedListener) { final CollectionMapper.Collection<String> collection = new CollectionMapper.Collection<String>() { @Override//from ww w . ja va2s . c o m public Iterator<String> keyIterator() { return parameters.keySet().iterator(); } @Override public Object get(String key) { return parameters.get(key); } @Override public void set(String key, Object value, CollectionMapper.OnErrorListener onErrorListener) { if (!Utility.putJSONValueInBundle(parameters, key, value)) { onErrorListener.onError(new FacebookException("Unexpected value: " + value.toString())); } } }; stageCollectionValues(collection, onOpenGraphActionStagedListener); }
From source file:uk.co.ashtonbrsc.intentexplode.Explode.java
private void rememberIntent(Intent original) { this.originalIntent = getUri(original); Intent copy = cloneIntent(this.originalIntent); final Bundle originalExtras = original.getExtras(); if (originalExtras != null) { // bugfix #14: collect extras that are lost in the intent <-> string conversion Bundle additionalExtrasBundle = new Bundle(originalExtras); for (String key : originalExtras.keySet()) { if (copy.hasExtra(key)) { additionalExtrasBundle.remove(key); }/*ww w.j a va 2s . co m*/ } if (!additionalExtrasBundle.isEmpty()) { additionalExtras = additionalExtrasBundle; } } }