[Android] Use path in folders settings for now

Geoffrey Métais git at videolan.org
Thu Jan 12 13:04:58 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Jan 12 13:04:21 2017 +0100| [913e3814843a2eb16b2b094e41286b1ccf7ea160] | committer: Geoffrey Métais

Use path in folders settings for now

> https://code.videolan.org/videolan/vlc-android/commit/913e3814843a2eb16b2b094e41286b1ccf7ea160
---

 .../videolan/vlc/gui/browser/BaseBrowserAdapter.java   |  3 ++-
 .../vlc/gui/browser/StorageBrowserAdapter.java         | 18 ++++++++++++------
 .../vlc/gui/browser/StorageBrowserFragment.java        |  2 +-
 3 files changed, 15 insertions(+), 8 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index dea18bb..09e0089 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -55,6 +55,7 @@ import java.util.List;
 
 import static org.videolan.medialibrary.media.MediaLibraryItem.FLAG_SELECTED;
 import static org.videolan.medialibrary.media.MediaLibraryItem.TYPE_MEDIA;
+import static org.videolan.medialibrary.media.MediaLibraryItem.TYPE_STORAGE;
 
 public class BaseBrowserAdapter extends RecyclerView.Adapter<BaseBrowserAdapter.ViewHolder> implements Filterable {
     protected static final String TAG = "VLC/BaseBrowserAdapter";
@@ -175,7 +176,7 @@ public class BaseBrowserAdapter extends RecyclerView.Adapter<BaseBrowserAdapter.
         }
 
         public void onCheckBoxClick(View v){
-            if (getItem(getAdapterPosition()) instanceof Storage) {
+            if (getItem(getAdapterPosition()).getItemType() == TYPE_STORAGE) {
                 checkBoxAction(v, ((Storage) getItem(getAdapterPosition())).getUri().getPath());
             }
         }
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 97d0f57..3862a70 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserAdapter.java
@@ -45,12 +45,13 @@ import java.util.Arrays;
 public class StorageBrowserAdapter extends BaseBrowserAdapter {
 
     boolean isRoot;
-    ArrayList<String> mMediaDirsLocation = new ArrayList<>();
-    ArrayList<String> mCustomDirsLocation;
+    private static ArrayList<String> mMediaDirsLocation;
+    private static ArrayList<String> mCustomDirsLocation;
 
     public StorageBrowserAdapter(BaseBrowserFragment fragment) {
         super(fragment);
-        updateMediaDirs();
+        if (mMediaDirsLocation == null && mCustomDirsLocation == null)
+            updateMediaDirs();
         isRoot = fragment.isRootDirectory();
     }
 
@@ -133,9 +134,14 @@ public class StorageBrowserAdapter extends BaseBrowserAdapter {
         });
     }
 
-    void updateMediaDirs(){
-        mMediaDirsLocation.clear();
-        mMediaDirsLocation = new ArrayList<>(Arrays.asList(VLCApplication.getMLInstance().getFoldersList()));
+    void updateMediaDirs() {
+        if (mMediaDirsLocation != null)
+            mMediaDirsLocation.clear();
+        String folders[] = VLCApplication.getMLInstance().getFoldersList();
+        mMediaDirsLocation = new ArrayList<>(folders.length);
+        for (String folder : folders) {
+            mMediaDirsLocation.add(folder.substring(7));
+        }
         mCustomDirsLocation = new ArrayList<>(Arrays.asList(CustomDirectories.getCustomDirectories()));
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
index 5b2ab72..992c722 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/StorageBrowserFragment.java
@@ -108,7 +108,7 @@ public class StorageBrowserFragment extends FileBrowserFragment {
 
     @Override
     protected void browseRoot() {
-        String[] storages = mMediaLibrary.getDevices();
+        String[] storages = AndroidDevices.getMediaDirectories();
         String[] customDirectories = CustomDirectories.getCustomDirectories();
         Storage storage;
         ArrayList<MediaLibraryItem> storagesList = new ArrayList<>();



More information about the Android mailing list