Commit 921ab24b authored by Sébastien Toque's avatar Sébastien Toque

prevent folders from being randomly checked/unchecked

Because views are recycled, a listener can exist when setChecked is called
while building the view, so it must be removed, and set only at the end
parent 11314179
......@@ -52,23 +52,7 @@ public class BrowserAdapter extends ArrayAdapter<File>
final CheckBox dirCheckBox =
(CheckBox) view.findViewById(R.id.browser_item_selected);
dirCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (dirCheckBox.isEnabled() && isChecked) {
dbManager.addDir(item.getPath());
File tmpFile = item;
while (!tmpFile.getPath().equals("/")) {
tmpFile = tmpFile.getParentFile();
dbManager.removeDir(tmpFile.getPath());
}
} else {
dbManager.removeDir(item.getPath());
}
}
});
dirCheckBox.setOnCheckedChangeListener(null);
dirCheckBox.setEnabled(true);
dirCheckBox.setChecked(false);
......@@ -86,6 +70,22 @@ public class BrowserAdapter extends ArrayAdapter<File>
break;
}
}
dirCheckBox.setOnCheckedChangeListener(new OnCheckedChangeListener() {
public void onCheckedChanged(CompoundButton buttonView,
boolean isChecked) {
if (dirCheckBox.isEnabled() && isChecked) {
dbManager.addDir(item.getPath());
File tmpFile = item;
while (!tmpFile.getPath().equals("/")) {
tmpFile = tmpFile.getParentFile();
dbManager.removeDir(tmpFile.getPath());
}
} else {
dbManager.removeDir(item.getPath());
}
}
});
}
return view;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment