Skip to content

Commit 0039312

Browse files
authored
Merge pull request #6109 from sauravrao637/codeImrovement
Replaced if/else with switch in ErrorActivity, supress false lint warning
2 parents bfb9be1 + 57f1152 commit 0039312

File tree

2 files changed

+12
-8
lines changed

2 files changed

+12
-8
lines changed

app/build.gradle

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,9 @@ android {
6666
// Or, if you prefer, you can continue to check for errors in release builds,
6767
// but continue the build even when errors are found:
6868
abortOnError false
69+
// suppress false warning ("Resource IDs will be non-final in Android Gradle Plugin version
70+
// 5.0, avoid using them in switch case statements"), which affects only library projects
71+
disable 'NonConstantResourceId'
6972
}
7073

7174
compileOptions {

app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -190,15 +190,16 @@ public boolean onCreateOptionsMenu(final Menu menu) {
190190

191191
@Override
192192
public boolean onOptionsItemSelected(final MenuItem item) {
193-
final int id = item.getItemId();
194-
if (id == android.R.id.home) {
195-
onBackPressed();
196-
} else if (id == R.id.menu_item_share_error) {
197-
ShareUtils.shareText(this, getString(R.string.error_report_title), buildJson());
198-
} else {
199-
return false;
193+
switch (item.getItemId()) {
194+
case R.id.home:
195+
onBackPressed();
196+
return true;
197+
case R.id.menu_item_share_error:
198+
ShareUtils.shareText(this, getString(R.string.error_report_title), buildJson());
199+
return true;
200+
default:
201+
return false;
200202
}
201-
return true;
202203
}
203204

204205
private void openPrivacyPolicyDialog(final Context context, final String action) {

0 commit comments

Comments
 (0)