[Android] Speed up image loading
Geoffrey Métais
git at videolan.org
Fri Feb 24 16:32:09 CET 2017
vlc-android | branch: master | Geoffrey Métais <geoffrey.metais at gmail.com> | Fri Feb 24 16:27:42 2017 +0100| [e37b98660f21ace9d944c53cb2458b85cd48637f] | committer: Geoffrey Métais
Speed up image loading
> https://code.videolan.org/videolan/vlc-android/commit/e37b98660f21ace9d944c53cb2458b85cd48637f
---
.../org/videolan/vlc/gui/helpers/AsyncImageLoader.java | 18 ++++++++++--------
1 file changed, 10 insertions(+), 8 deletions(-)
diff --git a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
index b7c0d46..33c760f 100644
--- a/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
+++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AsyncImageLoader.java
@@ -85,9 +85,16 @@ public class AsyncImageLoader {
@BindingAdapter({"media"})
public static void loadPicture(View v, MediaLibraryItem item) {
- if (item == null)
+ if (item == null || TextUtils.isEmpty(item.getArtworkMrl())
+ || item.getItemType() == MediaLibraryItem.TYPE_GENRE
+ || item.getItemType() == MediaLibraryItem.TYPE_PLAYLIST)
return;
- if (item instanceof MediaWrapper) {
+ final Bitmap bitmap = BitmapCache.getInstance().getBitmapFromMemCache(item.getArtworkMrl());
+ if (bitmap != null) {
+ updateTargetImage(bitmap, v, DataBindingUtil.findBinding(v));
+ return;
+ }
+ if (item.getItemType() == MediaLibraryItem.TYPE_MEDIA) {
if (item instanceof MediaGroup)
item = ((MediaGroup) item).getFirstMedia();
int type = ((MediaWrapper) item).getType();
@@ -100,11 +107,6 @@ public class AsyncImageLoader {
if (mw != null)
item = mw;
}
- final Bitmap bitmap = type == MediaWrapper.TYPE_VIDEO ? BitmapUtil.getPictureFromCache((MediaWrapper) item) : null;
- if (bitmap != null) {
- updateTargetImage(bitmap, v, DataBindingUtil.findBinding(v));
- return;
- }
}
AsyncImageLoader.LoadImage(new MLItemCoverFetcher(v, item), v);
}
@@ -136,7 +138,7 @@ public class AsyncImageLoader {
String artworkUrl = item.getArtworkMrl();
if (!TextUtils.isEmpty(artworkUrl) && artworkUrl.startsWith("http"))
return HttpImageLoader.downloadBitmap(artworkUrl);
- return AudioUtil.readCoverBitmap(Strings.removeFileProtocole(Uri.decode(item.getArtworkMrl())), width);
+ return AudioUtil.readCoverBitmap(Strings.removeFileProtocole(item.getArtworkMrl()), width);
}
@Override
More information about the Android
mailing list