[Android] Prevent ArrayIndexOutOfBoundsException in adapters

Geoffrey Métais git at videolan.org
Thu Dec 21 17:28:34 CET 2017


vlc-android | branch: 2.5.x | Geoffrey Métais <geoffrey.metais at gmail.com> | Thu Dec 21 11:28:11 2017 +0100| [2f0c3f8404cb3fd22e9721323df953ff1678f075] | committer: Geoffrey Métais

Prevent ArrayIndexOutOfBoundsException in adapters

(cherry picked from commit 4cba218c4b8b845c73467502293e49aea181f089)

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

 vlc-android/src/org/videolan/vlc/gui/helpers/SelectorViewHolder.java | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/SelectorViewHolder.java b/vlc-android/src/org/videolan/vlc/gui/helpers/SelectorViewHolder.java
index 9f478e4c3..4384bf72b 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/SelectorViewHolder.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/SelectorViewHolder.java
@@ -49,7 +49,7 @@ public class SelectorViewHolder<T extends ViewDataBinding> extends RecyclerView.
 
     @Override
     public void onFocusChange(View v, boolean hasFocus) {
-        setViewBackground(hasFocus, isSelected());
+        if (getLayoutPosition() >= 0) setViewBackground(hasFocus, isSelected());
     }
 
     protected boolean isSelected() {



More information about the Android mailing list