mirror of
https://github.com/oxen-io/session-android.git
synced 2025-06-29 22:58:28 +00:00
Don't release bitmaps managed by Glide, and don't cache group preview avatars.
This commit is contained in:
parent
d2739d52e0
commit
01375b321c
@ -225,8 +225,6 @@ public class LinkPreviewRepository {
|
|||||||
|
|
||||||
Optional<Attachment> thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
|
Optional<Attachment> thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
|
||||||
|
|
||||||
if (bitmap != null) bitmap.recycle();
|
|
||||||
|
|
||||||
callback.onSuccess(new LinkPreview(packUrl, title, thumbnail));
|
callback.onSuccess(new LinkPreview(packUrl, title, thumbnail));
|
||||||
} else {
|
} else {
|
||||||
callback.onError(Error.PREVIEW_NOT_AVAILABLE);
|
callback.onError(Error.PREVIEW_NOT_AVAILABLE);
|
||||||
@ -265,11 +263,9 @@ public class LinkPreviewRepository {
|
|||||||
|
|
||||||
if (AvatarHelper.hasAvatar(context, groupRecord.getRecipientId())) {
|
if (AvatarHelper.hasAvatar(context, groupRecord.getRecipientId())) {
|
||||||
Recipient recipient = Recipient.resolved(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);
|
thumbnail = bitmapToAttachment(bitmap, Bitmap.CompressFormat.WEBP, MediaUtil.IMAGE_WEBP);
|
||||||
|
|
||||||
if (bitmap != null) bitmap.recycle();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onSuccess(new LinkPreview(groupUrl, title, thumbnail));
|
callback.onSuccess(new LinkPreview(groupUrl, title, thumbnail));
|
||||||
|
@ -71,13 +71,17 @@ public final class AvatarUtil {
|
|||||||
requestCircle(GlideApp.with(context).asDrawable(), context, recipient).into(target);
|
requestCircle(GlideApp.with(context).asDrawable(), context, recipient).into(target);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Bitmap loadIconBitmapSquare(@NonNull Context context,
|
public static Bitmap loadIconBitmapSquareNoCache(@NonNull Context context,
|
||||||
@NonNull Recipient recipient,
|
@NonNull Recipient recipient,
|
||||||
int width,
|
int width,
|
||||||
int height)
|
int height)
|
||||||
throws ExecutionException, InterruptedException
|
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
|
@WorkerThread
|
||||||
|
Loading…
x
Reference in New Issue
Block a user