/** * re-selects all elements stored in the savedInstanceState * IMPORTANT! Call this method only after all items where added to the adapters again. Otherwise it may select wrong items! * * @param savedInstanceState If the activity is being re-initialized after * previously being shut down then this Bundle contains the data it most * recently supplied in Note: Otherwise it is null. * @return this */ public FastAdapter<Item> withSavedInstanceState(Bundle savedInstanceState) { return withSavedInstanceState(savedInstanceState, ""); }
@Override public void run() { //add some dummy data mItemAdapter.add(ImageDummyData.getSimpleImageItems()); //restore selections (this has to be done after the items were added mFastAdapter.withSavedInstanceState(savedInstanceState); } }, 50);
/** * helper method to reset to the original drawerContent */ public void resetDrawerContent() { if (switchedDrawerContent()) { //set the new items setOnDrawerItemClickListener(originalOnDrawerItemClickListener); setOnDrawerItemLongClickListener(originalOnDrawerItemLongClickListener); setItems(originalDrawerItems, true); getAdapter().withSavedInstanceState(originalDrawerState); //remove the references originalOnDrawerItemClickListener = null; originalOnDrawerItemLongClickListener = null; originalDrawerItems = null; originalDrawerState = null; //if we switch back scroll back to the top mDrawerBuilder.mRecyclerView.smoothScrollToPosition(0); //show the stickyFooter and it's shadow again if (getStickyFooter() != null) { getStickyFooter().setVisibility(View.VISIBLE); } if (getStickyFooterShadow() != null) { getStickyFooterShadow().setVisibility(View.VISIBLE); } //if we currently show the accountHeader selection list make sure to reset this attr if (mDrawerBuilder.mAccountHeader != null && mDrawerBuilder.mAccountHeader.mAccountHeaderBuilder != null) { mDrawerBuilder.mAccountHeader.mAccountHeaderBuilder.mSelectionListShown = false; } } }
if (!mAppended) { mAdapter.deselect(); mAdapter.withSavedInstanceState(mSavedInstance, Drawer.BUNDLE_SELECTION); DrawerUtils.setStickyFooterSelection(this, mSavedInstance.getInt(Drawer.BUNDLE_STICKY_FOOTER_SELECTION, -1), null); } else { mAdapter.deselect(); mAdapter.withSavedInstanceState(mSavedInstance, Drawer.BUNDLE_SELECTION_APPENDED); DrawerUtils.setStickyFooterSelection(this, mSavedInstance.getInt(Drawer.BUNDLE_STICKY_FOOTER_SELECTION_APPENDED, -1), null);
fastAdapter.withSavedInstanceState(savedInstanceState);
fastAdapter.withSavedInstanceState(savedInstanceState);
fastAdapter.withSavedInstanceState(savedInstanceState);
fastAdapter.withSavedInstanceState(savedInstanceState);
fastAdapter.withSavedInstanceState(savedInstanceState);
mFastAdapter.withSavedInstanceState(savedInstanceState);
mFastAdapter.withSavedInstanceState(savedInstanceState);
mFastAdapter.withSavedInstanceState(savedInstanceState);