[Android] [PATCH] Use the icon cache as additional source for cover art
Geoffrey Métais
geoffrey.metais at gmail.com
Wed Nov 9 18:03:54 CET 2016
b)
Player image should be sourced from getCoverFromMemCache, because it's
called from mainThread.
So, getCoverFromMemCache should look at HttpImageLoader if image url starts
with "http" => Which could lead to c)
On Mon, Nov 7, 2016 at 1:39 PM Marc K. <morckx at gmail.com> wrote:
> 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
> _______________________________________________
> Android mailing list
> Android at videolan.org
> https://mailman.videolan.org/listinfo/android
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20161109/31c5627e/attachment-0001.html>
More information about the Android
mailing list