@Override void complete(RequestHandler.Result result) { if (result == null) { throw new AssertionError( String.format("Attempted to complete action with no result!\n%s", this)); } Bitmap bitmap = result.getBitmap(); if (bitmap != null) { target.onBitmapLoaded(bitmap, result.getLoadedFrom()); if (bitmap.isRecycled()) { throw new IllegalStateException("Target callback must not recycle bitmap!"); } } }
@Test public void intoTargetWithQuickMemoryCacheCheckDoesNotSubmit() { when(picasso.quickMemoryCacheCheck(URI_KEY_1)).thenReturn(bitmap); BitmapTarget target = mockTarget(); new RequestCreator(picasso, URI_1, 0).into(target); verify(target).onBitmapLoaded(bitmap, MEMORY); verify(picasso).cancelRequest(target); verify(picasso, never()).enqueueAndSubmit(any(Action.class)); }
@Test public void invokesSuccessIfTargetIsNotNull() { Bitmap bitmap = makeBitmap(); BitmapTarget target = mockTarget(); BitmapTargetAction request = new BitmapTargetAction(mock(Picasso.class), target, null, null, 0); request.complete(new RequestHandler.Result(bitmap, MEMORY)); verify(target).onBitmapLoaded(bitmap, MEMORY); }
if (bitmap != null) { picasso.cancelRequest(target); target.onBitmapLoaded(bitmap, MEMORY); return;