@Test public void invokesErrorIfTargetIsNotNullWithErrorResourceId() throws Exception { ImageView target = mockImageViewTarget(); Callback callback = mockCallback(); Picasso mock = mock(Picasso.class); ImageViewAction request = new ImageViewAction(mock, target, null, 0, 0, RESOURCE_ID_1, null, null, null, callback, false); Exception e = new RuntimeException(); request.error(e); verify(target).setImageResource(RESOURCE_ID_1); verify(callback).onError(e); }
@Override public void error(Exception e) { ImageView target = this.target.get(); if (target == null) { return; } Drawable placeholder = target.getDrawable(); if (placeholder instanceof AnimationDrawable) { ((AnimationDrawable) placeholder).stop(); } if (errorResId != 0) { target.setImageResource(errorResId); } else if (errorDrawable != null) { target.setImageDrawable(errorDrawable); } if (callback != null) { callback.onError(e); } }
ImageViewAction extends Action<ImageView> { @Override public void error(Exception e) { ImageView target = this.target.get(); if (target == null) { return; } Drawable placeholder = target.getDrawable(); if (placeholder instanceof AnimationDrawable) { ((AnimationDrawable) placeholder).stop(); } if (errorResId != 0) { target.setImageResource(errorResId); } else if (errorDrawable != null) { target.setImageDrawable(errorDrawable); } if (callback != null) { callback.onError(e); } } }
ImageViewAction extends Action<ImageView> { @Override public void error(Exception e) { ImageView target = this.target.get(); if (target == null) { return; } Drawable placeholder = target.getDrawable(); if (placeholder instanceof AnimationDrawable) { ((AnimationDrawable) placeholder).stop(); } if (errorResId != 0) { target.setImageResource(errorResId); } else if (errorDrawable != null) { target.setImageDrawable(errorDrawable); } if (callback != null) { callback.onError(e); } } ImageViewAction(Picasso picasso, ImageView imageView, Request data, int memoryPolicy,
      int networkPolicy, int errorResId, Drawable errorDrawable, String key, Object tag,
      Callback callback, boolean noFade); }
ImageViewAction extends Action<ImageView> { @Override public void error(Exception e) { ImageView target = this.target.get(); if (target == null) { return; } Drawable placeholder = target.getDrawable(); if (placeholder instanceof AnimationDrawable) { ((AnimationDrawable) placeholder).stop(); } if (errorResId != 0) { target.setImageResource(errorResId); } else if (errorDrawable != null) { target.setImageDrawable(errorDrawable); } if (callback != null) { callback.onError(e); } } ImageViewAction(Picasso picasso, ImageView imageView, Request data, int memoryPolicy,
      int networkPolicy, int errorResId, Drawable errorDrawable, String key, Object tag,
      Callback callback, boolean noFade); @Override void complete(Bitmap result, Picasso.LoadedFrom from); @Override void error(Exception e); }
ImageViewAction extends Action<ImageView> { @Override public void error(Exception e) { ImageView target = this.target.get(); if (target == null) { return; } Drawable placeholder = target.getDrawable(); if (placeholder instanceof AnimationDrawable) { ((AnimationDrawable) placeholder).stop(); } if (errorResId != 0) { target.setImageResource(errorResId); } else if (errorDrawable != null) { target.setImageDrawable(errorDrawable); } if (callback != null) { callback.onError(e); } } ImageViewAction(Picasso picasso, ImageView imageView, Request data, int memoryPolicy,
      int networkPolicy, int errorResId, Drawable errorDrawable, String key, Object tag,
      Callback callback, boolean noFade); @Override void complete(Bitmap result, Picasso.LoadedFrom from); @Override void error(Exception e);  }