예제 #1
0
  @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());
  }
예제 #2
0
 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;
 }
예제 #3
0
 @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;
 }