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>(); } v.saveHierarchyState(viewStates); if (item.isActionViewExpanded()) { 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); } }
private Parcelable onSaveInstanceState() { SparseArray<Parcelable> state = new SparseArray<>(); itemView.saveHierarchyState(state); Bundle bundle = new Bundle(); bundle.putSparseParcelableArray(STATE, state); return bundle; }
public Notification build() { SparseArray localSparseArray = NotificationCompatJellybean.buildActionExtrasMap(c); if (localSparseArray != null) { b.putSparseParcelableArray("android.support.actionExtras", localSparseArray); } a.setExtras(b); return a.build(); }
/* (non-Javadoc) * @see android.os.Parcelable#writeToParcel(android.os.Parcel, int) */ @Override public void writeToParcel(final Parcel parcel, final int arg1) { final Bundle b = new Bundle(); b.putString(LOCAL_NAME_COMPLETE, mLocalNameComplete); b.putString(LOCAL_NAME_SHORT, mLocalNameShort); b.putSparseParcelableArray(RECORDS_ARRAY, mAdRecords); parcel.writeBundle(b); }
@Override public Parcelable saveState() { Bundle bundle = new Bundle(); for (ViewHolder viewHolder : getAttachedViewHolders()) { mSavedStates.put(getItemId(viewHolder.mPosition), viewHolder.onSaveInstanceState()); } bundle.putSparseParcelableArray(STATE, mSavedStates); return bundle; }
/** * 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. * @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; }
/** @return the saved views states */ public final Bundle saveAsBundle() { if (mChildStates == null || mChildStates.size() == 0) { return null; } Map<String, SparseArray<Parcelable>> snapshot = mChildStates.snapshot(); Bundle bundle = new Bundle(); for (Iterator<Entry<String, SparseArray<Parcelable>>> i = snapshot.entrySet().iterator(); i.hasNext(); ) { Entry<String, SparseArray<Parcelable>> e = i.next(); bundle.putSparseParcelableArray(e.getKey(), e.getValue()); } return bundle; }
private void dispatchSaveInstanceState(Bundle outState) { if (mPresenters.isEmpty()) return; SparseArray<Parcelable> presenterStates = new SparseArray<Parcelable>(); for (WeakReference<MenuPresenter> ref : mPresenters) { final MenuPresenter presenter = ref.get(); if (presenter == null) { mPresenters.remove(ref); } else { final int id = presenter.getId(); if (id > 0) { final Parcelable state = presenter.onSaveInstanceState(); if (state != null) { presenterStates.put(id, state); } } } } outState.putSparseParcelableArray(PRESENTER_KEY, presenterStates); }