@Override public void onViewCreated(final View view, @Nullable final Bundle state) { super.onViewCreated(view, state); mRefreshLayout.setOnRefreshListener( new SwipeRefreshLayout.OnRefreshListener() { @Override public void onRefresh() { UIUtils.updateEmptyViewState(getView(), mRecyclerView, mAdapter.isEmpty()); reloadTheFirstPage(); } }); mRecyclerView.setAdapter(mAdapter); if (!mAdapter.isEmpty()) { return; } if (state == null) { loadTheFirstPage(); } else { final List<AugmentedQuote> quotes = state.getParcelableArrayList(SAVED_ADAPTER_STATE); if (Utils.isCollectionEmpty(quotes)) { loadTheFirstPage(); } else { // This should give a non-zero integer mTotalPages = state.getInt(PAGES_SAVED_STATE); mInfiniteScrollListener = new InfiniteRecyclerLoadHelper( mRecyclerView, new InfiniteLoadCallback(), mTotalPages, null); addDataToAdapter(quotes); } } }
public void restoreInstanceState(final Bundle bundle) { if (bundle == null) { return; } final List<Integer> items = bundle.getIntegerArrayList(ACTIVATED_POSITIONS); if (Utils.isCollectionEmpty(items)) { return; } mActivatedPositions.addAll(items); mActionMode = mActivity.startSupportActionMode(this); notifyActivatedItemsChanged(); }