From fc4dd4524a6fbb35d39157bf0b1d12ddf0fa1e07 Mon Sep 17 00:00:00 2001 From: camo0112 <56369484+camo0112@users.noreply.github.com> Date: Mon, 19 Apr 2021 10:52:52 +0530 Subject: [PATCH 1/2] Replaced if/else with switch --- .../org/schabi/newpipe/error/ErrorActivity.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java index 2fcba0e1a..1bcd28d2e 100644 --- a/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java +++ b/app/src/main/java/org/schabi/newpipe/error/ErrorActivity.java @@ -190,15 +190,16 @@ public class ErrorActivity extends AppCompatActivity { @Override public boolean onOptionsItemSelected(final MenuItem item) { - final int id = item.getItemId(); - if (id == android.R.id.home) { - onBackPressed(); - } else if (id == R.id.menu_item_share_error) { - ShareUtils.shareText(this, getString(R.string.error_report_title), buildJson()); - } else { - return false; + switch (item.getItemId()) { + case R.id.home: + onBackPressed(); + return true; + case R.id.menu_item_share_error: + ShareUtils.shareText(this, getString(R.string.error_report_title), buildJson()); + return true; + default: + return false; } - return true; } private void openPrivacyPolicyDialog(final Context context, final String action) { From 57f1152751221ad3e3e0b581efa78e92544568fd Mon Sep 17 00:00:00 2001 From: camo0112 <56369484+camo0112@users.noreply.github.com> Date: Mon, 19 Apr 2021 19:26:15 +0530 Subject: [PATCH 2/2] suppress false warning (which affect only library projects) --- app/build.gradle | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/build.gradle b/app/build.gradle index bbf75063b..759b26d26 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -66,6 +66,9 @@ android { // Or, if you prefer, you can continue to check for errors in release builds, // but continue the build even when errors are found: abortOnError false + // suppress false warning ("Resource IDs will be non-final in Android Gradle Plugin version + // 5.0, avoid using them in switch case statements"), which affects only library projects + disable 'NonConstantResourceId' } compileOptions {