[Android] Prevent potential NPE

Geoffrey Métais git at videolan.org
Fri Sep 8 15:43:52 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Sep  8 15:43:30 2017 +0200| [6c8cd7c4f112c6814c3a2ba77b0947f61deb773c] | committer: Geoffrey Métais

Prevent potential NPE

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

 vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java | 5 ++---
 1 file changed, 2 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
index 7173c0fa0..1518e06a7 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoPlayerActivity.java
@@ -3200,12 +3200,11 @@ public class VideoPlayerActivity extends AppCompatActivity implements IVLCVout.C
             MediaWrapper media;
             if (!resumePlaylist) {
                 // restore last position
-                final Medialibrary ml = mMedialibrary;
-                media = ml.getMedia(mUri.getScheme().equals("content") ? FileUtils.getUri(mUri) : mUri);
+                media = mMedialibrary.getMedia("content".equals(mUri.getScheme()) ? FileUtils.getUri(mUri) : mUri);
                 if (media == null && TextUtils.equals(mUri.getScheme(), "file") &&
                         mUri.getPath() != null && mUri.getPath().startsWith("/sdcard")) {
                     mUri = FileUtils.convertLocalUri(mUri);
-                    media = ml.getMedia(mUri);
+                    media = mMedialibrary.getMedia(mUri);
                 }
                 if (media != null && media.getId() != 0L && media.getTime() == 0L)
                     media.setTime((long) (media.getMetaLong(MediaWrapper.META_PROGRESS) * (double) media.getLength())/100L);



More information about the Android mailing list