From e455e6d841cd39c72efa983eb35b87bc8e4cc0e5 Mon Sep 17 00:00:00 2001 From: Alex Quinlivan Date: Fri, 25 Feb 2022 19:30:49 +1300 Subject: [PATCH] Remove maskElements array and remove all ShimmerContainer children on setLayout MaskElements was an array that was seemingly unused, but multiple calls to setLayout would retain all previously held views and append the new views as well. ShimmerContainer would eventually grow in size as multiple setLayout calls were made. This can be remedied by removing all the views contained on setLayout. --- .../src/main/java/com/skydoves/androidveil/VeilLayout.kt | 3 +-- 1 file changed, 1 insertion(+), 2 deletions(-) diff --git a/androidveil/src/main/java/com/skydoves/androidveil/VeilLayout.kt b/androidveil/src/main/java/com/skydoves/androidveil/VeilLayout.kt index 24b9dd8..762d981 100644 --- a/androidveil/src/main/java/com/skydoves/androidveil/VeilLayout.kt +++ b/androidveil/src/main/java/com/skydoves/androidveil/VeilLayout.kt @@ -79,7 +79,6 @@ class VeilLayout : FrameLayout { var isVeiled = false private set - private val maskElements = ArrayList() val shimmerContainer = ShimmerFrameLayout(context) val nonShimmer = Shimmer.AlphaHighlightBuilder().setBaseAlpha(1.0f).setDropoff(1.0f).build() var shimmer = Shimmer.AlphaHighlightBuilder().build() @@ -174,6 +173,7 @@ class VeilLayout : FrameLayout { fun setLayout(layout: View) { removeAllViews() addView(layout) + shimmerContainer.removeAllViews() onFinishInflate() } @@ -224,7 +224,6 @@ class VeilLayout : FrameLayout { setColor(Color.DKGRAY) cornerRadius = radius } - maskElements.add(this) shimmerContainer.addView(this) } }