Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Replaced switch with if/else statements for Non-Constant Fields in Ca… #685

Closed
wants to merge 3 commits into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -211,14 +211,11 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
finish();
return true;

default:
return super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() == android.R.id.home) {
finish();
return true;
}
return super.onOptionsItemSelected(menuItem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -245,14 +245,11 @@ protected void onPause() {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;

default:
return super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -248,14 +248,11 @@ public void onRefresh() {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;

default:
return super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}

@Subscribe
Expand Down
34 changes: 15 additions & 19 deletions src/main/java/org/amahi/anywhere/activity/ServerAppActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -175,26 +175,22 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
finish();
return true;

case R.id.menu_back:
if (getWebView().canGoBack()) {
getWebView().goBack();
}
return true;

case R.id.menu_forward:
if (getWebView().canGoForward()) {
getWebView().goForward();
}
return true;

default:
return super.onOptionsItemSelected(menuItem);
int itemId = menuItem.getItemId();
if (itemId == android.R.id.home) {
finish();
return true;
} else if (itemId == R.id.menu_back) {
if (getWebView().canGoBack()) {
getWebView().goBack();
}
return true;
} else if (itemId == R.id.menu_forward) {
if (getWebView().canGoForward()) {
getWebView().goForward();
}
return true;
}
return super.onOptionsItemSelected(menuItem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -618,18 +618,16 @@ public void setUpAudioListIcon(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.menu_audio_list:
toggleAudioList();
toggleAudioListIcon(menuItem);
return true;

default:
return super.onOptionsItemSelected(menuItem);
}
int itemId = menuItem.getItemId();
if (itemId == android.R.id.home) {
finish();
return true;
} else if (itemId == R.id.menu_audio_list) {
toggleAudioList();
toggleAudioListIcon(menuItem);
return true;
}
return super.onOptionsItemSelected(menuItem);
}

private void toggleAudioList() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -298,18 +298,15 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
finish();
return true;

case R.id.menu_share:
prepareDownload();
return true;

default:
return super.onOptionsItemSelected(menuItem);
int itemId = menuItem.getItemId();
if (itemId == android.R.id.home) {
finish();
return true;
} else if (itemId == R.id.menu_share) {
prepareDownload();
return true;
}
return super.onOptionsItemSelected(menuItem);
}

private void startFileSharingActivity() {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -682,18 +682,16 @@ public boolean onCreateOptionsMenu(Menu menu) {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
finish();
return true;
case R.id.menu_subtitle:
menuItem.setChecked(!menuItem.isChecked());
enableSubtitles(menuItem.isChecked());
return true;

default:
return super.onOptionsItemSelected(menuItem);
int itemId = menuItem.getItemId();
if (itemId == android.R.id.home) {
finish();
return true;
} else if (itemId == R.id.menu_subtitle) {
menuItem.setChecked(!menuItem.isChecked());
enableSubtitles(menuItem.isChecked());
return true;
}
return super.onOptionsItemSelected(menuItem);
}

private void enableSubtitles(boolean enable) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -650,14 +650,11 @@ private boolean isConnectionLocal() {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;

default:
return super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}

@Override
Expand Down
11 changes: 4 additions & 7 deletions src/main/java/org/amahi/anywhere/activity/SettingsActivity.java
Original file line number Diff line number Diff line change
Expand Up @@ -82,14 +82,11 @@ private void setUpSettingsFragment() {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case android.R.id.home:
onBackPressed();
return true;

default:
return super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() == android.R.id.home) {
onBackPressed();
return true;
}
return super.onOptionsItemSelected(menuItem);
}

@Subscribe
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -669,14 +669,11 @@ public void onCreateOptionsMenu(Menu menu, MenuInflater menuInflater) {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {
case R.id.menu_settings:
BusProvider.getBus().post(new SettingsSelectedEvent());
return true;

default:
return super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() == R.id.menu_settings) {
BusProvider.getBus().post(new SettingsSelectedEvent());
return true;
}
return super.onOptionsItemSelected(menuItem);
}

@Override
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -748,7 +748,7 @@ private void setUpFilesContentRefreshing() {
SwipeRefreshLayout refreshLayout = getRefreshLayout();

refreshLayout.setProgressBackgroundColorSchemeResource(R.color.accent);
refreshLayout.setColorSchemeResources(
refreshLayout.setColorSchemeResources(
android.R.color.white);

refreshLayout.setOnRefreshListener(this);
Expand Down Expand Up @@ -854,14 +854,11 @@ private void setSearchCursor() {

@Override
public boolean onOptionsItemSelected(MenuItem menuItem) {
switch (menuItem.getItemId()) {

case R.id.menu_sort:
showSortOptions();
return true;
default:
return super.onOptionsItemSelected(menuItem);
if (menuItem.getItemId() == R.id.menu_sort) {
showSortOptions();
return true;
}
return super.onOptionsItemSelected(menuItem);
}

private void showSortOptions() {
Expand Down
Loading