[Android] Prevent NPE

Geoffrey Métais git at videolan.org
Mon Apr 3 11:53:35 CEST 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Mon Apr  3 11:50:28 2017 +0200| [f5cc244d1bbff68e8aee6e70cd97e102cb478e77] | committer: Geoffrey Métais

Prevent NPE

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

 vlc-android/src/org/videolan/vlc/PlaybackService.java | 8 ++++----
 1 file changed, 4 insertions(+), 4 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/PlaybackService.java b/vlc-android/src/org/videolan/vlc/PlaybackService.java
index 9540b69..1421a27 100644
--- a/vlc-android/src/org/videolan/vlc/PlaybackService.java
+++ b/vlc-android/src/org/videolan/vlc/PlaybackService.java
@@ -1689,7 +1689,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
     @MainThread
     public String getTitlePrev() {
-        if (mPrevIndex != -1)
+        if (isValidIndex(mPrevIndex))
             return mMediaList.getMedia(mPrevIndex).getTitle();
         else
             return null;
@@ -1697,7 +1697,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
     @MainThread
     public String getTitleNext() {
-        if (mNextIndex != -1)
+        if (isValidIndex(mNextIndex))
             return mMediaList.getMedia(mNextIndex).getTitle();
         else
             return null;
@@ -1710,7 +1710,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
     @MainThread
     public String getPrevCoverArt() {
-        if (mPrevIndex != -1)
+        if (isValidIndex(mPrevIndex))
             return mMediaList.getMedia(mPrevIndex).getArtworkMrl();
         else
             return null;
@@ -1718,7 +1718,7 @@ public class PlaybackService extends MediaBrowserServiceCompat implements IVLCVo
 
     @MainThread
     public String getNextCoverArt() {
-        if (mNextIndex != -1)
+        if (isValidIndex(mNextIndex))
             return mMediaList.getMedia(mNextIndex).getArtworkMrl();
         else
             return null;



More information about the Android mailing list