Commit abe1204a authored by mengcuiguang's avatar mengcuiguang

解决首页内存泄漏

parent 12f9ab31
......@@ -331,7 +331,9 @@ public class CircleProgress extends View {
}
private void startAnimator(float start, float end, long animTime) {
mAnimator = ValueAnimator.ofFloat(start, end);
if (mAnimator == null) {
mAnimator = ValueAnimator.ofFloat(start, end);
}
mAnimator.setDuration(animTime);
mAnimator.addUpdateListener(new ValueAnimator.AnimatorUpdateListener() {
@Override
......
......@@ -123,7 +123,9 @@ public class CycleProgress extends View {
delta = delta == 0 ? 1 : delta;
mProgressWidth = (int) (progress * mViewWidth);
mAnimator = ValueAnimator.ofFloat(0, progress).setDuration(delta * DURATION);
if (mAnimator == null) {
mAnimator = ValueAnimator.ofFloat(0, progress).setDuration(delta * DURATION);
}
mAnimator.setRepeatCount(ValueAnimator.INFINITE);
ValueAnimator.AnimatorUpdateListener mUpdateListener = animation -> {
......@@ -136,16 +138,13 @@ public class CycleProgress extends View {
}
public void resumeAnim() {
if (mAnimator != null) {
mAnimator.resume();
} else {
startAnim();
}
startAnim();
}
public void pauseAnim() {
if (mAnimator != null) {
mAnimator.pause();
mAnimator.cancel();
mAnimator.removeAllUpdateListeners();
}
}
}
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment