Using checked state listener instead of click listener

This commit is contained in:
tonymanou 2017-01-09 22:27:25 +01:00 committed by topjohnwu
parent 8f43055b0e
commit 7be5937aa0

View File

@ -47,10 +47,10 @@ public class ModulesAdapter extends RecyclerView.Adapter<ModulesAdapter.ViewHold
holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author)); holder.author.setText(TextUtils.isEmpty(author) ? null : context.getString(R.string.author, author));
holder.description.setText(module.getDescription()); holder.description.setText(module.getDescription());
holder.checkBox.setOnCheckedChangeListener(null);
holder.checkBox.setChecked(module.isEnabled()); holder.checkBox.setChecked(module.isEnabled());
holder.checkBox.setOnClickListener((v) -> { holder.checkBox.setOnCheckedChangeListener((v, isChecked) -> {
CheckBox checkBox = (CheckBox) v; if (isChecked) {
if (checkBox.isChecked()) {
new Async.RootTask<Void, Void, Void>() { new Async.RootTask<Void, Void, Void>() {
@Override @Override
protected Void doInBackground(Void... voids) { protected Void doInBackground(Void... voids) {