[Android] MediaList: increase count after items move

Geoffrey Métais git at videolan.org
Fri May 24 15:09:26 CEST 2019


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

MediaList: increase count after items move

Prevent ArrayIndexOutOfBoundsException

(cherry picked from commit 1f245e48cae953bcc57aa2cb795dc38eefbf6943)

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

 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 c6a87573a..c7fdd722a 100644
--- a/libvlc/src/org/videolan/libvlc/MediaList.java
+++ b/libvlc/src/org/videolan/libvlc/MediaList.java
@@ -104,10 +104,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