コード例 #1
0
 /**
  * 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 {
       mProgressBar.stop();
     }
   }
 }
コード例 #2
0
 /**
  * Set the four colors used in the progress animation. The first color will also be the color of
  * the bar that grows in response to a user swipe gesture.
  *
  * @param colorRes1 Color resource.
  * @param colorRes2 Color resource.
  * @param colorRes3 Color resource.
  * @param colorRes4 Color resource.
  */
 public void setColorScheme(int colorRes1, int colorRes2, int colorRes3, int colorRes4) {
   ensureTarget();
   final Resources res = getResources();
   final int color1 = res.getColor(colorRes1);
   final int color2 = res.getColor(colorRes2);
   final int color3 = res.getColor(colorRes3);
   final int color4 = res.getColor(colorRes4);
   mProgressBar.setColorScheme(color1, color2, color3, color4);
 }
コード例 #3
0
 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;
   mProgressBar.setTriggerPercentage(percent);
 }
コード例 #4
0
 @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);
 }
コード例 #5
0
 @Override
 public void applyTransformation(float interpolatedTime, Transformation t) {
   float percent = mFromPercentage + ((0 - mFromPercentage) * interpolatedTime);
   mProgressBar.setTriggerPercentage(percent);
 }
コード例 #6
0
 @Override
 public void draw(Canvas canvas) {
   super.draw(canvas);
   mProgressBar.draw(canvas);
 }
コード例 #7
0
 /**
  * Set the four colors used in the progress animation. The first color will also be the color of
  * the bar that grows in response to a user swipe gesture.
  *
  * @param color1 Color.
  * @param color2 Color.
  * @param color3 Color.
  * @param color4 Color.
  */
 public void setColorSchemeFromColors(int color1, int color2, int color3, int color4) {
   ensureTarget();
   mProgressBar.setColorScheme(color1, color2, color3, color4);
 }