void animateSetProgress(int progress) { final float curProgress = isAnimationRunning() ? getAnimationPosition() : getProgress(); if (progress < mMin) { progress = mMin; } else if (progress > mMax) { progress = mMax; } // setProgressValueOnly(progress); if (mPositionAnimator != null) { mPositionAnimator.cancel(); } mAnimationTarget = progress; mPositionAnimator = AnimatorCompat.create( curProgress, progress, new AnimatorCompat.AnimationFrameUpdateListener() { @Override public void onAnimationFrame(float currentValue) { setAnimationPosition(currentValue); } }); mPositionAnimator.setDuration(PROGRESS_ANIMATION_DURATION); mPositionAnimator.start(); }
private void setProgress(int value, boolean fromUser) { value = Math.max(mMin, Math.min(mMax, value)); if (isAnimationRunning()) { mPositionAnimator.cancel(); } if (mValue != value) { mValue = value; notifyProgress(value, fromUser); updateProgressMessage(value); updateThumbPosFromCurrentProgress(); } }
boolean isAnimationRunning() { return mPositionAnimator != null && mPositionAnimator.isRunning(); }