From 5330dda9f8f81644a11e878e310ec5fefacf0eb1 Mon Sep 17 00:00:00 2001 From: Viktor De Pasquale Date: Tue, 16 Apr 2019 19:03:52 +0200 Subject: [PATCH] Removed redundant casts --- .../magisk/model/adapters/PolicyAdapter.java | 19 ++++++++----------- .../magisk/model/adapters/ReposAdapter.java | 8 ++++---- .../com/topjohnwu/magisk/view/SafetyNet.java | 2 +- 3 files changed, 13 insertions(+), 16 deletions(-) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/adapters/PolicyAdapter.java b/app/src/main/java/com/topjohnwu/magisk/model/adapters/PolicyAdapter.java index 6b285dcc7..ef4e0bfec 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/adapters/PolicyAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/model/adapters/PolicyAdapter.java @@ -30,10 +30,10 @@ import butterknife.BindView; public class PolicyAdapter extends RecyclerView.Adapter { - private List policyList; - private MagiskDB dbHelper; - private PackageManager pm; - private boolean[] expandList; + private final List policyList; + private final MagiskDB dbHelper; + private final PackageManager pm; + private final boolean[] expandList; public PolicyAdapter(List list, MagiskDB db, PackageManager pm) { policyList = list; @@ -78,8 +78,7 @@ public class PolicyAdapter extends RecyclerView.Adapter { boolean isChecked = holder.masterSwitch.isChecked(); Runnable r = () -> { - if ((isChecked && policy.policy == Policy.DENY) || - (!isChecked && policy.policy == Policy.ALLOW)) { + if (isChecked ? policy.policy == Policy.DENY : policy.policy == Policy.ALLOW) { policy.policy = isChecked ? Policy.ALLOW : Policy.DENY; String message = v.getContext().getString( isChecked ? R.string.su_snack_grant : R.string.su_snack_deny, policy.appName); @@ -98,8 +97,7 @@ public class PolicyAdapter extends RecyclerView.Adapter { - if ((isChecked && !policy.notification) || - (!isChecked && policy.notification)) { + if (isChecked != policy.notification) { policy.notification = isChecked; String message = v.getContext().getString( isChecked ? R.string.su_snack_notif_on : R.string.su_snack_notif_off, policy.appName); @@ -108,8 +106,7 @@ public class PolicyAdapter extends RecyclerView.Adapter { - if ((isChecked && !policy.logging) || - (!isChecked && policy.logging)) { + if (isChecked != policy.logging) { policy.logging = isChecked; String message = v.getContext().getString( isChecked ? R.string.su_snack_log_on : R.string.su_snack_log_off, policy.appName); @@ -130,7 +127,7 @@ public class PolicyAdapter extends RecyclerView.Adapter l.onClick(null, 0)).show(); } else { - new CustomAlertDialog((Activity) v.getContext()) + new CustomAlertDialog(v.getContext()) .setTitle(R.string.su_revoke_title) .setMessage(v.getContext().getString(R.string.su_revoke_msg, policy.appName)) .setPositiveButton(R.string.yes, l) diff --git a/app/src/main/java/com/topjohnwu/magisk/model/adapters/ReposAdapter.java b/app/src/main/java/com/topjohnwu/magisk/model/adapters/ReposAdapter.java index 162b809fb..8085545d7 100644 --- a/app/src/main/java/com/topjohnwu/magisk/model/adapters/ReposAdapter.java +++ b/app/src/main/java/com/topjohnwu/magisk/model/adapters/ReposAdapter.java @@ -43,8 +43,8 @@ public class ReposAdapter private static final int OTHERS = 2; private Map moduleMap; - private RepoDatabaseHelper repoDB; - private List>> repoPairs; + private final RepoDatabaseHelper repoDB; + private final List>> repoPairs; private List fullList; private SearchView mSearch; @@ -110,10 +110,10 @@ public class ReposAdapter holder.updateTime.setText(context.getString(R.string.updated_on, repo.getLastUpdateString())); holder.infoLayout.setOnClickListener(v -> - MarkDownWindow.show((BaseActivity) context, null, repo.getDetailUrl())); + MarkDownWindow.show(context, null, repo.getDetailUrl())); holder.downloadImage.setOnClickListener(v -> { - new CustomAlertDialog((BaseActivity) context) + new CustomAlertDialog(context) .setTitle(context.getString(R.string.repo_install_title, repo.getName())) .setMessage(context.getString(R.string.repo_install_msg, repo.getDownloadFilename())) .setCancelable(true) diff --git a/app/src/main/java/com/topjohnwu/magisk/view/SafetyNet.java b/app/src/main/java/com/topjohnwu/magisk/view/SafetyNet.java index 67cbc36f4..e6a8615d1 100644 --- a/app/src/main/java/com/topjohnwu/magisk/view/SafetyNet.java +++ b/app/src/main/java/com/topjohnwu/magisk/view/SafetyNet.java @@ -119,7 +119,7 @@ public class SafetyNet implements ISafetyNetHelper.Callback { }; if (!EXT_APK.exists()) { // Show dialog - new CustomAlertDialog((Activity) v.getContext()) + new CustomAlertDialog(v.getContext()) .setTitle(R.string.proprietary_title) .setMessage(R.string.proprietary_notice) .setCancelable(true)