@Override protected void onSaveInstanceState(Bundle outState) { super.onSaveInstanceState(outState); if (mSpinnerAdapter.getCount() > 0) outState.putParcelableArrayList("chapters", mSpinnerAdapter.getAll()); if (mViewPagerAdapter.getSelectedChapter() != null) outState.putParcelable("selected_chapter", mViewPagerAdapter.getSelectedChapter()); }
protected String getTrackedViewName() { if (mViewPager == null || mViewPagerAdapter.getSelectedChapter() == null) return "Main"; final String[] pagesNames = {"News", "Info", "Events"}; String pageName; try { pageName = pagesNames[getCurrentPage()]; } catch (IndexOutOfBoundsException e) { pageName = ""; } return "Main/" + mViewPagerAdapter.getSelectedChapter().getName().replaceAll(" ", "-") + "/" + pageName; }
@Override public boolean onNavigationItemSelected(int position, long l) { Chapter previous = mViewPagerAdapter.getSelectedChapter(); mViewPagerAdapter.setSelectedChapter(mSpinnerAdapter.getItem(position)); if (previous == null || !previous.equals(mSpinnerAdapter.getItem(position))) { Timber.d("Switching chapter!"); mViewPagerAdapter.notifyDataSetChanged(); } return true; }