Beispiel #1
0
  @Override
  public boolean onNavigationItemSelected(MenuItem item) {
    binding.drawer.closeDrawer(GravityCompat.START);

    Page page = Page.forMenuId(item);
    toggleToolbarElevation(page.shouldToggleToolbar());
    changePage(page.getTitleResId(), page.createFragment());

    return true;
  }
Beispiel #2
0
 @Override
 public void onBackStackChanged() {
   FragmentManager fm = getSupportFragmentManager();
   Fragment current = fm.findFragmentById(R.id.content_view);
   if (current == null) {
     // no more fragments in the stack. finish.
     finish();
     return;
   }
   Page page = Page.forName(current);
   binding.navView.setCheckedItem(page.getMenuId());
   binding.toolbar.setTitle(page.getTitleResId());
   toggleToolbarElevation(page.shouldToggleToolbar());
   if (current instanceof StackedPageListener) {
     StackedPageListener l = (StackedPageListener) current;
     l.onTop();
   }
 }