[Android] Emptiness check for JNI String arguments

Geoffrey Métais git at videolan.org
Wed Aug 23 18:17:40 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Wed Aug 23 15:13:33 2017 +0200| [b5674b6d0b055a9234bd6260809445907376ff06] | committer: Geoffrey Métais

Emptiness check for JNI String arguments

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

 .../org/videolan/medialibrary/Medialibrary.java    | 22 +++++++++++-----------
 1 file changed, 11 insertions(+), 11 deletions(-)

diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index 1e57cde2c..7993f3ac1 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -132,7 +132,7 @@ public class Medialibrary {
     }
 
     public boolean removeDevice(String uuid) {
-        return mIsInitiated && nativeRemoveDevice(VLCUtil.encodeVLCString(uuid));
+        return mIsInitiated && !TextUtils.isEmpty(uuid) && nativeRemoveDevice(VLCUtil.encodeVLCString(uuid));
     }
 
     @Override
@@ -214,7 +214,7 @@ public class Medialibrary {
     }
 
     public Playlist createPlaylist(String name) {
-        return mIsInitiated ? nativePlaylistCreate(name) : null;
+        return mIsInitiated && !TextUtils.isEmpty(name) ? nativePlaylistCreate(name) : null;
     }
 
     public void pauseBackgroundOperations() {
@@ -233,7 +233,7 @@ public class Medialibrary {
     }
 
     public void reload(String entryPoint) {
-        if (mIsInitiated)
+        if (mIsInitiated && !TextUtils.isEmpty(entryPoint))
             nativeReload(entryPoint);
     }
 
@@ -269,11 +269,11 @@ public class Medialibrary {
     }
 
     public MediaWrapper getMedia(String mrl) {
-        return mIsInitiated ? nativeGetMediaFromMrl(Tools.encodeVLCMrl(mrl)) : null;
+        return mIsInitiated && !TextUtils.isEmpty(mrl) ? nativeGetMediaFromMrl(Tools.encodeVLCMrl(mrl)) : null;
     }
 
     public MediaWrapper addMedia(String mrl) {
-        return mIsInitiated ? nativeAddMedia(Tools.encodeVLCMrl(mrl)) : null;
+        return mIsInitiated && !TextUtils.isEmpty(mrl) ? nativeAddMedia(Tools.encodeVLCMrl(mrl)) : null;
     }
 
     public long getId() {
@@ -492,27 +492,27 @@ public class Medialibrary {
     }
 
     public SearchAggregate search(String query) {
-        return mIsInitiated ? nativeSearch(query) : null;
+        return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearch(query) : null;
     }
 
     public MediaSearchAggregate searchMedia(String query) {
-        return mIsInitiated ? nativeSearchMedia(query) : null;
+        return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchMedia(query) : null;
     }
 
     public Artist[] searchArtist(String query) {
-        return mIsInitiated ? nativeSearchArtist(query) : null;
+        return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchArtist(query) : null;
     }
 
     public Album[] searchAlbum(String query) {
-        return mIsInitiated ? nativeSearchAlbum(query) : null;
+        return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchAlbum(query) : null;
     }
 
     public Genre[] searchGenre(String query) {
-        return mIsInitiated ? nativeSearchGenre(query) : null;
+        return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchGenre(query) : null;
     }
 
     public Playlist[] searchPlaylist(String query) {
-        return mIsInitiated ? nativeSearchPlaylist(query) : null;
+        return mIsInitiated && !TextUtils.isEmpty(query) ? nativeSearchPlaylist(query) : null;
     }
 
     public void addDeviceDiscoveryCb(DevicesDiscoveryCb cb) {



More information about the Android mailing list