From a2d63d117bd52333c639da1ba5633ea0fccd6311 Mon Sep 17 00:00:00 2001 From: Jake McGinty Date: Fri, 24 Jul 2015 14:04:56 -0700 Subject: [PATCH] fix rounded corners memory thrash // FREEBIE --- src/org/thoughtcrime/securesms/mms/RoundedCorners.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/org/thoughtcrime/securesms/mms/RoundedCorners.java b/src/org/thoughtcrime/securesms/mms/RoundedCorners.java index 3a3485baad..594876069d 100644 --- a/src/org/thoughtcrime/securesms/mms/RoundedCorners.java +++ b/src/org/thoughtcrime/securesms/mms/RoundedCorners.java @@ -10,6 +10,7 @@ import android.graphics.RectF; import android.graphics.Shader.TileMode; import android.support.annotation.NonNull; import android.support.annotation.Nullable; +import android.util.Log; import com.bumptech.glide.load.engine.bitmap_recycle.BitmapPool; import com.bumptech.glide.load.resource.bitmap.BitmapTransformation; @@ -32,7 +33,11 @@ public class RoundedCorners extends BitmapTransformation { { final Bitmap toRound = crop ? centerCrop(pool, toTransform, outWidth, outHeight) : fitCenter(pool, toTransform, outWidth, outHeight); - return round(pool, toRound); + final Bitmap rounded = round(pool, toRound); + if (toRound != null && toRound != rounded && !pool.put(toRound)) { + toRound.recycle(); + } + return rounded; } private Bitmap centerCrop(BitmapPool pool, Bitmap toTransform, int outWidth, int outHeight) {