[Android] Ensure we don't pass empty mrls to emdialibrary
Geoffrey Métais
git at videolan.org
Mon Nov 6 16:00:47 CET 2017
vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Nov 6 15:26:16 2017 +0100| [be4480fabcdcdbbd06ddbd935f85148c1c1994fe] | committer: Geoffrey Métais
Ensure we don't pass empty mrls to emdialibrary
(cherry picked from commit 57b1a3e2a41c27d64327fd32a0cc5f91946dc720)
> https://code.videolan.org/videolan/vlc-android/commit/be4480fabcdcdbbd06ddbd935f85148c1c1994fe
---
.../src/org/videolan/medialibrary/Medialibrary.java | 14 +++++++++++---
1 file changed, 11 insertions(+), 3 deletions(-)
diff --git a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
index f48915d5e..76c275352 100644
--- a/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
+++ b/medialibrary/src/org/videolan/medialibrary/Medialibrary.java
@@ -8,6 +8,7 @@ import android.net.Uri;
import android.os.Build;
import android.os.Environment;
import android.support.annotation.NonNull;
+import android.support.annotation.Nullable;
import android.support.annotation.WorkerThread;
import android.support.v4.content.ContextCompat;
import android.support.v4.content.LocalBroadcastManager;
@@ -252,20 +253,27 @@ public class Medialibrary {
return mIsInitiated && nativeAddToHistory(Tools.encodeVLCMrl(mrl), VLCUtil.encodeVLCString(title));
}
+ @Nullable
public MediaWrapper getMedia(long id) {
return mIsInitiated ? nativeGetMedia(id) : null;
}
+ @Nullable
public MediaWrapper getMedia(Uri uri) {
- return mIsInitiated ? nativeGetMediaFromMrl(VLCUtil.encodeVLCUri(uri)) : null;
+ final String vlcMrl = VLCUtil.encodeVLCUri(uri);
+ return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeGetMediaFromMrl(vlcMrl) : null;
}
+ @Nullable
public MediaWrapper getMedia(String mrl) {
- return mIsInitiated && !TextUtils.isEmpty(mrl) ? nativeGetMediaFromMrl(Tools.encodeVLCMrl(mrl)) : null;
+ final String vlcMrl = Tools.encodeVLCMrl(mrl);
+ return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeGetMediaFromMrl(vlcMrl) : null;
}
+ @Nullable
public MediaWrapper addMedia(String mrl) {
- return mIsInitiated && !TextUtils.isEmpty(mrl) ? nativeAddMedia(Tools.encodeVLCMrl(mrl)) : null;
+ final String vlcMrl = Tools.encodeVLCMrl(mrl);
+ return mIsInitiated && !TextUtils.isEmpty(vlcMrl) ? nativeAddMedia(vlcMrl) : null;
}
public long getId() {
More information about the Android
mailing list