@Test public void recyclingInSuccessThrowsException() { Target bad = new Target() { @Override public void onBitmapLoaded(Bitmap bitmap, Picasso.LoadedFrom from) { bitmap.recycle(); } @Override public void onBitmapFailed(Exception e, Drawable errorDrawable) { throw new AssertionError(); } @Override public void onPrepareLoad(Drawable placeHolderDrawable) { throw new AssertionError(); } }; Picasso picasso = mock(Picasso.class); Bitmap bitmap = makeBitmap(); TargetAction tr = new TargetAction(picasso, bad, null, 0, 0, null, URI_KEY_1, null, 0); try { tr.complete(bitmap, MEMORY); fail(); } catch (IllegalStateException ignored) { } }
@Override void complete(Bitmap result, Picasso.LoadedFrom from) { if (result == null) { throw new AssertionError( String.format("Attempted to complete action with no result!\n%s", this)); } Target target = getTarget(); if (target != null) { target.onBitmapLoaded(result, from); if (result.isRecycled()) { throw new IllegalStateException("Target callback must not recycle bitmap!"); } } }
TargetAction extends Action<Target> { @Override void complete(Bitmap result, Picasso.LoadedFrom from) { if (result == null) { throw new AssertionError( String.format("Attempted to complete action with no result!\n%s", this)); } Target target = getTarget(); if (target != null) { target.onBitmapLoaded(result, from); if (result.isRecycled()) { throw new IllegalStateException("Target callback must not recycle bitmap!"); } } } }
TargetAction extends Action<Target> { @Override void complete(Bitmap result, Picasso.LoadedFrom from) { if (result == null) { throw new AssertionError( String.format("Attempted to complete action with no result!\n%s", this)); } Target target = getTarget(); if (target != null) { target.onBitmapLoaded(result, from); if (result.isRecycled()) { throw new IllegalStateException("Target callback must not recycle bitmap!"); } } } TargetAction(Picasso picasso, Target target, Request data, int memoryPolicy, int networkPolicy,
      Drawable errorDrawable, String key, Object tag, int errorResId); }
TargetAction extends Action<Target> { @Override void complete(Bitmap result, Picasso.LoadedFrom from) { if (result == null) { throw new AssertionError( String.format("Attempted to complete action with no result!\n%s", this)); } Target target = getTarget(); if (target != null) { target.onBitmapLoaded(result, from); if (result.isRecycled()) { throw new IllegalStateException("Target callback must not recycle bitmap!"); } } } TargetAction(Picasso picasso, Target target, Request data, int memoryPolicy, int networkPolicy,
      Drawable errorDrawable, String key, Object tag, int errorResId);  }
TargetAction extends Action<Target> { @Override void complete(Bitmap result, Picasso.LoadedFrom from) { if (result == null) { throw new AssertionError( String.format("Attempted to complete action with no result!\n%s", this)); } Target target = getTarget(); if (target != null) { target.onBitmapLoaded(result, from); if (result.isRecycled()) { throw new IllegalStateException("Target callback must not recycle bitmap!"); } } } TargetAction(Picasso picasso, Target target, Request data, int memoryPolicy, int networkPolicy,
      Drawable errorDrawable, String key, Object tag, int errorResId);   }