Source:
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_select_all: { getListOfFilesFragment().selectAll(); } case R.id.action_sync_account: { startSynchronization(); break; } case android.R.id.home: { FileFragment second = getSecondFragment(); OCFile currentDir = getCurrentDir(); boolean inRootFolder = currentDir != null && currentDir.getParentId() == 0; boolean fileFragmentVisible = second != null && second.getFile() != null; if (!inRootFolder || (fileFragmentVisible)) { onBackPressed(); } else if (isDrawerOpen()) { closeDrawer(); } else { openDrawer(); } break; } case R.id.action_sort_descending: { item.setChecked(!item.isChecked()); final boolean sortAscending = !item.isChecked(); PreferenceManager.setSortAscending(sortAscending, this); switch (getSortOrder(this)) { case FileStorageUtils.SORT_NAME: sortByName(sortAscending); break; case FileStorageUtils.SORT_DATE: sortByDate(sortAscending); break; case FileStorageUtils.SORT_SIZE: sortBySize(sortAscending); } break; } case R.id.action_switch_view: { if (isGridView()) { item.setTitle(getString(R.string.action_switch_grid_view)); item.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_view_module)); getListOfFilesFragment().setListAsPreferred(); } else { item.setTitle(getApplicationContext().getString(R.string.action_switch_list_view)); item.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_view_list)); getListOfFilesFragment().setGridAsPreferred(); } return true; } case R.id.action_sort_by_date: item.setChecked(true); sortByDate(PreferenceManager.getSortAscending(this)); return true; case R.id.action_sort_by_name: item.setChecked(true); sortByName(PreferenceManager.getSortAscending(this)); return true; case R.id.action_sort_by_size: item.setChecked(true); sortBySize(PreferenceManager.getSortAscending(this)); return true; default: } return super.onOptionsItemSelected(item); }

Target:
public boolean onOptionsItemSelected(MenuItem item) { switch (item.getItemId()) { case R.id.action_select_all: { getListOfFilesFragment().selectAll(); break; } case R.id.action_sync_account: { startSynchronization(); break; } case android.R.id.home: { FileFragment second = getSecondFragment(); OCFile currentDir = getCurrentDir(); boolean inRootFolder = currentDir != null && currentDir.getParentId() == 0; boolean fileFragmentVisible = second != null && second.getFile() != null; if (!inRootFolder || (fileFragmentVisible)) { onBackPressed(); } else if (isDrawerOpen()) { closeDrawer(); } else { openDrawer(); } break; } case R.id.action_sort_descending: { item.setChecked(!item.isChecked()); final boolean sortAscending = !item.isChecked(); PreferenceManager.setSortAscending(sortAscending, this); switch (getSortOrder(this)) { case FileStorageUtils.SORT_NAME: sortByName(sortAscending); break; case FileStorageUtils.SORT_DATE: sortByDate(sortAscending); break; case FileStorageUtils.SORT_SIZE: sortBySize(sortAscending); } break; } case R.id.action_switch_view: { if (isGridView()) { item.setTitle(getString(R.string.action_switch_grid_view)); item.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_view_module)); getListOfFilesFragment().setListAsPreferred(); } else { item.setTitle(getApplicationContext().getString(R.string.action_switch_list_view)); item.setIcon(ContextCompat.getDrawable(getApplicationContext(), R.drawable.ic_view_list)); getListOfFilesFragment().setGridAsPreferred(); } return true; } case R.id.action_sort_by_date: item.setChecked(true); sortByDate(PreferenceManager.getSortAscending(this)); return true; case R.id.action_sort_by_name: item.setChecked(true); sortByName(PreferenceManager.getSortAscending(this)); return true; case R.id.action_sort_by_size: item.setChecked(true); sortBySize(PreferenceManager.getSortAscending(this)); return true; default: } return super.onOptionsItemSelected(item); }