replace menu switch statements with if/else

Signed-off-by: Andy Scherzinger <info@andy-scherzinger.de>
This commit is contained in:
Andy Scherzinger 2021-05-26 20:59:11 +02:00
parent 3c0ef1d1e0
commit 45a88c0722
No known key found for this signature in database
GPG key ID: 6CADC7E3523C308B
5 changed files with 70 additions and 81 deletions

View file

@ -145,13 +145,11 @@ public abstract class BrowserController extends BaseController implements Listin
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.files_selection_done:
if (item.getItemId() == R.id.files_selection_done) {
onFileSelectionDone();
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
@Override

View file

@ -436,20 +436,18 @@ public class ContactsController extends BaseController implements SearchView.OnQ
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
getRouter().popCurrentController();
return true;
case R.id.contacts_selection_done:
int itemId = item.getItemId();
if (itemId == android.R.id.home) {
return getRouter().popCurrentController();
} else if (itemId == R.id.contacts_selection_done) {
selectionDone();
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
@Override
public void onCreateOptionsMenu(Menu menu, @NonNull MenuInflater inflater) {
public void onCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
super.onCreateOptionsMenu(menu, inflater);
inflater.inflate(R.menu.menu_contacts, menu);
searchItem = menu.findItem(R.id.action_search);

View file

@ -157,8 +157,7 @@ public class ProfileController extends BaseController {
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case R.id.edit:
if (item.getItemId() == R.id.edit) {
if (edit) {
save();
}
@ -217,10 +216,8 @@ public class ProfileController extends BaseController {
adapter.notifyDataSetChanged();
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
@Override

View file

@ -116,12 +116,10 @@ public class RingtoneSelectionController extends BaseController implements Flexi
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (item.getItemId() == android.R.id.home) {
return getRouter().popCurrentController();
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
private void prepareViews() {

View file

@ -84,13 +84,11 @@ public abstract class BaseController extends ButterKnifeController {
@Override
public boolean onOptionsItemSelected(@NonNull MenuItem item) {
switch (item.getItemId()) {
case android.R.id.home:
if (item.getItemId() == android.R.id.home) {
getRouter().popCurrentController();
return true;
default:
return super.onOptionsItemSelected(item);
}
return super.onOptionsItemSelected(item);
}
private void cleanTempCertPreference() {