diff options
author | Scott Jackson <daneren2005@gmail.com> | 2013-05-25 21:59:27 -0700 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2013-05-25 21:59:27 -0700 |
commit | d5175ab650ed2bc86005c1a2228021f934f37fd6 (patch) | |
tree | 22b8f7f2ae1f74670f30a3a08cd6242481ece9af | |
parent | 8c98ee5aca5340e0dd79aa52e3edff00f418dc54 (diff) | |
parent | ab3d6f40332e8abaf5c6f4010071b87db5a3c8e9 (diff) | |
download | dsub-d5175ab650ed2bc86005c1a2228021f934f37fd6.tar.gz dsub-d5175ab650ed2bc86005c1a2228021f934f37fd6.tar.bz2 dsub-d5175ab650ed2bc86005c1a2228021f934f37fd6.zip |
Merge branch 'master' of https://github.com/daneren2005/Subsonic.git
-rw-r--r-- | subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java | 17 |
1 files changed, 13 insertions, 4 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java index 61f20c0a..f84116f7 100644 --- a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java +++ b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java @@ -56,6 +56,7 @@ public class ImageLoader implements Runnable { private Handler mHandler = new Handler(); private Context context; private LruCache<String, Bitmap> cache; + private Bitmap nowPlaying; private final BlockingQueue<Task> queue; private final int imageSizeDefault; private final int imageSizeLarge; @@ -73,7 +74,7 @@ public class ImageLoader implements Runnable { @Override protected void entryRemoved(boolean evicted, String key, Bitmap oldBitmap, Bitmap newBitmap) { - if(evicted) { + if(evicted && oldBitmap != nowPlaying) { oldBitmap.recycle(); } } @@ -110,13 +111,16 @@ public class ImageLoader implements Runnable { if (bitmap != null) { final Drawable drawable = Util.createDrawableFromBitmap(this.context, bitmap); setImage(view, drawable, large); + if(large) { + nowPlaying = bitmap; + } return; } if (!large) { setUnknownImage(view, large); } - queue.offer(new Task(view.getContext(), entry, size, imageSizeLarge, new ViewTaskHandler(view, crossfade))); + queue.offer(new Task(view.getContext(), entry, size, imageSizeLarge, large, new ViewTaskHandler(view, crossfade))); } public void loadImage(Context context, RemoteControlClient remoteControl, MusicDirectory.Entry entry) { @@ -133,7 +137,7 @@ public class ImageLoader implements Runnable { } setUnknownImage(remoteControl); - queue.offer(new Task(context, entry, imageSizeLarge, imageSizeLarge, new RemoteControlClientTaskHandler(remoteControl))); + queue.offer(new Task(context, entry, imageSizeLarge, imageSizeLarge, false, new RemoteControlClientTaskHandler(remoteControl))); } private String getKey(String coverArtId, int size) { @@ -228,13 +232,15 @@ public class ImageLoader implements Runnable { private final MusicDirectory.Entry mEntry; private final int mSize; private final int mSaveSize; + private final boolean mIsNowPlaying; private ImageLoaderTaskHandler mTaskHandler; - public Task(Context context, MusicDirectory.Entry entry, int size, int saveSize, ImageLoaderTaskHandler taskHandler) { + public Task(Context context, MusicDirectory.Entry entry, int size, int saveSize, boolean isNowPlaying, ImageLoaderTaskHandler taskHandler) { mContext = context; mEntry = entry; mSize = size; mSaveSize = saveSize; + mIsNowPlaying = isNowPlaying; mTaskHandler = taskHandler; } @@ -255,6 +261,9 @@ public class ImageLoader implements Runnable { cache.put(key, bitmap); // Make sure key is the most recently "used" cache.get(key); + if(mIsNowPlaying) { + nowPlaying = bitmap; + } final Drawable drawable = Util.createDrawableFromBitmap(mContext, bitmap); mTaskHandler.setDrawable(drawable); |