コード例 #1
0
 /** Stop the indeterminate progress animation. */
 void stopAnimation() {
   mAnimation = null;
   mTransformation = null;
   if (mIndeterminateDrawable instanceof Animatable) {
     ((Animatable) mIndeterminateDrawable).stop();
     mShouldStartAnimationDrawable = false;
   }
   postInvalidate();
 }
コード例 #2
0
 /**
  * Define the drawable used to draw the progress bar in indeterminate mode.
  *
  * @param d the new drawable
  * @see #getIndeterminateDrawable()
  * @see #setIndeterminate(boolean)
  */
 public void setIndeterminateDrawable(Drawable d) {
   if (d != null) {
     d.setCallback(this);
   }
   mIndeterminateDrawable = d;
   if (mIndeterminate) {
     mCurrentDrawable = d;
     postInvalidate();
   }
 }
コード例 #3
0
 @Override
 public void onTransferProgress(
     long progressRate, long totalTransferredSoFar, long totalToTransfer, String filename) {
   int percent = (int) (100.0 * ((double) totalTransferredSoFar) / ((double) totalToTransfer));
   if (percent != mLastPercent) {
     ProgressBar pb = mProgressBar.get();
     if (pb != null) {
       pb.setProgress(percent);
       pb.postInvalidate();
     }
   }
   mLastPercent = percent;
 }
コード例 #4
0
  /**
   * Set the range of the progress bar to 0...<tt>max</tt>.
   *
   * @param max the upper range of this progress bar
   * @see #getMax()
   * @see #setProgress(int)
   * @see #setSecondaryProgress(int)
   */
  @android.view.RemotableViewMethod
  public synchronized void setMax(int max) {
    if (max < 0) {
      max = 0;
    }
    if (max != mMax) {
      mMax = max;
      postInvalidate();

      if (mProgress > max) {
        mProgress = max;
        refreshProgress(R.id.progress, mProgress, false);
      }
    }
  }
コード例 #5
0
  /**
   * Define the drawable used to draw the progress bar in progress mode.
   *
   * @param d the new drawable
   * @see #getProgressDrawable()
   * @see #setIndeterminate(boolean)
   */
  public void setProgressDrawable(Drawable d) {
    if (d != null) {
      d.setCallback(this);

      // Make sure the ProgressBar is always tall enough
      int drawableHeight = d.getMinimumHeight();
      if (mMaxHeight < drawableHeight) {
        mMaxHeight = drawableHeight;
        requestLayout();
      }
    }
    mProgressDrawable = d;
    if (!mIndeterminate) {
      mCurrentDrawable = d;
      postInvalidate();
    }
  }
コード例 #6
0
  /** Start the indeterminate progress animation. */
  void startAnimation() {
    if (getVisibility() != VISIBLE) {
      return;
    }

    if (mIndeterminateDrawable instanceof Animatable) {
      mShouldStartAnimationDrawable = true;
      mAnimation = null;
    } else {
      if (mInterpolator == null) {
        mInterpolator = new LinearInterpolator();
      }

      mTransformation = new Transformation();
      mAnimation = new AlphaAnimation(0.0f, 1.0f);
      mAnimation.setRepeatMode(mBehavior);
      mAnimation.setRepeatCount(Animation.INFINITE);
      mAnimation.setDuration(mDuration);
      mAnimation.setInterpolator(mInterpolator);
      mAnimation.setStartTime(Animation.START_ON_FIRST_FRAME);
    }
    postInvalidate();
  }