aboutsummaryrefslogtreecommitdiff
path: root/src/github
diff options
context:
space:
mode:
authorScott Jackson <daneren2005@gmail.com>2013-11-30 10:42:28 -0800
committerScott Jackson <daneren2005@gmail.com>2013-11-30 10:42:28 -0800
commitaf57cc541d24bd7bfa792e1ea75f343be4f0ffb4 (patch)
treee49354628065bb3cc28087eee5f2b3efee40f441 /src/github
parent14542ac3d39435011384cef3ffd5c61fa8af8c34 (diff)
downloaddsub-af57cc541d24bd7bfa792e1ea75f343be4f0ffb4.tar.gz
dsub-af57cc541d24bd7bfa792e1ea75f343be4f0ffb4.tar.bz2
dsub-af57cc541d24bd7bfa792e1ea75f343be4f0ffb4.zip
Fix #197 RemoteControlClient recycles bitmaps on it's own
Diffstat (limited to 'src/github')
-rw-r--r--src/github/daneren2005/dsub/util/ImageLoader.java15
1 files changed, 10 insertions, 5 deletions
diff --git a/src/github/daneren2005/dsub/util/ImageLoader.java b/src/github/daneren2005/dsub/util/ImageLoader.java
index 42143d3a..9e9875aa 100644
--- a/src/github/daneren2005/dsub/util/ImageLoader.java
+++ b/src/github/daneren2005/dsub/util/ImageLoader.java
@@ -25,6 +25,7 @@ import android.graphics.drawable.BitmapDrawable;
import android.graphics.drawable.Drawable;
import android.graphics.drawable.TransitionDrawable;
import android.media.RemoteControlClient;
+import android.os.Build;
import android.os.Handler;
import android.util.DisplayMetrics;
import android.util.Log;
@@ -75,7 +76,7 @@ public class ImageLoader implements Runnable {
protected void entryRemoved(boolean evicted, String key, Bitmap oldBitmap, Bitmap newBitmap) {
if(evicted) {
if(oldBitmap != nowPlaying) {
- // oldBitmap.recycle();
+ oldBitmap.recycle();
} else {
cache.put(key, oldBitmap);
}
@@ -131,8 +132,9 @@ public class ImageLoader implements Runnable {
}
public void loadImage(Context context, RemoteControlClient remoteControl, MusicDirectory.Entry entry) {
- if (largeUnknownImage != null && ((BitmapDrawable)largeUnknownImage).getBitmap().isRecycled())
- createLargeUnknownImage(context);
+ if (largeUnknownImage != null && ((BitmapDrawable)largeUnknownImage).getBitmap().isRecycled()) {
+ createLargeUnknownImage(context);
+ }
if (entry == null || entry.getCoverArt() == null) {
setUnknownImage(remoteControl);
@@ -199,13 +201,16 @@ public class ImageLoader implements Runnable {
private void setImage(RemoteControlClient remoteControl, Drawable drawable) {
if(remoteControl != null && drawable != null) {
Bitmap origBitmap = ((BitmapDrawable)drawable).getBitmap();
+ if(Build.VERSION.SDK_INT > Build.VERSION_CODES.JELLY_BEAN_MR2) {
+ origBitmap = origBitmap.copy(origBitmap.getConfig(), false);
+ }
if ( origBitmap != null && !origBitmap.isRecycled()) {
remoteControl.editMetadata(false).putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, origBitmap).apply();
} else {
Log.e(TAG, "Tried to load a recycled bitmap.");
remoteControl.editMetadata(false)
- .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, null)
- .apply();
+ .putBitmap(RemoteControlClient.MetadataEditor.BITMAP_KEY_ARTWORK, null)
+ .apply();
}
}
}