[Android] Prevent ArrayIndexOutOfBoundsException in adapters

Geoffrey Métais git at videolan.org
Tue Jan 16 17:45:00 CET 2018


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

Prevent ArrayIndexOutOfBoundsException in adapters

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

 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