[Android] MediaList: increase count after items move

Geoffrey Métais git at videolan.org
Thu May 16 15:30:37 CEST 2019


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu May 16 15:30:20 2019 +0200| [1f245e48cae953bcc57aa2cb795dc38eefbf6943] | committer: Geoffrey Métais

MediaList: increase count after items move

Prevent ArrayIndexOutOfBoundsException

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

 libvlc/src/org/videolan/libvlc/MediaList.java | 3 +--
 1 file changed, 1 insertion(+), 2 deletions(-)

diff --git a/libvlc/src/org/videolan/libvlc/MediaList.java b/libvlc/src/org/videolan/libvlc/MediaList.java
index 317597a5e..44d909853 100644
--- a/libvlc/src/org/videolan/libvlc/MediaList.java
+++ b/libvlc/src/org/videolan/libvlc/MediaList.java
@@ -106,10 +106,9 @@ public class MediaList extends VLCObject<MediaList.Event> {
     }
 
     private synchronized Media insertMediaFromEvent(int index) {
-        mCount++;
-
         for (int i = mCount - 1; i >= index; --i)
             mMediaArray.put(i + 1, mMediaArray.valueAt(i));
+        mCount++;
         final Media media = new Media(this, index);
         mMediaArray.put(index, media);
         return media;



More information about the Android mailing list