[Android] Correctly handle discovery of one single directory

Geoffrey Métais git at videolan.org
Tue Feb 28 12:09:19 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Feb 28 11:53:58 2017 +0100| [9771eadf041c0d8f36055c78c05b97ab581478ab] | committer: Geoffrey Métais

Correctly handle discovery of one single directory

> https://code.videolan.org/videolan/vlc-android/commit/9771eadf041c0d8f36055c78c05b97ab581478ab
---

 vlc-android/src/org/videolan/vlc/MediaParsingService.java | 10 ++++++++--
 1 file changed, 8 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/MediaParsingService.java b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
index f440e7a..05eb675 100644
--- a/vlc-android/src/org/videolan/vlc/MediaParsingService.java
+++ b/vlc-android/src/org/videolan/vlc/MediaParsingService.java
@@ -43,7 +43,9 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
     private Medialibrary mMedialibrary;
     private int mParsing = 0, mReload = 0;
     private String mCurrentDiscovery = null;
+    String mFolderToDiscover = null;
     private long mLastNotificationTime = 0L;
+
     private BroadcastReceiver mReceiver = new BroadcastReceiver() {
         @Override
         public void onReceive(Context context, Intent intent) {
@@ -93,6 +95,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
     }
 
     private void discover(String path) {
+        mFolderToDiscover = "";
         mMedialibrary.discover(path);
     }
 
@@ -201,7 +204,10 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
     }
 
     @Override
-    public void onDiscoveryStarted(String entryPoint) {}
+    public void onDiscoveryStarted(String entryPoint) {
+        if (mFolderToDiscover != null && mFolderToDiscover.isEmpty())
+            mFolderToDiscover = entryPoint;
+    }
 
     @Override
     public void onDiscoveryProgress(String entryPoint) {
@@ -212,7 +218,7 @@ public class MediaParsingService extends Service implements DevicesDiscoveryCb {
 
     @Override
     public void onDiscoveryCompleted(String entryPoint) {
-        if (mCurrentDiscovery != null && mParsing == 0 && entryPoint.isEmpty())
+        if ((mParsing == 0 && mCurrentDiscovery != null && entryPoint.isEmpty()) || TextUtils.equals(mFolderToDiscover, entryPoint))
             stopSelf();
     }
 



More information about the Android mailing list