Source:
<code>public boolean onNavigationItemSelected(MenuItem menuItem) { int itemId = menuItem.getItemId(); if (itemId == R.id.navigation_home) { switchFragment(new HomePagerFragment(), org); getSupportActionBar().setTitle(getString(R.string.app_name)); return true; } else if (itemId == R.id.navigation_gists) { switchFragment(new GistsPagerFragment(), null); <START> getSupportActionBar().setTitle(getString(R.string.gists)); <END> return true; } else if (itemId == R.id.navigation_issue_dashboard) { switchFragment(new IssueDashboardPagerFragment(), null); getSupportActionBar().setTitle(getString(R.string.issue_dashboard)); return true; } else if (itemId == R.id.navigation_bookmarks) { switchFragment(new FilterListFragment(), null); getSupportActionBar().setTitle(getString(R.string.bookmarks)); return true; } else if (itemId == R.id.navigation_log_out) { AccountManager accountManager = getAccountManager(); Account[] allGitHubAccounts = accountManager.getAccountsByType(getString(R.string.account_type)); for (Account account : allGitHubAccounts) { accountManager.removeAccount(account, null, null); } Intent in = new Intent(this, LoginActivity.class); in.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(in); finish(); return false; } else if (menuItemOrganizationMap.containsKey(menuItem)) { switchFragment(new HomePagerFragment(), menuItemOrganizationMap.get(menuItem)); navigationView.getMenu().findItem(R.id.navigation_home).setChecked(true); return false; } else { throw new IllegalStateException("MenuItem " + menuItem + " not known"); } }</code><technical_language>menuItem.getTitle() in order prevent redundancy</technical_language>

Target:
public boolean onNavigationItemSelected(MenuItem menuItem) { int itemId = menuItem.getItemId(); if (itemId == R.id.navigation_home) { switchFragment(new HomePagerFragment(), org); getSupportActionBar().setTitle(getString(R.string.app_name)); return true; } else if (itemId == R.id.navigation_gists) { switchFragment(new GistsPagerFragment(), null); getSupportActionBar().setTitle(menuItem.getTitle()); return true; } else if (itemId == R.id.navigation_issue_dashboard) { switchFragment(new IssueDashboardPagerFragment(), null); getSupportActionBar().setTitle(menuItem.getTitle()); return true; } else if (itemId == R.id.navigation_bookmarks) { switchFragment(new FilterListFragment(), null); getSupportActionBar().setTitle(menuItem.getTitle()); return true; } else if (itemId == R.id.navigation_log_out) { AccountManager accountManager = getAccountManager(); Account[] allGitHubAccounts = accountManager.getAccountsByType(getString(R.string.account_type)); for (Account account : allGitHubAccounts) { accountManager.removeAccount(account, null, null); } Intent in = new Intent(this, LoginActivity.class); in.addFlags(IntentCompat.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(in); finish(); return false; } else if (menuItemOrganizationMap.containsKey(menuItem)) { switchFragment(new HomePagerFragment(), menuItemOrganizationMap.get(menuItem)); navigationView.getMenu().findItem(R.id.navigation_home).setChecked(true); return false; } else { throw new IllegalStateException("MenuItem " + menuItem + " not known"); } }