diff options
author | Scott Jackson <daneren2005@gmail.com> | 2015-11-16 08:06:09 -0800 |
---|---|---|
committer | Scott Jackson <daneren2005@gmail.com> | 2015-11-16 08:06:09 -0800 |
commit | 25a67f1f8d186fabd339c711ceef6ad8a0c3d5d5 (patch) | |
tree | 652f14c02f4df40e8f400f74ddbc969a1a35de83 /app/src/main | |
parent | b3ef65f64a23ee5eae626bd488c3afe3263aff43 (diff) | |
download | dsub-25a67f1f8d186fabd339c711ceef6ad8a0c3d5d5.tar.gz dsub-25a67f1f8d186fabd339c711ceef6ad8a0c3d5d5.tar.bz2 dsub-25a67f1f8d186fabd339c711ceef6ad8a0c3d5d5.zip |
Keep bitmaps in the notification from being recycled
Diffstat (limited to 'app/src/main')
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java | 8 | ||||
-rw-r--r-- | app/src/main/java/github/daneren2005/dsub/util/Notifications.java | 1 |
2 files changed, 8 insertions, 1 deletions
diff --git a/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java b/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java index 4ba72960..5da66023 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java +++ b/app/src/main/java/github/daneren2005/dsub/util/ImageLoader.java @@ -64,6 +64,7 @@ public class ImageLoader { private LruCache<String, Bitmap> cache; private Handler handler; private Bitmap nowPlaying; + private Bitmap nowPlayingSmall; private final int imageSizeDefault; private final int imageSizeLarge; private final int avatarSizeDefault; @@ -93,7 +94,7 @@ public class ImageLoader { @Override protected void entryRemoved(boolean evicted, String key, Bitmap oldBitmap, Bitmap newBitmap) { if(evicted) { - if(oldBitmap != nowPlaying || clearingCache) { + if((oldBitmap != nowPlaying && oldBitmap != nowPlayingSmall) || clearingCache) { oldBitmap.recycle(); } else { cache.put(key, oldBitmap); @@ -105,6 +106,7 @@ public class ImageLoader { public void clearCache() { nowPlaying = null; + nowPlayingSmall = null; new SilentBackgroundTask<Void>(context) { @Override protected Void doInBackground() throws Throwable { @@ -126,6 +128,10 @@ public class ImageLoader { } } + public void setNowPlayingSmall(Bitmap bitmap) { + nowPlayingSmall = bitmap; + } + private Bitmap getUnknownImage(MusicDirectory.Entry entry, int size) { String key; int color; diff --git a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java index 499e2189..375c9966 100644 --- a/app/src/main/java/github/daneren2005/dsub/util/Notifications.java +++ b/app/src/main/java/github/daneren2005/dsub/util/Notifications.java @@ -135,6 +135,7 @@ public final class Notifications { // set default album art rv.setImageViewResource(R.id.notification_image, R.drawable.unknown_album); } else { + imageLoader.setNowPlayingSmall(bitmap); rv.setImageViewBitmap(R.id.notification_image, bitmap); } } catch (Exception x) { |