mirror of
https://github.com/oxen-io/session-android.git
synced 2025-10-25 13:58:40 +00:00
Cache circle cropped photos on Recipient.
This commit is contained in:
committed by
Moxie Marlinspike
parent
fa3cb871d0
commit
7c9282f306
@@ -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);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user