aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authordaneren2005 <daneren2005@gmail.com>2013-02-21 16:13:09 -0800
committerdaneren2005 <daneren2005@gmail.com>2013-02-21 16:13:09 -0800
commitf03006ac5a13522085753c69562ea5c23f911309 (patch)
treeff799f86e1ea9bac513e57ce86f975905b0c503d
parent52e389588f7c7403d2619db18631a959b877724a (diff)
downloaddsub-f03006ac5a13522085753c69562ea5c23f911309.tar.gz
dsub-f03006ac5a13522085753c69562ea5c23f911309.tar.bz2
dsub-f03006ac5a13522085753c69562ea5c23f911309.zip
Attempt to fix both oom and recycled errors
-rw-r--r--subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java7
1 files changed, 5 insertions, 2 deletions
diff --git a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java
index 4c3b256b..8e014afe 100644
--- a/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java
+++ b/subsonic-android/src/github/daneren2005/dsub/util/ImageLoader.java
@@ -64,7 +64,7 @@ public class ImageLoader implements Runnable {
public ImageLoader(Context context) {
this.context = context;
final int maxMemory = (int) (Runtime.getRuntime().maxMemory() / 1024);
- final int cacheSize = maxMemory / 2;
+ final int cacheSize = maxMemory / 4;
cache = new LruCache<String, Bitmap>(cacheSize) {
@Override
protected int sizeOf(String key, Bitmap bitmap) {
@@ -253,7 +253,10 @@ public class ImageLoader implements Runnable {
try {
MusicService musicService = MusicServiceFactory.getMusicService(mContext);
Bitmap bitmap = musicService.getCoverArt(mContext, mEntry, mSize, mSaveSize, null);
- cache.put(getKey(mEntry.getCoverArt(), mSize), bitmap);
+ String key = getKey(mEntry.getCoverArt(), mSize);
+ cache.put(key, bitmap);
+ // Make sure key is the most recently "used"
+ cache.get(key);
final Drawable drawable = Util.createDrawableFromBitmap(mContext, bitmap);
mTaskHandler.setDrawable(drawable);