From 5c45bd2abbc5a08382c718fc9d506ab773191167 Mon Sep 17 00:00:00 2001 From: wing Date: Thu, 20 Oct 2016 11:26:55 +0800 Subject: [PATCH] remove listener when animate end --- .../main/java/com/wingsofts/threedlayout/ThreeDLayout.java | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/threedlayout/src/main/java/com/wingsofts/threedlayout/ThreeDLayout.java b/threedlayout/src/main/java/com/wingsofts/threedlayout/ThreeDLayout.java index 015b40c..0e0296c 100644 --- a/threedlayout/src/main/java/com/wingsofts/threedlayout/ThreeDLayout.java +++ b/threedlayout/src/main/java/com/wingsofts/threedlayout/ThreeDLayout.java @@ -246,7 +246,7 @@ public void setMaxRotateDegree(int degree) { * start horizontal turn animate */ public void startHorizontalAnimate(long duration) { - ValueAnimator animator = ValueAnimator.ofFloat(-180f, 0f); + final ValueAnimator animator = ValueAnimator.ofFloat(-180f, 0f); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mDegreeY = (float) animation.getAnimatedValue(); @@ -260,6 +260,7 @@ public void startHorizontalAnimate(long duration) { @Override public void onAnimationEnd(Animator animation) { mDegreeY = 0; + animator.removeAllUpdateListeners(); } @Override public void onAnimationCancel(Animator animation) { @@ -300,7 +301,7 @@ public void startHorizontalAnimateDelayed(final long delayed, final long duratio * start vertical turn animate */ public void startVerticalAnimate(long duration) { - ValueAnimator animator = ValueAnimator.ofFloat(-180f, 0f); + final ValueAnimator animator = ValueAnimator.ofFloat(-180f, 0f); animator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() { @Override public void onAnimationUpdate(ValueAnimator animation) { mDegreeX = (float) animation.getAnimatedValue(); @@ -314,6 +315,7 @@ public void startVerticalAnimate(long duration) { @Override public void onAnimationEnd(Animator animation) { mDegreeX = 0; + animator.removeAllUpdateListeners(); } @Override public void onAnimationCancel(Animator animation) {