[Android] Improve external storage discovery
Geoffrey Métais
git at videolan.org
Thu Feb 23 17:31:44 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Feb 23 17:30:59 2017 +0100| [85a22aa7d8ae56aad606ac9164f4cd9aceba4670] | committer: Geoffrey Métais
Improve external storage discovery
> https://code.videolan.org/videolan/vlc-android/commit/85a22aa7d8ae56aad606ac9164f4cd9aceba4670
---
.../src/org/videolan/vlc/MediaParsingService.java | 17 ++++++++++++-----
1 file changed, 12 insertions(+), 5 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index f75b902..42401e0 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -21,6 +21,7 @@ import org.videolan.medialibrary.interfaces.DevicesDiscoveryCb;
import org.videolan.vlc.util.AndroidDevices;
import org.videolan.vlc.util.FileUtils;
import org.videolan.vlc.util.Strings;
+import org.videolan.vlc.util.Util;
import java.io.File;
@@ -120,19 +121,25 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
if (mMedialibrary.init(VLCApplication.getAppContext())) {
showNotification();
LocalBroadcastManager.getInstance(MediaParsingService.this).sendBroadcast(new Intent(VLCApplication.ACTION_MEDIALIBRARY_READY));
- if (mMedialibrary.getFoldersList().length == 0) {
+ String[] foldersList = mMedialibrary.getFoldersList();
+ if (foldersList.length == 0) {
for (String storage : storages)
for (String folder : Medialibrary.getBlackList())
- mMedialibrary.banFolder(storage+folder);
+ mMedialibrary.banFolder(storage + folder);
for (File folder : Medialibrary.getDefaultFolders())
if (folder.exists())
mMedialibrary.discover(folder.getPath());
- for (String externalStorage : AndroidDevices.getExternalStorageDirectories())
- if (!TextUtils.equals(externalStorage, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY))
- mMedialibrary.discover(externalStorage);
} else if (upgrade) {
mMedialibrary.forceParserRetry();
}
+ for (String externalStorage : AndroidDevices.getExternalStorageDirectories()) {
+ if (!TextUtils.equals(externalStorage, AndroidDevices.EXTERNAL_PUBLIC_DIRECTORY)
+ && !Util.arrayContains(foldersList, "file://" + externalStorage + "/")) {
+ for (String folder : Medialibrary.getBlackList())
+ mMedialibrary.banFolder(externalStorage + folder);
+ mMedialibrary.discover(externalStorage);
+ }
+ }
}
}
});
More information about the Android
mailing list