Exemplo n.º 1
0
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);
    int thumbWidth = mThumb.getIntrinsicWidth();
    int thumbHeight = mThumb.getIntrinsicHeight();
    int addedThumb = mAddedTouchBounds;
    int halfThumb = thumbWidth / 2;
    int paddingLeft = getPaddingLeft() + addedThumb;
    int paddingRight = getPaddingRight();
    int bottom = getHeight() - getPaddingBottom() - addedThumb;
    mThumb.setBounds(paddingLeft, bottom - thumbHeight, paddingLeft + thumbWidth, bottom);
    int trackHeight = Math.max(mTrackHeight / 2, 1);
    mTrack.setBounds(
        paddingLeft + halfThumb,
        bottom - halfThumb - trackHeight,
        getWidth() - halfThumb - paddingRight - addedThumb,
        bottom - halfThumb + trackHeight);
    int scrubberHeight = Math.max(mScrubberHeight / 2, 2);
    mScrubber.setBounds(
        paddingLeft + halfThumb,
        bottom - halfThumb - scrubberHeight,
        paddingLeft + halfThumb,
        bottom - halfThumb + scrubberHeight);

    // Update the thumb position after size changed
    updateThumbPosFromCurrentProgress();
  }
Exemplo 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();
    }
  }