Commit 12e40648 authored by Geoffrey Métais's avatar Geoffrey Métais
Browse files

Recursive check when adding a directory

parent 721f9ed4
......@@ -188,9 +188,9 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
String path = ((Storage)getItem(vh.getAdapterPosition())).getPath();
updateMediaDirs();
if (isChecked)
mDbManager.addDir(path);
else {
if (isChecked) {
addDir(path);
} else {
if (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty()){
String storagePath;
for (Object storage : mMediaList){
......@@ -222,6 +222,20 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
vh.checkBox.setEnabled(false);
}
private void addDir(final String path) {
new Thread(new Runnable() {
@Override
public void run() {
mDbManager.addDir(path);
File tmpFile = new File(path).getParentFile();
while (tmpFile != null && !tmpFile.getPath().equals("/")) {
mDbManager.removeDir(tmpFile.getPath());
tmpFile = tmpFile.getParentFile();
}
}
}).start();
}
@Override
public int getItemCount() {
return mMediaList.size();
......
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