public void setLoading(boolean loading) {
   if (mLoading != loading) {
     ensureTarget();
     mCurrPercentage = 0;
     mLoading = loading;
     if (mLoading) {
       mProgressBarBottom.start();
     } else {
       mLastDirection = Mode.DISABLED;
       mProgressBarBottom.stop();
     }
   }
 }
 /**
  * Notify the widget that refresh state has changed. Do not call this when refresh is triggered by
  * a swipe gesture.
  *
  * @param refreshing Whether or not the view should show refresh progress.
  */
 public void setRefreshing(boolean refreshing) {
   if (mRefreshing != refreshing) {
     ensureTarget();
     mCurrPercentage = 0;
     mRefreshing = refreshing;
     if (mRefreshing) {
       mProgressBar.start();
     } else {
       mLastDirection = Mode.DISABLED;
       mProgressBar.stop();
     }
   }
 }
 @Override
 protected void onLayout(boolean changed, int left, int top, int right, int bottom) {
   final int width = getMeasuredWidth();
   final int height = getMeasuredHeight();
   mProgressBar.setBounds(0, 0, width, mProgressBarHeight);
   if (getChildCount() == 0) {
     return;
   }
   final View child = getChildAt(0);
   final int childLeft = getPaddingLeft();
   final int childTop = mCurrentTargetOffsetTop + getPaddingTop();
   final int childWidth = width - getPaddingLeft() - getPaddingRight();
   final int childHeight = height - getPaddingTop() - getPaddingBottom();
   child.layout(childLeft, childTop, childLeft + childWidth, childTop + childHeight);
   mProgressBarBottom.setBounds(0, height - mProgressBarHeight, width, height);
 }
 // 设置进度条的显示百分比
 private void setTriggerPercentage(float percent) {
   if (percent == 0f) {
     // No-op. A null trigger means it's uninitialized, and setting it to zero-percent
     // means we're trying to reset state, so there's nothing to reset in this case.
     mCurrPercentage = 0;
     return;
   }
   mCurrPercentage = percent;
   if (((mMode == Mode.PULL_FROM_START) || (mMode == Mode.BOTH))
       && mLastDirection != Mode.PULL_FROM_END
       && !mLoading) {
     mProgressBar.setTriggerPercentage(percent);
   } else if (((mMode == Mode.PULL_FROM_END) || (mMode == Mode.BOTH))
       && mLastDirection != Mode.PULL_FROM_START
       && !mRefreshing) {
     mProgressBarBottom.setTriggerPercentage(percent);
   }
 }
 @Override
 public void applyTransformation(float interpolatedTime, Transformation t) {
   float percent = mFromPercentage + ((0 - mFromPercentage) * interpolatedTime);
   mProgressBar.setTriggerPercentage(percent);
 }
 @Override
 public void draw(Canvas canvas) {
   super.draw(canvas);
   mProgressBar.draw(canvas);
   mProgressBarBottom.draw(canvas);
 }
 private void setColorSchemeColorsBottom(int color1, int color2, int color3, int color4) {
   ensureTarget();
   mProgressBarBottom.setColorScheme(color1, color2, color3, color4);
 }