Don't release bitmaps managed by Glide, and don't cache group preview avatars.
parent
d2739d52e0
commit
01375b321c
|
@ -225,8 +225,6 @@ public class LinkPreviewRepository {
|
|||
|
||||
Optional<Attachment> thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
|
||||
|
||||
if (bitmap != null) bitmap.recycle();
|
||||
|
||||
callback.onSuccess(new LinkPreview(packUrl, title, thumbnail));
|
||||
} else {
|
||||
callback.onError(Error.PREVIEW_NOT_AVAILABLE);
|
||||
|
@ -265,11 +263,9 @@ public class LinkPreviewRepository {
|
|||
|
||||
if (AvatarHelper.hasAvatar(context, groupRecord.getRecipientId())) {
|
||||
Recipient recipient = Recipient.resolved(groupRecord.getRecipientId());
|
||||
Bitmap bitmap = AvatarUtil.loadIconBitmapSquare(context, recipient, 512, 512);
|
||||
Bitmap bitmap = AvatarUtil.loadIconBitmapSquareNoCache(context, recipient, 512, 512);
|
||||
|
||||
thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
|
||||
|
||||
if (bitmap != null) bitmap.recycle();
|
||||
}
|
||||
|
||||
callback.onSuccess(new LinkPreview(groupUrl, title, thumbnail));
|
||||
|
|
|
@ -71,13 +71,17 @@ public final class AvatarUtil {
|
|||
requestCircle(GlideApp.with(context).asDrawable(), context, recipient).into(target);
|
||||
}
|
||||
|
||||
public static Bitmap loadIconBitmapSquare(@NonNull Context context,
|
||||
@NonNull Recipient recipient,
|
||||
int width,
|
||||
int height)
|
||||
public static Bitmap loadIconBitmapSquareNoCache(@NonNull Context context,
|
||||
@NonNull Recipient recipient,
|
||||
int width,
|
||||
int height)
|
||||
throws ExecutionException, InterruptedException
|
||||
{
|
||||
return requestSquare(GlideApp.with(context).asBitmap(), context, recipient).submit(width, height).get();
|
||||
return requestSquare(GlideApp.with(context).asBitmap(), context, recipient)
|
||||
.skipMemoryCache(true)
|
||||
.diskCacheStrategy(DiskCacheStrategy.NONE)
|
||||
.submit(width, height)
|
||||
.get();
|
||||
}
|
||||
|
||||
@WorkerThread
|
||||
|
|
Loading…
Reference in New Issue