[Android] Do not add item at invalid position

Geoffrey Métais git at videolan.org
Tue Mar 7 18:29:28 CET 2017


vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar  7 18:27:45 2017 +0100| [2c9289c0e971de873efb45ff643783eced5cc034] | committer: Geoffrey Métais

Do not add item at invalid position

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

 .../src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java        | 6 ++++--
 1 file changed, 4 insertions(+), 2 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
index b0d9568..2d993dc 100644
--- a/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/browser/BaseBrowserAdapter.java
@@ -244,8 +244,10 @@ public class BaseBrowserAdapter extends BaseQueuedAdapter<ArrayList<MediaLibrary
         if (item .getItemType() == TYPE_MEDIA && (((MediaWrapper) item).getType() == MediaWrapper.TYPE_VIDEO || ((MediaWrapper) item).getType() == MediaWrapper.TYPE_AUDIO))
             mMediaCount++;
 
-        list.add(position, item);
-        update(list);
+        if (position <= list.size()) {
+            list.add(position, item);
+            update(list);
+        }
     }
 
     public void setTop (int top) {



More information about the Android mailing list