Cache circle cropped photos on Recipient.

This commit is contained in:
Lukas Barth
2014-03-07 00:58:26 +01:00
committed by Moxie Marlinspike
parent fa3cb871d0
commit 7c9282f306
5 changed files with 72 additions and 30 deletions

View File

@@ -19,11 +19,15 @@ import java.util.Map;
public class ContactPhotoFactory {
private static final Object defaultPhotoLock = new Object();
private static final Object defaultGroupPhotoLock = new Object();
private static final Object defaultPhotoLock = new Object();
private static final Object defaultGroupPhotoLock = new Object();
private static final Object defaultPhotoCroppedLock = new Object();
private static final Object defaultGroupPhotoCroppedLock = new Object();
private static Bitmap defaultContactPhoto;
private static Bitmap defaultGroupContactPhoto;
private static Bitmap defaultContactPhotoCropped;
private static Bitmap defaultGroupContactPhotoCropped;
private static final Map<Uri,Bitmap> localUserContactPhotoCache =
Collections.synchronizedMap(new LRUCache<Uri,Bitmap>(2));
@@ -52,6 +56,24 @@ public class ContactPhotoFactory {
}
}
public static Bitmap getDefaultContactPhotoCropped(Context context) {
synchronized (defaultPhotoCroppedLock) {
if (defaultContactPhotoCropped == null)
defaultContactPhotoCropped = BitmapUtil.getCircleCroppedBitmap(getDefaultContactPhoto(context));
return defaultContactPhotoCropped;
}
}
public static Bitmap getDefaultGroupPhotoCropped(Context context) {
synchronized (defaultGroupPhotoCroppedLock) {
if (defaultGroupContactPhotoCropped == null)
defaultGroupContactPhotoCropped = BitmapUtil.getCircleCroppedBitmap(getDefaultGroupPhoto(context));
return defaultGroupContactPhotoCropped;
}
}
public static Bitmap getLocalUserContactPhoto(Context context, Uri uri) {
if (uri == null) return getDefaultContactPhoto(context);