[Android] [PATCH] Use the icon cache as additional source for cover art
Geoffrey Métais
geoffrey.metais at gmail.com
Mon Nov 7 11:10:55 CET 2016
Referring to last former patch, I'd rather put the retrieval from
*getBitmapFromIconCache()* in *getCoverFromMemCache().*
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
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mailman.videolan.org/pipermail/android/attachments/20161107/fef2a954/attachment-0001.html>
More information about the Android
mailing list