aboutsummaryrefslogtreecommitdiff
path: root/app/src/main
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2015-11-16 08:06:09 -0800
committerScott Jackson <daneren2005@gmail.com>2015-11-16 08:06:09 -0800
commit25a67f1f8d186fabd339c711ceef6ad8a0c3d5d5 (patch)
tree652f14c02f4df40e8f400f74ddbc969a1a35de83 /app/src/main
parentb3ef65f64a23ee5eae626bd488c3afe3263aff43 (diff)
downloaddsub-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.java8
-rw-r--r--app/src/main/java/github/daneren2005/dsub/util/Notifications.java1
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) {