From af4d2845384c020f02511fc3a4f27af546eec64e Mon Sep 17 00:00:00 2001 From: Chanson <84365252@qq.com> Date: Thu, 19 Apr 2018 21:37:23 +0800 Subject: [PATCH] [bugfix] new TransitionDrawable point to old drawable array, which cause memory leak --- .../at/favre/lib/dali/builder/blur/BlurBuilder.java | 11 +++++++++-- 1 file changed, 9 insertions(+), 2 deletions(-) diff --git a/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java b/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java index b567f00..46e0390 100644 --- a/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java +++ b/dali/src/main/java/at/favre/lib/dali/builder/blur/BlurBuilder.java @@ -8,6 +8,7 @@ import android.graphics.drawable.BitmapDrawable; import android.graphics.drawable.ColorDrawable; import android.graphics.drawable.Drawable; +import android.graphics.drawable.LayerDrawable; import android.graphics.drawable.TransitionDrawable; import android.os.Build; import android.os.Handler; @@ -287,8 +288,14 @@ public void run() { if (data.alphaFadeIn) { //use what is currently in the imageview to fade Drawable placeholder; - if (imageView.getDrawable() != null) { - placeholder = imageView.getDrawable(); + Drawable oldDrawable = imageView.getDrawable(); + if (oldDrawable != null) { + if (oldDrawable instanceof LayerDrawable) { + LayerDrawable oldLayerDrawable = (LayerDrawable) oldDrawable; + placeholder = oldLayerDrawable.getDrawable(0); + } else { + placeholder = imageView.getDrawable(); + } } else { placeholder = new ColorDrawable(Color.parseColor("#00FFFFFF")); }