Java Code Examples for android.support.v4.app.fragment#SavedState
The following examples show how to use
android.support.v4.app.fragment#SavedState .
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: FolioActivity.java From ankihelper with GNU General Public License v3.0 | 6 votes |
private void resetSearchResults() { Log.v(LOG_TAG, "-> resetSearchResults"); ArrayList<Fragment> fragments = mFolioPageFragmentAdapter.getFragments(); for (int i = 0; i < fragments.size(); i++) { FolioPageFragment folioPageFragment = (FolioPageFragment) fragments.get(i); if (folioPageFragment != null) { folioPageFragment.resetSearchResults(); } } ArrayList<Fragment.SavedState> savedStateList = mFolioPageFragmentAdapter.getSavedStateList(); if (savedStateList != null) { for (int i = 0; i < savedStateList.size(); i++) { Fragment.SavedState savedState = savedStateList.get(i); Bundle bundle = FolioPageFragmentAdapter.getBundleFromSavedState(savedState); if (bundle != null) bundle.putParcelable(FolioPageFragment.BUNDLE_SEARCH_ITEM, null); } } }
Example 2
Source File: CustomFragmentStatePagerAdapter.java From Orin with GNU General Public License v3.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; } } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment); if (mSavedState.size() > position) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment); return fragment; }
Example 3
Source File: CustomFragmentStatePagerAdapter.java From RetroMusicPlayer with GNU General Public License v3.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; } } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment); if (mSavedState.size() > position) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment); return fragment; }
Example 4
Source File: FolioPageFragmentAdapter.java From ankihelper with GNU General Public License v3.0 | 5 votes |
public ArrayList<Fragment.SavedState> getSavedStateList() { if (savedStateList == null) { try { Field field = FragmentStatePagerAdapter.class.getDeclaredField("mSavedState"); field.setAccessible(true); savedStateList = (ArrayList<Fragment.SavedState>) field.get(this); } catch (Exception e) { Log.e(LOG_TAG, "-> ", e); } } return savedStateList; }
Example 5
Source File: UpdatableFragmentPagerAdapter.java From UpdatableFragmentStatePagerAdapter with Apache License 2.0 | 5 votes |
@Override @NonNull public Object instantiateItem(ViewGroup container, int position) { long tag = getItemId(position); Fragment fragment = mFragments.get(tag); // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (fragment != null) { return fragment; } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } fragment = getItem(position); // restore state final Fragment.SavedState savedState = mSavedStates.get(tag); if (savedState != null) { fragment.setInitialSavedState(savedState); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.put(tag, fragment); mCurTransaction.add(container.getId(), fragment, "f" + tag); return fragment; }
Example 6
Source File: TaggedFragmentStatePagerAdapter.java From yahnac with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; } } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) { Log.v(TAG, "Adding item #" + position + ": f=" + fragment); } if (mSavedState.size() > position) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, getTag(position)); return fragment; }
Example 7
Source File: TaggedFragmentStatePagerAdapter.java From oneHookLibraryAndroid with Apache License 2.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; } } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment); if (mSavedState.size() > position) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment, getTag(position)); return fragment; }
Example 8
Source File: FragmentStatePagerAdapterFix.java From UMS-Interface with GNU General Public License v3.0 | 5 votes |
@SuppressLint("LongLogTag") @Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; } } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment); if (mSavedState.size() > position) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } while (mFragments.size() <= position) { mFragments.add(null); } fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment); return fragment; }
Example 9
Source File: FragmentNoMenuStatePagerAdapter.java From actor-platform with GNU Affero General Public License v3.0 | 5 votes |
@Override public Object instantiateItem(ViewGroup container, int position) { // If we already have this item instantiated, there is nothing // to do. This can happen when we are restoring the entire pager // from its saved state, where the fragment manager has already // taken care of restoring the fragments we previously had instantiated. if (mFragments.size() > position) { Fragment f = mFragments.get(position); if (f != null) { return f; } } if (mCurTransaction == null) { mCurTransaction = mFragmentManager.beginTransaction(); } Fragment fragment = getItem(position); if (DEBUG) Log.v(TAG, "Adding item #" + position + ": f=" + fragment); if (mSavedState.size() > position) { Fragment.SavedState fss = mSavedState.get(position); if (fss != null) { fragment.setInitialSavedState(fss); } } while (mFragments.size() <= position) { mFragments.add(null); } // fragment.setMenuVisibility(false); fragment.setUserVisibleHint(false); mFragments.set(position, fragment); mCurTransaction.add(container.getId(), fragment); return fragment; }
Example 10
Source File: CompositeDialogFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setInitialSavedState(@Nullable Fragment.SavedState state) { delegate.setInitialSavedState(state); }
Example 11
Source File: StateRestoreDemoActivity.java From HelloActivityAndFragment with Apache License 2.0 | 4 votes |
private void saveFragmentState(int index, Fragment fragment) { Fragment.SavedState savedState = getSupportFragmentManager().saveFragmentInstanceState(fragment); savedStateSparseArray.put(index, savedState); }
Example 12
Source File: CompositeDialogFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void super_setInitialSavedState(@Nullable Fragment.SavedState state) { super.setInitialSavedState(state); }
Example 13
Source File: CompositeFragment.java From CompositeAndroid with Apache License 2.0 | 4 votes |
@Override public void setInitialSavedState(@Nullable Fragment.SavedState state) { delegate.setInitialSavedState(state); }
Example 14
Source File: DialogFragmentDelegate.java From CompositeAndroid with Apache License 2.0 | 4 votes |
public void setInitialSavedState(@Nullable Fragment.SavedState state) { mFragmentDelegate.setInitialSavedState(state); }
Example 15
Source File: FragmentPlugin.java From CompositeAndroid with Apache License 2.0 | 4 votes |
void setInitialSavedState(final CallVoid1<Fragment.SavedState> superCall, @Nullable Fragment.SavedState state) { synchronized (mSuperListeners) { mSuperListeners.push(superCall); setInitialSavedState(state); } }
Example 16
Source File: FragmentPlugin.java From CompositeAndroid with Apache License 2.0 | 4 votes |
public void setInitialSavedState(@Nullable Fragment.SavedState state) { verifyMethodCalledFromDelegate("setInitialSavedState(Fragment.SavedState)"); ((CallVoid1<Fragment.SavedState>) mSuperListeners.pop()).call(state); }
Example 17
Source File: NestedFragApp.java From blog-nested-fragments-backstack with Apache License 2.0 | 4 votes |
@Override public void onCreate() { savedStateMap = new HashMap<String, Fragment.SavedState>(); super.onCreate(); }
Example 18
Source File: NestedFragApp.java From blog-nested-fragments-backstack with Apache License 2.0 | 4 votes |
public void setFragmentSavedState(String key, Fragment.SavedState state){ savedStateMap.put(key, state); }
Example 19
Source File: FragmentStatePagerAdapter.java From RecyclerViewPager with Apache License 2.0 | 2 votes |
/** * Return the Fragment associated with a specified position. */ public abstract Fragment getItem(int position, Fragment.SavedState savedState);
Example 20
Source File: ICompositeFragment.java From CompositeAndroid with Apache License 2.0 | votes |
void setInitialSavedState(@Nullable Fragment.SavedState state);