[Android] VideoListAdapter: don't load picture asynchronously if already in cache
Thomas Guillem
git at videolan.org
Tue Oct 6 18:32:34 CEST 2015
vlc-ports/android | branch: master | Thomas Guillem <thomas at gllm.fr> | Tue Oct 6 17:32:25 2015 +0200| [aaefb530882f1852c97e10c50b26884d871a77f8] | committer: Thomas Guillem
VideoListAdapter: don't load picture asynchronously if already in cache
> http://git.videolan.org/gitweb.cgi/vlc-ports/android.git/?a=commit;h=aaefb530882f1852c97e10c50b26884d871a77f8
---
.../org/videolan/vlc/gui/video/VideoListAdapter.java | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
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 85e7b73..4a89ac0 100644
--- a/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
+++ b/vlc-android/src/org/videolan/vlc/gui/video/VideoListAdapter.java
@@ -183,10 +183,19 @@ public class VideoListAdapter extends ArrayAdapter<MediaWrapper>
MediaWrapper media = getItem(position);
- AsyncImageLoader.LoadVideoCover(new VideoCoverFetcher(media), holder.binding, mFragment.getActivity());
holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.CENTER);
- holder.binding.setVariable(BR.cover, DEFAULT_COVER);
+ final Bitmap bitmap = BitmapUtil.getPictureFromCache(media);
+ if (bitmap != null) {
+ if (bitmap.getWidth() != 1 && bitmap.getHeight() != 1) {
+ holder.binding.setVariable(BR.scaleType, ImageView.ScaleType.FIT_CENTER);
+ holder.binding.setVariable(BR.cover, new BitmapDrawable(VLCApplication.getAppResources(), bitmap));
+ } else
+ holder.binding.setVariable(BR.cover, DEFAULT_COVER);
+ } else {
+ holder.binding.setVariable(BR.cover, DEFAULT_COVER);
+ AsyncImageLoader.LoadVideoCover(new VideoCoverFetcher(media), holder.binding, mFragment.getActivity());
+ }
fillView(holder, media);
@@ -266,7 +275,7 @@ public class VideoListAdapter extends ArrayAdapter<MediaWrapper>
@Override
public Bitmap call() throws Exception {
- return BitmapUtil.getPictureFromCache(media);
+ return BitmapUtil.fetchPicture(media);
}
}
}
More information about the Android
mailing list