Refactoring

This commit is contained in:
M66B 2022-01-07 18:48:59 +01:00
parent 6651b741eb
commit 850a120cd5
1 changed files with 4 additions and 6 deletions

View File

@ -55,6 +55,8 @@ public class FragmentDialogAsk extends FragmentDialogBase {
final Context context = getContext(); final Context context = getContext();
final int colorError = Helper.resolveColor(context, R.attr.colorError); final int colorError = Helper.resolveColor(context, R.attr.colorError);
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_again, null); View dview = LayoutInflater.from(context).inflate(R.layout.dialog_ask_again, null);
TextView tvMessage = dview.findViewById(R.id.tvMessage); TextView tvMessage = dview.findViewById(R.id.tvMessage);
TextView tvRemark = dview.findViewById(R.id.tvRemark); TextView tvRemark = dview.findViewById(R.id.tvRemark);
@ -85,10 +87,8 @@ public class FragmentDialogAsk extends FragmentDialogBase {
cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() { cbNotAgain.setOnCheckedChangeListener(new CompoundButton.OnCheckedChangeListener() {
@Override @Override
public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) { public void onCheckedChanged(CompoundButton buttonView, boolean isChecked) {
if (accept == null) { if (accept == null)
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean(notagain, isChecked).apply(); prefs.edit().putBoolean(notagain, isChecked).apply();
}
tvAccept.setVisibility(isChecked && accept != null ? View.VISIBLE : View.GONE); tvAccept.setVisibility(isChecked && accept != null ? View.VISIBLE : View.GONE);
} }
}); });
@ -111,10 +111,8 @@ public class FragmentDialogAsk extends FragmentDialogBase {
boolean confirmed = (confirm == null || cbConfirm.isChecked()); boolean confirmed = (confirm == null || cbConfirm.isChecked());
EntityLog.log(context, "Ask confirmed=" + confirmed); EntityLog.log(context, "Ask confirmed=" + confirmed);
if (confirmed) { if (confirmed) {
if (notagain != null && accept != null) { if (notagain != null && accept != null)
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit().putBoolean(notagain, cbNotAgain.isChecked()).apply(); prefs.edit().putBoolean(notagain, cbNotAgain.isChecked()).apply();
}
sendResult(Activity.RESULT_OK); sendResult(Activity.RESULT_OK);
} else } else
sendResult(Activity.RESULT_CANCELED); sendResult(Activity.RESULT_CANCELED);