[Android] [PATCH] Use the icon cache as additional source for cover art
Marc K.
morckx at gmail.com
Mon Nov 7 13:39:28 CET 2016
On Mon, 2016-11-07 at 10:10 +0000, Geoffrey Métais wrote:
> Referring to last former patch, I'd rather put the retrieval
> from getBitmapFromIconCache() in getCoverFromMemCache().
>
Let me make sure I understand you correctly. Do you mean:
a) call HttpImageLoader.getBitmapFromIconCache from inside
getCoverFromMemCache
b) access the icon map directly from getCoverFromMemCache
c) integrate the icon map in HttpImageLoader with the MemCache
?
a) would make sense to me. (c) only done partially would be a little
bit clumsy (different keys) and to do it thoroughly it would be good to
have a plan of how to fully integrate the network browser with the
audio browser and its recent developments – which might be some work.
> On Mon, Nov 7, 2016 at 10:04 AM Marc K <morckx at gmail.com> wrote:
> > This fixes showing the cover art of network media if it was
> > previously
> > shown as icon in the browser,
> >
> > Signed-off-by: Marc K <morckx at gmail.com>
> > ---
> > vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java | 7
> > +++++--
> > vlc-android/src/org/videolan/vlc/util/HttpImageLoader.java | 11
> > +++++++++--
> > 2 files changed, 14 insertions(+), 4 deletions(-)
> >
> > diff --git a/vlc-
> > android/src/org/videolan/vlc/gui/helpers/AudioUtil.java b/vlc-
> > android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
> > index 846f996..022387a 100644
> > --- a/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
> > +++ b/vlc-android/src/org/videolan/vlc/gui/helpers/AudioUtil.java
> > @@ -42,6 +42,7 @@ import org.videolan.vlc.R;
> > import org.videolan.vlc.VLCApplication;
> > import org.videolan.vlc.media.MediaUtils;
> > import org.videolan.vlc.util.AndroidDevices;
> > +import org.videolan.vlc.util.HttpImageLoader;
> > import org.videolan.vlc.util.MurmurHash;
> > import org.videolan.vlc.util.Permissions;
> > import org.videolan.vlc.util.Util;
> > @@ -322,8 +323,6 @@ public class AudioUtil {
> > if (cacheFile.exists()) {
> > if (cacheFile.length() > 0)
> > coverPath = cachePath;
> > - else
> > - return null;
> > }
> > }
> >
> > @@ -342,6 +341,10 @@ public class AudioUtil {
> > // read (and scale?) the bitmap
> > cover = readCoverBitmap(coverPath, width);
> >
> > + // as last resort try to get the cover from the icon
> > cache
> > + if (cover == null && media.getArtworkURL() != null)
> > + cover =
> > HttpImageLoader.getBitmapFromIconCache(media.getArtworkURL());
> > +
> > // store cover into both cache
> > if (cachePath != null) {
> > writeBitmap(cover, cachePath);
> > diff --git a/vlc-
> > android/src/org/videolan/vlc/util/HttpImageLoader.java b/vlc-
> > android/src/org/videolan/vlc/util/HttpImageLoader.java
> > index a0cf59e..8810408 100644
> > --- a/vlc-android/src/org/videolan/vlc/util/HttpImageLoader.java
> > +++ b/vlc-android/src/org/videolan/vlc/util/HttpImageLoader.java
> > @@ -95,7 +95,7 @@ public class HttpImageLoader implements Callbacks
> > {
> > }
> >
> > @Nullable
> > - public static Bitmap downloadBitmap(String imageUrl) {
> > + public static Bitmap getBitmapFromIconCache(String imageUrl) {
> > if (iconsMap.containsKey(imageUrl)) {
> > Bitmap bd = iconsMap.get(imageUrl).get();
> > if (bd != null) {
> > @@ -103,8 +103,15 @@ public class HttpImageLoader implements
> > Callbacks {
> > } else
> > iconsMap.remove(imageUrl);
> > }
> > + return null;
> > + }
> > +
> > + @Nullable
> > + public static Bitmap downloadBitmap(String imageUrl) {
> > HttpURLConnection urlConnection = null;
> > - Bitmap icon = null;
> > + Bitmap icon = getBitmapFromIconCache(imageUrl);
> > + if (icon != null)
> > + return icon;
> > try {
> > URL url = new URL(imageUrl);
> > if (url.getPort() <= 0)
> > --
> > 2.9.3
> >
> > _______________________________________________
> > Android mailing list
> > Android at videolan.org
> > https://mailman.videolan.org/listinfo/android
> >
>
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
More information about the Android
mailing list