[Android] Update media directories in DirectoryViewFragment

Geoffrey Métais git at videolan.org
Thu Mar 26 13:18:12 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Mar 26 13:17:19 2015 +0100| [18762feeb0990354b94476cd90f6c9220eb00448] | committer: Geoffrey Métais

Update media directories in DirectoryViewFragment

Fixes #10497

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=18762feeb0990354b94476cd90f6c9220eb00448
---

 .../src/org/videolan/vlc/gui/DirectoryViewFragment.java |    7 ++++++-
 .../src/org/videolan/vlc/util/AndroidDevices.java       |    2 +-
 .../src/org/videolan/vlc/util/CustomDirectories.java    |   15 +++++++++++++++
 3 files changed, 22 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
index 5ec2332..3232e8e 100644
--- a/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
+++ b/vlc-android/src/org/videolan/vlc/gui/DirectoryViewFragment.java
@@ -60,7 +60,6 @@ import android.view.ViewGroup;
 import android.widget.AbsListView;
 import android.widget.AdapterView;
 import android.widget.AdapterView.AdapterContextMenuInfo;
-import android.widget.AdapterView.OnItemLongClickListener;
 import android.widget.ListView;
 
 public class DirectoryViewFragment extends BrowserFragment implements IRefreshable, SwipeRefreshLayout.OnRefreshListener, AdapterView.OnItemClickListener {
@@ -92,6 +91,12 @@ public class DirectoryViewFragment extends BrowserFragment implements IRefreshab
         focusHelper(mDirectoryAdapter.isEmpty());
     }
 
+    @Override
+    public void onResume() {
+        super.onResume();
+        refresh();
+    }
+
     private void focusHelper(boolean idIsEmpty) {
         View parent = View.inflate(getActivity(),
             R.layout.directory_view, null);
diff --git a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
index 003c2e0..993e553 100644
--- a/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
+++ b/vlc-android/src/org/videolan/vlc/util/AndroidDevices.java
@@ -142,7 +142,7 @@ public class AndroidDevices {
     public static String[] getMediaDirectories() {
         ArrayList<String> list = new ArrayList<String>();
         list.addAll(getStorageDirectories());
-        list.addAll(Arrays.asList(CustomDirectories.getCustomDirectories()));
+        list.addAll(CustomDirectories.getActiveCustomDirectories());
         return list.toArray(new String[list.size()]);
     }
 
diff --git a/vlc-android/src/org/videolan/vlc/util/CustomDirectories.java b/vlc-android/src/org/videolan/vlc/util/CustomDirectories.java
index 1a1ac1b..06934d5 100644
--- a/vlc-android/src/org/videolan/vlc/util/CustomDirectories.java
+++ b/vlc-android/src/org/videolan/vlc/util/CustomDirectories.java
@@ -20,9 +20,13 @@
 
 package org.videolan.vlc.util;
 
+import java.io.File;
 import java.util.ArrayList;
 import java.util.Arrays;
+import java.util.Collections;
+import java.util.List;
 
+import org.videolan.vlc.MediaDatabase;
 import org.videolan.vlc.VLCApplication;
 
 import android.content.SharedPreferences;
@@ -81,4 +85,15 @@ public class CustomDirectories {
             return custom_paths.split(":");
     }
 
+    public static ArrayList<String> getActiveCustomDirectories() {
+        ArrayList<String> activePaths = new ArrayList<String>();
+        final ArrayList<String> customPaths = new ArrayList<String>(Arrays.asList(getCustomDirectories()));
+        List<File> dirs = MediaDatabase.getInstance().getMediaDirs();
+        for (File dir : dirs){
+            if (customPaths.contains(dir.getPath()))
+                activePaths.add(dir.getPath());
+        }
+        return activePaths;
+    }
+
 }



More information about the Android mailing list