Removed redundant casts

This commit is contained in:
Viktor De Pasquale 2019-04-16 19:03:52 +02:00
parent ebab126579
commit 5330dda9f8
3 changed files with 13 additions and 16 deletions

View File

@ -30,10 +30,10 @@ import butterknife.BindView;
public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder> { public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder> {
private List<Policy> policyList; private final List<Policy> policyList;
private MagiskDB dbHelper; private final MagiskDB dbHelper;
private PackageManager pm; private final PackageManager pm;
private boolean[] expandList; private final boolean[] expandList;
public PolicyAdapter(List<Policy> list, MagiskDB db, PackageManager pm) { public PolicyAdapter(List<Policy> list, MagiskDB db, PackageManager pm) {
policyList = list; policyList = list;
@ -78,8 +78,7 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
holder.masterSwitch.setOnClickListener(v -> { holder.masterSwitch.setOnClickListener(v -> {
boolean isChecked = holder.masterSwitch.isChecked(); boolean isChecked = holder.masterSwitch.isChecked();
Runnable r = () -> { Runnable r = () -> {
if ((isChecked && policy.policy == Policy.DENY) || if (isChecked ? policy.policy == Policy.DENY : policy.policy == Policy.ALLOW) {
(!isChecked && policy.policy == Policy.ALLOW)) {
policy.policy = isChecked ? Policy.ALLOW : Policy.DENY; policy.policy = isChecked ? Policy.ALLOW : Policy.DENY;
String message = v.getContext().getString( String message = v.getContext().getString(
isChecked ? R.string.su_snack_grant : R.string.su_snack_deny, policy.appName); isChecked ? R.string.su_snack_grant : R.string.su_snack_deny, policy.appName);
@ -98,8 +97,7 @@ public class PolicyAdapter extends RecyclerView.Adapter<PolicyAdapter.ViewHolder
} }
}); });
holder.notificationSwitch.setOnCheckedChangeListener((v, isChecked) -> { holder.notificationSwitch.setOnCheckedChangeListener((v, isChecked) -> {
if ((isChecked && !policy.notification) || if (isChecked != policy.notification) {
(!isChecked && policy.notification)) {
policy.notification = isChecked; policy.notification = isChecked;
String message = v.getContext().getString( String message = v.getContext().getString(
isChecked ? R.string.su_snack_notif_on : R.string.su_snack_notif_off, policy.appName); 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<PolicyAdapter.ViewHolder
} }
}); });
holder.loggingSwitch.setOnCheckedChangeListener((v, isChecked) -> { holder.loggingSwitch.setOnCheckedChangeListener((v, isChecked) -> {
if ((isChecked && !policy.logging) || if (isChecked != policy.logging) {
(!isChecked && policy.logging)) {
policy.logging = isChecked; policy.logging = isChecked;
String message = v.getContext().getString( String message = v.getContext().getString(
isChecked ? R.string.su_snack_log_on : R.string.su_snack_log_off, policy.appName); 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<PolicyAdapter.ViewHolder
new FingerprintAuthDialog((Activity) v.getContext(), new FingerprintAuthDialog((Activity) v.getContext(),
() -> l.onClick(null, 0)).show(); () -> l.onClick(null, 0)).show();
} else { } else {
new CustomAlertDialog((Activity) v.getContext()) new CustomAlertDialog(v.getContext())
.setTitle(R.string.su_revoke_title) .setTitle(R.string.su_revoke_title)
.setMessage(v.getContext().getString(R.string.su_revoke_msg, policy.appName)) .setMessage(v.getContext().getString(R.string.su_revoke_msg, policy.appName))
.setPositiveButton(R.string.yes, l) .setPositiveButton(R.string.yes, l)

View File

@ -43,8 +43,8 @@ public class ReposAdapter
private static final int OTHERS = 2; private static final int OTHERS = 2;
private Map<String, Module> moduleMap; private Map<String, Module> moduleMap;
private RepoDatabaseHelper repoDB; private final RepoDatabaseHelper repoDB;
private List<Pair<Integer, List<Repo>>> repoPairs; private final List<Pair<Integer, List<Repo>>> repoPairs;
private List<Repo> fullList; private List<Repo> fullList;
private SearchView mSearch; private SearchView mSearch;
@ -110,10 +110,10 @@ public class ReposAdapter
holder.updateTime.setText(context.getString(R.string.updated_on, repo.getLastUpdateString())); holder.updateTime.setText(context.getString(R.string.updated_on, repo.getLastUpdateString()));
holder.infoLayout.setOnClickListener(v -> holder.infoLayout.setOnClickListener(v ->
MarkDownWindow.show((BaseActivity) context, null, repo.getDetailUrl())); MarkDownWindow.show(context, null, repo.getDetailUrl()));
holder.downloadImage.setOnClickListener(v -> { holder.downloadImage.setOnClickListener(v -> {
new CustomAlertDialog((BaseActivity) context) new CustomAlertDialog(context)
.setTitle(context.getString(R.string.repo_install_title, repo.getName())) .setTitle(context.getString(R.string.repo_install_title, repo.getName()))
.setMessage(context.getString(R.string.repo_install_msg, repo.getDownloadFilename())) .setMessage(context.getString(R.string.repo_install_msg, repo.getDownloadFilename()))
.setCancelable(true) .setCancelable(true)

View File

@ -119,7 +119,7 @@ public class SafetyNet implements ISafetyNetHelper.Callback {
}; };
if (!EXT_APK.exists()) { if (!EXT_APK.exists()) {
// Show dialog // Show dialog
new CustomAlertDialog((Activity) v.getContext()) new CustomAlertDialog(v.getContext())
.setTitle(R.string.proprietary_title) .setTitle(R.string.proprietary_title)
.setMessage(R.string.proprietary_notice) .setMessage(R.string.proprietary_notice)
.setCancelable(true) .setCancelable(true)