List of usage examples for android.view View saveHierarchyState
public void saveHierarchyState(SparseArray<Parcelable> container)
From source file:com.nightlynexus.viewstatepageradapter.ViewStatePagerAdapter.java
private void putInDetached(int position, View view) { SparseArray<Parcelable> viewState = new SparseArray<>(); view.saveHierarchyState(viewState); detached.put(position, viewState);//from ww w. ja va2 s .com }
From source file:co.lemonlabs.mortar.example.core.util.ScreenConductor.java
/** * Store view hierarchy state into a Screen that will be pushed into * the backstack of Flow//from ww w . jav a 2s . co m */ protected void storeViewState(View view, S screen) { if (screen != null && screen instanceof TransitionScreen) { SparseArray<Parcelable> state = new SparseArray<>(); view.saveHierarchyState(state); ((TransitionScreen) screen).setViewState(state); Timber.i("Storing view state %s", state); } }
From source file:io.github.clendy.leanback.widget.ViewsStateBundle.java
public final Bundle saveOnScreenView(Bundle bundle, View view, int id) { if (mSavePolicy != BaseGridView.SAVE_NO_CHILD) { String key = getSaveStatesKey(id); SparseArray<Parcelable> container = new SparseArray<Parcelable>(); view.saveHierarchyState(container); if (bundle == null) { bundle = new Bundle(); }//from w ww. java 2s . com bundle.putSparseParcelableArray(key, container); } return bundle; }
From source file:android.support.v17.leanback.widget.ViewsStateBundle.java
/** * Save views regardless what's the current policy is. * * @param view view to save// w w w .jav a 2 s. c o m * @param id unique id for the view within this ViewsStateBundle */ protected final void saveViewUnchecked(View view, int id) { if (mChildStates != null) { String key = getSaveStatesKey(id); SparseArray<Parcelable> container = new SparseArray<Parcelable>(); view.saveHierarchyState(container); mChildStates.put(key, container); } }
From source file:android.support.v17.leanback.widget.ViewsStateBundle.java
/** * The on screen view is saved when policy is not {@link #SAVE_NO_CHILD}. * * @param bundle Bundle where we save the on screen view state. If null, * a new Bundle is created and returned. * @param view The view to save.//from www . j ava 2 s .c o m * @param id Id of the view. */ public final Bundle saveOnScreenView(Bundle bundle, View view, int id) { if (mSavePolicy != SAVE_NO_CHILD) { String key = getSaveStatesKey(id); SparseArray<Parcelable> container = new SparseArray<Parcelable>(); view.saveHierarchyState(container); if (bundle == null) { bundle = new Bundle(); } bundle.putSparseParcelableArray(key, container); } return bundle; }
From source file:com.actionbarsherlock.internal.view.menu.MenuBuilder.java
public void saveActionViewStates(Bundle outStates) { SparseArray<Parcelable> viewStates = null; final int itemCount = size(); for (int i = 0; i < itemCount; i++) { final MenuItem item = getItem(i); final View v = item.getActionView(); if (v != null && v.getId() != View.NO_ID) { if (viewStates == null) { viewStates = new SparseArray<Parcelable>(); }/*w ww .ja v a 2 s .com*/ v.saveHierarchyState(viewStates); } if (item.hasSubMenu()) { final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); subMenu.saveActionViewStates(outStates); } } if (viewStates != null) { outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates); } }
From source file:android.support.v7.internal.view.menu.MenuBuilder.java
public void saveActionViewStates(Bundle outStates) { SparseArray<Parcelable> viewStates = null; final int itemCount = size(); for (int i = 0; i < itemCount; i++) { final MenuItem item = getItem(i); final View v = MenuItemCompat.getActionView(item); if (v != null && v.getId() != View.NO_ID) { if (viewStates == null) { viewStates = new SparseArray<Parcelable>(); }//from w w w.j a v a 2s . com v.saveHierarchyState(viewStates); if (MenuItemCompat.isActionViewExpanded(item)) { outStates.putInt(EXPANDED_ACTION_VIEW_ID, item.getItemId()); } } if (item.hasSubMenu()) { final SubMenuBuilder subMenu = (SubMenuBuilder) item.getSubMenu(); subMenu.saveActionViewStates(outStates); } } if (viewStates != null) { outStates.putSparseParcelableArray(getActionViewStatesKey(), viewStates); } }