Only cache small images so that they are not kicked out by big images
Bug:6202229
Change-Id: I593a575a2f65cebd3cc126d5b734887e02dacc50
diff --git a/src/com/android/contacts/ContactPhotoManager.java b/src/com/android/contacts/ContactPhotoManager.java
index 4286293..5b6a1ca 100644
--- a/src/com/android/contacts/ContactPhotoManager.java
+++ b/src/com/android/contacts/ContactPhotoManager.java
@@ -582,8 +582,11 @@
view.setImageBitmap(cachedBitmap);
}
- // Put the bitmap in the LRU cache
- mBitmapCache.put(request.getKey(), cachedBitmap);
+ // Put the bitmap in the LRU cache. But only do this for images that are small enough
+ // (we require that at least six of those can be cached at the same time)
+ if (cachedBitmap.getByteCount() < mBitmapCache.maxSize() / 6) {
+ mBitmapCache.put(request.getKey(), cachedBitmap);
+ }
// Soften the reference
holder.bitmap = null;