[Android] [PATCH] return empty view when position is out of range

Geoffrey Métais geoffrey.metais at gmail.com
Wed Mar 11 14:46:46 CET 2015


When receive crash reports showing that getView is sometie called with an out of range position.
I don't manage to reproduce, I suggest to return an empty view, because this state shouldn't last.

It happens while refreshing, I guess theses view are erased for the newly created ones.
---
 vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java | 2 ++
 1 file changed, 2 insertions(+)

diff --git a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
index 3d37bfc..00b05c9 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -176,6 +176,8 @@ public class VideoListAdapter extends ArrayAdapter<MediaWrapper>
 
         MediaWrapper media = getItem(position);
 
+        if (media == null)
+            return v; //return empty view in case of out of bounds position
         /* Thumbnail */
         Bitmap thumbnail = BitmapUtil.getPictureFromCache(media);
         holder.thumbnail.setScaleType(ImageView.ScaleType.FIT_CENTER);
-- 
2.1.0



More information about the Android mailing list