Esempio n. 1
0
 /**
  * Sets the current {@link NumericTransformer}
  *
  * @param transformer
  * @see #getNumericTransformer()
  */
 public void setNumericTransformer(@Nullable NumericTransformer transformer) {
   mNumericTransformer = transformer != null ? transformer : new DefaultNumericTransformer();
   // We need to refresh the PopupIndivator view
   if (!isInEditMode()) {
     mIndicator.updateSizes(convertValueToMessage(mNumericTransformer.transform(mMax)));
   }
   updateProgressMessage(mValue);
 }
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();
    }
  }
Esempio n. 3
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);
 }
Esempio n. 4
0
 /**
  * Sets the current Indicator formatter string
  *
  * @param formatter
  * @see String#format(String, Object...)
  * @see #setNumericTransformer(NumericTransformer)
  */
 public void setIndicatorFormatter(@Nullable String formatter) {
   mIndicatorFormatter = formatter;
   updateProgressMessage(mValue);
 }