From 625e02efae48be25785d6d7dbba7a8125b3cc84d Mon Sep 17 00:00:00 2001 From: qgnie <32289765+qgnie@users.noreply.github.com> Date: Wed, 23 Dec 2020 10:15:00 +0800 Subject: [PATCH] fix not remove GlobalLayoutListener If not, it will execute expand animation many times, and will leak --- .../main/java/com/brucetoo/pinterestview/PinterestView.java | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/com/brucetoo/pinterestview/PinterestView.java b/app/src/main/java/com/brucetoo/pinterestview/PinterestView.java index 1fa3db7..3001c97 100644 --- a/app/src/main/java/com/brucetoo/pinterestview/PinterestView.java +++ b/app/src/main/java/com/brucetoo/pinterestview/PinterestView.java @@ -348,6 +348,7 @@ private void bindChildAnimation(final View child, final int position) { child.getViewTreeObserver().addOnGlobalLayoutListener(new ViewTreeObserver.OnGlobalLayoutListener() { @Override public void onGlobalLayout() { + child.getViewTreeObserver().removeOnGlobalLayoutListener(this); Rect childRect = getChildDisPlayBounds(child); if (mExpanded) { expandAnimation(child, childRect); @@ -511,4 +512,4 @@ interface PinMenuClickListener { */ void onAnchorViewClick(); } -} \ No newline at end of file +}