Skip to content

Commit

Permalink
remove listener when animate end
Browse files Browse the repository at this point in the history
  • Loading branch information
wing committed Oct 20, 2016
1 parent 2143edb commit 5c45bd2
Showing 1 changed file with 4 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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();
Expand All @@ -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) {
Expand Down Expand Up @@ -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();
Expand All @@ -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) {
Expand Down

0 comments on commit 5c45bd2

Please sign in to comment.