List of usage examples for android.os Bundle getParcelableArray
@Nullable
public Parcelable[] getParcelableArray(@Nullable String key)
From source file:com.btmura.android.reddit.app.FragmentStateItemPagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from w w w. java2s .co m*/ mItemIds = bundle.getLongArray("itemIds"); 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:at.jclehner.rxdroid.ui.ScheduleGridFragment.java
private void onRestoreInstanceState(Bundle state) { if (state == null) return;//from w w w . j av a 2s . com for (int i = 0; i != mHolders.length; ++i) { Fraction[] doses = (Fraction[]) state.getParcelableArray("doses_" + i); if (doses != null) { for (int j = 0; j != doses.length; ++j) mHolders[i].doseViews[j].setDose(doses[j]); } } mDayStatus.set(state.getLong("day_status")); }
From source file:com.example.android.apprestrictionschema.AppRestrictionSchemaFragment.java
private void updateItems(Bundle restrictions) { if (!BUNDLE_SUPPORTED) { return;//from w w w . j av a 2 s. c o m } StringBuilder builder = new StringBuilder(); if (restrictions != null) { Parcelable[] parcelables = restrictions.getParcelableArray(KEY_ITEMS); if (parcelables != null && parcelables.length > 0) { Bundle[] items = new Bundle[parcelables.length]; for (int i = 0; i < parcelables.length; i++) { items[i] = (Bundle) parcelables[i]; } boolean first = true; for (Bundle item : items) { if (!item.containsKey(KEY_ITEM_KEY) || !item.containsKey(KEY_ITEM_VALUE)) { continue; } if (first) { first = false; } else { builder.append(", "); } builder.append(item.getString(KEY_ITEM_KEY)); builder.append(":"); builder.append(item.getString(KEY_ITEM_VALUE)); } } else { builder.append(getString(R.string.none)); } } else { builder.append(getString(R.string.none)); } mTextItems.setText(getString(R.string.your_items, builder)); }
From source file:com.example.craiger.nav.FragmentItemIdStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*w ww. jav a 2 s .c o m*/ long[] itemIdsForState = bundle.getLongArray("itemIdsForState"); Parcelable[] fss = bundle.getParcelableArray("states"); mFragmentToItemIdMap.clear(); mItemIdToFragmentMap.clear(); mUnusedRestoredFragments.clear(); mSavedState.clear(); if (fss != null) { for (int i = 0; i < fss.length; i++) { mSavedState.put(itemIdsForState[i], (Fragment.SavedState) fss[i]); } } Iterable<String> keys = bundle.keySet(); for (String key : keys) { if (key.startsWith(KEY_FRAGMENT)) { Long itemId = Long.parseLong(key.substring(KEY_FRAGMENT.length())); Fragment f = mFragmentManager.getFragment(bundle, key); if (f != null) { f.setMenuVisibility(false); mFragmentToItemIdMap.put(f, itemId); mItemIdToFragmentMap.put(itemId, f); } else { Log.w(TAG, "Bad fragment at key " + key); } } } mUnusedRestoredFragments.addAll(mFragmentToItemIdMap.keySet()); } }
From source file:com.github.michalbednarski.intentslab.ActivityMonitorActivity.java
public void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); if (savedInstanceState != null) { final Parcelable[] recordedIntentsRaw = savedInstanceState.getParcelableArray("recordedIntents"); if (recordedIntentsRaw != null) { mRecordedIntents = new Intent[recordedIntentsRaw.length]; System.arraycopy(recordedIntentsRaw, 0, mRecordedIntents, 0, recordedIntentsRaw.length); }//from ww w .ja v a 2 s . co m } else if (sStagingIntents == null) { startRecording(); } if (mRecordedIntents == null && sStagingIntents == null) { finish(); return; } getListView().setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> parent, View view, int position, long id) { Object item = parent.getItemAtPosition(position); if (item instanceof Intent) { startActivity(new Intent(ActivityMonitorActivity.this, IntentEditorActivity.class) .putExtra(IntentEditorActivity.EXTRA_INTENT, (Intent) item)); } } }); chooseAndSetAdapter(); }
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);/* w w w. java2 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.github.paradam.infinitepager.InfiniteFragmentStatePagerAdapter.java
@Override public void restoreState(Parcelable state, ClassLoader loader) { if (state != null) { Bundle bundle = (Bundle) state; bundle.setClassLoader(loader);/*from ww w. j a v 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) { 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:net.mm2d.dmsexplorer.CdsListActivity.java
@Override protected void onRestoreInstanceState(Bundle savedInstanceState) { super.onRestoreInstanceState(savedInstanceState); final History[] histories = (History[]) savedInstanceState.getParcelableArray(KEY_HISTORY); Collections.addAll(mHistories, histories); final History history = mHistories.peekLast(); if (history.getId().equals(mDataHolder.getCurrentContainer())) { prepareViewState();//from ww w. ja v a 2 s. c o m updateListView(mDataHolder.getCurrentList(), true); } else { browse(history.getPosition(), history.getId(), history.getTitle(), false); } mSelectedObject = savedInstanceState.getParcelable(KEY_SELECTED); final int position = savedInstanceState.getInt(KEY_POSITION, -1); mCdsListAdapter.setSelection(position); if (position >= 0) { mRecyclerView.scrollToPosition(position); } if (mTwoPane && mSelectedObject != null) { final Bundle arguments = new Bundle(); arguments.putString(Const.EXTRA_UDN, mServer.getUdn()); arguments.putParcelable(Const.EXTRA_OBJECT, mSelectedObject); mCdsDetailFragment = new CdsDetailFragment(); mCdsDetailFragment.setArguments(arguments); getSupportFragmentManager().beginTransaction().replace(R.id.cds_detail_container, mCdsDetailFragment) .commit(); } }
From source file:io.github.rockerhieu.emojicon.EmojiconGridFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView); Bundle bundle = getArguments(); if (bundle == null) { mEmojiconType = Emojicon.TYPE_UNDEFINED; mEmojicons = People.DATA;/*from w ww .j ava2s. c o m*/ mUseSystemDefault = false; } else { //noinspection WrongConstant mEmojiconType = bundle.getInt(ARG_EMOJICON_TYPE); if (mEmojiconType == Emojicon.TYPE_UNDEFINED) { Parcelable[] parcels = bundle.getParcelableArray(ARG_EMOJICONS); mEmojicons = new Emojicon[parcels.length]; for (int i = 0; i < parcels.length; i++) { mEmojicons[i] = (Emojicon) parcels[i]; } } else { mEmojicons = Emojicon.getEmojicons(mEmojiconType); } mUseSystemDefault = bundle.getBoolean(ARG_USE_SYSTEM_DEFAULTS); } gridView.setAdapter(new EmojiAdapter(view.getContext(), mEmojicons, mUseSystemDefault)); gridView.setOnItemClickListener(this); }
From source file:com.shoutin.emojicons.EmojiconGridFragment.java
@Override public void onViewCreated(View view, Bundle savedInstanceState) { GridView gridView = (GridView) view.findViewById(R.id.Emoji_GridView); Bundle bundle = getArguments(); if (bundle == null) { mEmojiconType = Emojicon.TYPE_UNDEFINED; mEmojicons = People.DATA;/*from w w w . j a v a 2s.co m*/ mUseSystemDefault = false; } else { //noinspection WrongConstant mEmojiconType = bundle.getInt(ARG_EMOJICON_TYPE); if (mEmojiconType == Emojicon.TYPE_UNDEFINED) { Parcelable[] parcels = bundle.getParcelableArray(ARG_EMOJICONS); mEmojicons = new Emojicon[parcels.length]; for (int i = 0; i < parcels.length; i++) { mEmojicons[i] = (Emojicon) parcels[i]; } } else { mEmojicons = Emojicon.getEmojicons(mEmojiconType); } mUseSystemDefault = bundle.getBoolean(ARG_USE_SYSTEM_DEFAULTS); } gridView.setAdapter(new EmojiconAdapter(view.getContext(), mEmojicons, mUseSystemDefault)); gridView.setOnItemClickListener(this); }