From da78c911a0d9164a49f27643819faeb006a0d62c Mon Sep 17 00:00:00 2001 From: "jerry.cai" Date: Wed, 27 Jul 2016 15:58:35 +0800 Subject: [PATCH] fix bug when user taps start to show progress, and then stop it immediately, the progress can't not be stopped --- .../progressarc/ProgressArcView.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/library/src/main/java/com/github/jorgecastilloprz/progressarc/ProgressArcView.java b/library/src/main/java/com/github/jorgecastilloprz/progressarc/ProgressArcView.java index ae68442..d52e1a5 100644 --- a/library/src/main/java/com/github/jorgecastilloprz/progressarc/ProgressArcView.java +++ b/library/src/main/java/com/github/jorgecastilloprz/progressarc/ProgressArcView.java @@ -38,6 +38,12 @@ public final class ProgressArcView extends ProgressBar { private int arcColor; private int arcWidth; private boolean roundedStroke; + private Runnable animationRunnable = new Runnable() { + public void run() { + ProgressArcView.this.setAlpha(1.0F); + ProgressArcView.this.getDrawable().reset(); + } + }; public ProgressArcView(Context context, int arcColor, int arcWidth, boolean roundedStroke) { super(context); @@ -62,15 +68,11 @@ public void setInternalListener(ArcListener internalListener) { } public void show() { - postDelayed(new Runnable() { - @Override public void run() { - setAlpha(1); - getDrawable().reset(); - } - }, SHOW_SCALE_ANIM_DELAY); + postDelayed(animationRunnable, SHOW_SCALE_ANIM_DELAY); } public void stop() { + removeCallbacks(animationRunnable); getDrawable().stop(); ValueAnimator fadeOutAnim = ObjectAnimator.ofFloat(this, "alpha", 1, 0); fadeOutAnim.setDuration(100).start();