[Android] Prevent ArrayOutOfBoundsException

Geoffrey Métais git at videolan.org
Tue Mar 17 14:41:56 CET 2015


vlc-ports/android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Tue Mar 17 14:18:50 2015 +0100| [64fe7d5685fb562746c86db9a1113ae9c0511680] | committer: Geoffrey Métais

Prevent ArrayOutOfBoundsException

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

 vlc-android/src/org/videolan/vlc/gui/MRLAdapter.java |    8 +++++---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/MRLAdapter.java b/vlc-android/src/org/videolan/vlc/gui/MRLAdapter.java
index f3165a9..537aa40 100644
--- a/vlc-android/src/org/videolan/vlc/gui/MRLAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/MRLAdapter.java
@@ -72,9 +72,11 @@ public class MRLAdapter extends RecyclerView.Adapter<MRLAdapter.ViewHolder> {
             @Override
             public void onClick(View v) {
                 int pos = holder.getPosition();
-                MediaDatabase.getInstance().deleteMrlUri(mDataset.get(pos));
-                mDataset.remove(pos);
-                notifyItemRemoved(pos);
+                if (pos > -1) {
+                    MediaDatabase.getInstance().deleteMrlUri(mDataset.get(pos));
+                    mDataset.remove(pos);
+                    notifyItemRemoved(pos);
+                }
             }
         });
     }



More information about the Android mailing list