/** Stop the indeterminate progress animation. */
 void stopAnimation() {
   mAnimation = null;
   mTransformation = null;
   if (mIndeterminateDrawable instanceof Animatable) {
     ((Animatable) mIndeterminateDrawable).stop();
     mShouldStartAnimationDrawable = false;
   }
   postInvalidate();
 }
  /** Change the checked state of the view to the inverse of its current state */
  public void toggle() {
    checked = !checked;
    setImageDrawable(checked ? onDrawable : offDrawable);

    if (isLollipop()) {
      Drawable drawable = getDrawable();
      if (drawable instanceof Animatable) {
        Animatable animatable = (Animatable) drawable;
        if (animatable.isRunning()) {
          animatable.stop();
        }
        animatable.start();
      }
    }
  }
예제 #3
0
 /**
  * Create or update the drawable on the target {@link ImageView} to display the supplied bitmap
  * image.
  */
 static void setBitmap(
     ImageView target,
     Context context,
     Bitmap bitmap,
     Picasso.LoadedFrom loadedFrom,
     boolean noFade,
     boolean debugging) {
   Drawable placeholder = target.getDrawable();
   if (placeholder instanceof Animatable) {
     ((Animatable) placeholder).stop();
   }
   PicassoDrawable drawable =
       new PicassoDrawable(context, bitmap, placeholder, loadedFrom, noFade, debugging);
   target.setImageDrawable(drawable);
 }
 private void stopIfAnimatable(Drawable drawable) {
   if (drawable instanceof Animatable) {
     ((Animatable) drawable).stop();
   }
 }