예제 #1
0
  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();
  }
예제 #2
0
  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();
    }
  }
예제 #3
0
 boolean isAnimationRunning() {
   return mPositionAnimator != null && mPositionAnimator.isRunning();
 }