[Android] Medialibrary: add init checks

Geoffrey Métais git at videolan.org
Tue Mar 14 18:34:02 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 14 15:35:49 2017 +0100| [cfa90749ca11261b8172e75852f22fea20dce732] | committer: Geoffrey Métais

Medialibrary: add init checks

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

 medialibrary/src/org/videolan/medialibrary/Medialibrary.java | 10 ++++++----
 1 file changed, 6 insertions(+), 4 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index b49c39d..3f6b028 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -78,7 +78,7 @@ public class Medialibrary {
     }
 
     public String[] getDevices() {
-        return nativeDevices();
+        return mIsInitiated ? nativeDevices() : new String[0];
     }
 
     public void addDevice(String uuid, String path, boolean removable) {
@@ -86,11 +86,13 @@ public class Medialibrary {
     }
 
     public void discover(String path) {
-        nativeDiscover(Tools.encodeVLCMrl(path));
+        if (mIsInitiated)
+            nativeDiscover(Tools.encodeVLCMrl(path));
     }
 
     public void removeFolder(String path) {
-        nativeRemoveEntryPoint(Tools.encodeVLCMrl(path));
+        if (mIsInitiated)
+            nativeRemoveEntryPoint(Tools.encodeVLCMrl(path));
     }
 
     public String[] getFoldersList() {
@@ -100,7 +102,7 @@ public class Medialibrary {
     }
 
     public boolean removeDevice(String uuid) {
-        return nativeRemoveDevice(uuid);
+        return mIsInitiated && nativeRemoveDevice(uuid);
     }
 
     @Override



More information about the Android mailing list