Ejemplo n.º 1
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();
    }
  }
Ejemplo n.º 2
0
 private void updateProgressFromAnimation(float scale) {
   Rect bounds = mThumb.getBounds();
   int halfThumb = bounds.width() / 2;
   int addedThumb = mAddedTouchBounds;
   int left = getPaddingLeft() + halfThumb + addedThumb;
   int right = getWidth() - (getPaddingRight() + halfThumb + addedThumb);
   int available = right - left;
   int progress = Math.round((scale * (mMax - mMin)) + mMin);
   // we don't want to just call setProgress here to avoid the animation
   // being cancelled,
   // and this position is not bound to a real progress value but
   // interpolated
   if (progress != getProgress()) {
     mValue = progress;
     notifyProgress(mValue, true);
     updateProgressMessage(progress);
   }
   final int thumbPos = (int) (scale * available + 0.5f);
   updateThumbPos(thumbPos);
 }