public void switchCategory(Article.Category category) { PreferencesUtility.saveCategory(getContext(), category); currentState = new State(); recyclerView.scrollToPosition(0); if (category == Article.Category.FAVOURITES) { mListener.removeOffsetListener(); } else { mListener.restoreOffsetListener(); } launchLoader(currentState.currentPage); }
private void loadArticle(long id, int position, String title) { Bundle args = new Bundle(); args.putLong(DatabaseHelper.KEY_ID, id); args.putString(DatabaseHelper.KEY_TITLE, title); args.putInt(POSITION, position); args.putLongArray(IDS_ARRAY, getPosIdArray()); mListener.loadArticle(args); }
@Override public void onViewStateRestored(Bundle savedInstanceState) { Log.d(LOG_TAG, "OnViewStateRestored"); // if (savedInstanceState != null) { // currentState = savedInstanceState.getParcelable(STATE); // launchLoader(currentState.lastPageLoaded); // mLinearLayoutManager.scrollToPosition(currentState.firstVisibleIndex); // //поставить выделение selected на нужной позиции // // if (mListener.isDualPane() && currentState.selectedId > 0) { // Log.d(LOG_TAG, "Loading article"); // loadArticle(currentState.selectedId, currentState.selectedPosition); // } // } else { if (PreferencesUtility.readCategory(getContext()) == Article.Category.FAVOURITES) { mListener.removeOffsetListener(); } launchLoader(1); // } super.onViewStateRestored(savedInstanceState); }