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 ...@@ -188,9 +188,9 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) { public void onCheckedChanged(CompoundButton compoundButton, boolean isChecked) {
String path = ((Storage)getItem(vh.getAdapterPosition())).getPath(); String path = ((Storage)getItem(vh.getAdapterPosition())).getPath();
updateMediaDirs(); updateMediaDirs();
if (isChecked) if (isChecked) {
mDbManager.addDir(path); addDir(path);
else { } else {
if (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty()){ if (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty()){
String storagePath; String storagePath;
for (Object storage : mMediaList){ for (Object storage : mMediaList){
...@@ -222,6 +222,20 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH ...@@ -222,6 +222,20 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<RecyclerView.ViewH
vh.checkBox.setEnabled(false); 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 @Override
public int getItemCount() { public int getItemCount() {
return mMediaList.size(); 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