Source:
protected void setupDrawerContent(NavigationView navigationView) { if (!getResources().getBoolean(R.bool.help_enabled)) { navigationView.getMenu().removeItem(R.id.drawer_menu_help); } if (!getResources().getBoolean(R.bool.feedback_enabled)) { navigationView.getMenu().removeItem(R.id.drawer_menu_feedback); } navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { mDrawerLayout.closeDrawers(); switch (menuItem.getItemId()) { case R.id.nav_all_files: menuItem.setChecked(true); mCheckedMenuItem = menuItem.getItemId(); allFilesOption(); break; case R.id.nav_uploads: Intent uploadListIntent = new Intent(getApplicationContext(), UploadListActivity.class); uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(uploadListIntent); break; case R.id.nav_only_available_offline: ; menuItem.setChecked(true); mCheckedMenuItem = menuItem.getItemId(); onlyAvailableOfflineOption(); break; case R.id.nav_settings: Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class); startActivity(settingsIntent); break; case R.id.drawer_menu_account_add: createAccount(false); break; case R.id.drawer_menu_account_manage: Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class); startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS); break; case R.id.drawer_menu_feedback: openFeedback(); break; case R.id.drawer_menu_help: openHelp(); break; case Menu.NONE: accountClicked(menuItem.getTitle().toString()); default: Log_OC.i(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle()); } return true; } }); if (mIsAccountChooserActive) { navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, true); } else { navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, false); } }

Target:
protected void setupDrawerContent(NavigationView navigationView) { if (!getResources().getBoolean(R.bool.help_enabled)) { navigationView.getMenu().removeItem(R.id.drawer_menu_help); } if (!getResources().getBoolean(R.bool.feedback_enabled)) { navigationView.getMenu().removeItem(R.id.drawer_menu_feedback); } navigationView.setNavigationItemSelectedListener( new NavigationView.OnNavigationItemSelectedListener() { @Override public boolean onNavigationItemSelected(MenuItem menuItem) { mDrawerLayout.closeDrawers(); switch (menuItem.getItemId()) { case R.id.nav_all_files: menuItem.setChecked(true); mCheckedMenuItem = menuItem.getItemId(); allFilesOption(); break; case R.id.nav_uploads: Intent uploadListIntent = new Intent(getApplicationContext(), UploadListActivity.class); uploadListIntent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TOP); startActivity(uploadListIntent); break; case R.id.nav_only_available_offline: menuItem.setChecked(true); mCheckedMenuItem = menuItem.getItemId(); onlyAvailableOfflineOption(); break; case R.id.nav_settings: Intent settingsIntent = new Intent(getApplicationContext(), Preferences.class); startActivity(settingsIntent); break; case R.id.drawer_menu_account_add: createAccount(false); break; case R.id.drawer_menu_account_manage: Intent manageAccountsIntent = new Intent(getApplicationContext(), ManageAccountsActivity.class); startActivityForResult(manageAccountsIntent, ACTION_MANAGE_ACCOUNTS); break; case R.id.drawer_menu_feedback: openFeedback(); break; case R.id.drawer_menu_help: openHelp(); break; case Menu.NONE: accountClicked(menuItem.getTitle().toString()); default: Log_OC.i(TAG, "Unknown drawer menu item clicked: " + menuItem.getTitle()); } return true; } }); if (mIsAccountChooserActive) { navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, true); } else { navigationView.getMenu().setGroupVisible(R.id.drawer_menu_accounts, false); } }