@Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    super.onSizeChanged(w, h, oldw, oldh);

    // Cache the view bounds.
    mCachedBounds.set(0, 0, w, h);
  }
  @Override
  protected void onSizeChanged(int w, int h, int oldw, int oldh) {
    saveButtonOriginalPosition();

    if (mShouldProgressIndeterminate) {
      setIndeterminate(true);
      mShouldProgressIndeterminate = false;
    } else if (mShouldSetProgress) {
      setProgress(mProgress, mAnimateProgress);
      mShouldSetProgress = false;
    } else if (mShouldUpdateButtonPosition) {
      updateButtonPosition();
      mShouldUpdateButtonPosition = false;
    }
    super.onSizeChanged(w, h, oldw, oldh);

    setupProgressBounds();
    setupProgressBarPaints();
    updateBackground();
  }