[Android] Improve ML management

Geoffrey Métais git at videolan.org
Wed Jan 18 15:58:05 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Jan 17 17:24:33 2017 +0100| [f4382884ae85a9984cce1f6e6541ac1972012e41] | committer: Geoffrey Métais

Improve ML management

Do not reload while already loading and no need to have ML initilized
for adding/removing callbacks

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

 medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 8 +++-----
 1 file changed, 3 insertions(+), 5 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 2e06a42..1a9c433 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -91,6 +91,8 @@ public class Medialibrary {
     }
 
     public String[] getFoldersList() {
+        if (!mIsInitiated)
+            return new String[0];
         return nativeEntryPoints();
     }
 
@@ -174,7 +176,7 @@ public class Medialibrary {
     }
 
     public void reload() {
-        if (mIsInitiated)
+        if (mIsInitiated && !isWorking())
             nativeReload();
     }
 
@@ -373,14 +375,10 @@ public class Medialibrary {
     }
 
     public void addDeviceDiscoveryCb(DevicesDiscoveryCb cb) {
-        if (!mIsInitiated)
-            return;
         devicesDiscoveryCbList.add(cb);
     }
 
     public void removeDeviceDiscoveryCb(DevicesDiscoveryCb cb) {
-        if (!mIsInitiated)
-            return;
         devicesDiscoveryCbList.remove(cb);
     }
 



More information about the Android mailing list