public boolean onSupportNavigateUp() {
    Intent upIntent = getSupportParentActivityIntent();

    if (upIntent != null) {
      if (supportShouldUpRecreateTask(upIntent)) {
        TaskStackBuilder b = TaskStackBuilder.create(this);
        onCreateSupportNavigateUpTaskStack(b);
        onPrepareSupportNavigateUpTaskStack(b);
        b.startActivities();

        try {
          ActivityCompat.finishAffinity(this);
        } catch (IllegalStateException e) {
          // This can only happen on 4.1+, when we don't have a parent or a result set.
          // In that case we should just finish().
          finish();
        }
      } else {
        // This activity is part of the application's task, so simply
        // navigate up to the hierarchical parent activity.
        supportNavigateUpTo(upIntent);
      }
      return true;
    }
    return false;
  }
 public boolean b() {
   Intent localIntent = getSupportParentActivityIntent();
   if (localIntent != null) {
     if (a(localIntent)) {
       TaskStackBuilder localTaskStackBuilder = TaskStackBuilder.create(this);
       a(localTaskStackBuilder);
       b(localTaskStackBuilder);
       localTaskStackBuilder.startActivities();
     }
     for (; ; ) {
       try {
         ActivityCompat.finishAffinity(this);
         return true;
       } catch (IllegalStateException localIllegalStateException) {
         finish();
         continue;
       }
       b(localIntent);
     }
   }
   return false;
 }
Example #3
0
 @Override
 public boolean onNavigationItemSelected(MenuItem item) {
   FragmentTransaction transaction = getSupportFragmentManager().beginTransaction();
   switch (item.getItemId()) {
     case R.id.nav_chapter:
       transaction.detach(forum).detach(game).attach(chapter);
       break;
     case R.id.nav_forum:
       transaction.detach(chapter).detach(game).attach(forum);
       break;
     case R.id.nav_game:
       transaction.detach(forum).detach(chapter).attach(game);
       break;
     case R.id.nav_setting:
       break;
     case R.id.nav_exit:
       ActivityCompat.finishAffinity(this);
       break;
   }
   transaction.commit();
   drawer.closeDrawer(GravityCompat.START);
   return true;
 }