[Android] Better handling of directories at root level
Geoffrey Métais
git at videolan.org
Tue May 12 16:39:18 CEST 2015
vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue May 12 16:20:13 2015 +0200| [8328c8ab34ba5c56f9545d0005e1099ba6bcb65f] | committer: Geoffrey Métais
Better handling of directories at root level
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=8328c8ab34ba5c56f9545d0005e1099ba6bcb65f
---
.../vlc/gui/browser/StorageBrowserAdapter.java | 33 +++++++++++++++-----
1 file changed, 25 insertions(+), 8 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
index 6f23af2..9555b3f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
@@ -37,9 +37,11 @@ import org.videolan.vlc.util.Strings;
public class StorageBrowserAdapter extends BaseBrowserAdapter {
+ boolean isRoot;
public StorageBrowserAdapter(BaseBrowserFragment fragment) {
super(fragment);
updateMediaDirs();
+ isRoot = fragment.isRootDirectory();
}
@Override
@@ -71,14 +73,14 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
((StorageBrowserFragment) fragment).browse(mw, holder.getAdapterPosition(), vh.checkBox.isChecked());
}
});
- vh.checkBox.setChecked(mMediaDirsLocation == null || mMediaDirsLocation.isEmpty() ||
+ vh.checkBox.setChecked((isRoot && (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty())) ||
mMediaDirsLocation.contains(storage.getPath()));
vh.checkBox.setEnabled(!((StorageBrowserFragment) fragment).mScannedDirectory);
vh.checkBox.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
- boolean isChecked = ((CheckBox)v).isChecked();
- String path = ((Storage)getItem(vh.getAdapterPosition())).getPath();
+ boolean isChecked = ((CheckBox) v).isChecked();
+ String path = ((Storage) getItem(vh.getAdapterPosition())).getPath();
if (isChecked)
addDir(path);
else
@@ -110,10 +112,25 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
addItem(storage, notify, top);
}
- private void removeDir(String path) {
- mDbManager.removeDir(path);
- updateMediaDirs();
- fragment.updateLib();
+ private void removeDir(final String path) {
+ new Thread(new Runnable() {
+ @Override
+ public void run() {
+ //if media dir list was empty, we add all others
+ if (mMediaDirsLocation.isEmpty()) {
+ Storage storage;
+ for (Object item : mMediaList){
+ storage = (Storage) item;
+ if (!TextUtils.equals(path, storage.getPath()))
+ mDbManager.addDir(storage.getPath());
+ }
+ } else
+ mDbManager.removeDir(path);
+ updateMediaDirs();
+ if (isRoot && mMediaDirsLocation.isEmpty())
+ refreshFragment();
+ }
+ }).start();
}
private void addDir(final String path) {
@@ -128,7 +145,6 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
}
refreshFragment();
updateMediaDirs();
- fragment.updateLib();
}
}).start();
}
@@ -139,6 +155,7 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
public void run() {
if (mMediaDirsLocation == null || mMediaDirsLocation.isEmpty())
fragment.refresh();
+ fragment.updateLib();
}
});
}
More information about the Android
mailing list