@Override
  public void onRestoreInstanceState(Parcelable state) {
    if (!(state instanceof ProgressSavedState)) {
      super.onRestoreInstanceState(state);
      return;
    }

    ProgressSavedState ss = (ProgressSavedState) state;
    super.onRestoreInstanceState(ss.getSuperState());

    this.mCurrentProgress = ss.mCurrentProgress;
    this.mTargetProgress = ss.mTargetProgress;
    this.mSpinSpeed = ss.mSpinSpeed;
    this.mProgressWidth = ss.mProgressWidth;
    this.mProgressColor = ss.mProgressColor;
    this.mProgressBackgroundColor = ss.mProgressBackgroundColor;
    this.mShouldProgressIndeterminate = ss.mShouldProgressIndeterminate;
    this.mShouldSetProgress = ss.mShouldSetProgress;
    this.mProgress = ss.mProgress;
    this.mAnimateProgress = ss.mAnimateProgress;
    this.mShowProgressBackground = ss.mShowProgressBackground;

    this.mLastTimeAnimated = SystemClock.uptimeMillis();
  }
  @Override
  public Parcelable onSaveInstanceState() {
    Parcelable superState = super.onSaveInstanceState();

    ProgressSavedState ss = new ProgressSavedState(superState);

    ss.mCurrentProgress = this.mCurrentProgress;
    ss.mTargetProgress = this.mTargetProgress;
    ss.mSpinSpeed = this.mSpinSpeed;
    ss.mProgressWidth = this.mProgressWidth;
    ss.mProgressColor = this.mProgressColor;
    ss.mProgressBackgroundColor = this.mProgressBackgroundColor;
    ss.mShouldProgressIndeterminate = this.mProgressIndeterminate;
    ss.mShouldSetProgress =
        this.mProgressBarEnabled && mProgress > 0 && !this.mProgressIndeterminate;
    ss.mProgress = this.mProgress;
    ss.mAnimateProgress = this.mAnimateProgress;
    ss.mShowProgressBackground = this.mShowProgressBackground;

    return ss;
  }