[Android] AudioBrowserListAdapter: fix ArrayIndexOutOfBoundsException

Edward Wang git at videolan.org
Wed Jun 11 22:50:06 CEST 2014


vlc-ports/android | branch: master | Edward Wang <edward.c.wang at compdigitec.com> | Wed Jun 11 16:08:51 2014 -0400| [86e401c67be70b27808f89b0047b265d55c5b988] | committer: Edward Wang

AudioBrowserListAdapter: fix ArrayIndexOutOfBoundsException

Clip invalid index values from Android

> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=86e401c67be70b27808f89b0047b265d55c5b988
---

 .../org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java |   11 ++++++++++-
 1 file changed, 10 insertions(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
index 4b40b14..5ee920a 100644
--- a/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/audio/AudioBrowserListAdapter.java
@@ -363,7 +363,16 @@ public class AudioBrowserListAdapter extends BaseAdapter implements SectionIndex
 
     @Override
     public int getPositionForSection(int sectionIndex) {
-        return mSections.keyAt(sectionIndex);
+        int index;
+        if(mSections.size() == 0)
+            index = 0;
+        else if(sectionIndex > mSections.size())
+            index = mSections.size() - 1;
+        else if(sectionIndex < 0)
+            index = 0;
+        else
+            index = sectionIndex;
+        return mSections.keyAt(index);
     }
 
     @Override



More information about the Android mailing list