Esempio n. 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();
  }
Esempio n. 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();
    }
  }