/** * Asynchronously fulfills the request into the specified {@link ImageView} and invokes the target * {@link Callback} if it's not {@code null}. * * <p><em>Note:</em> The {@link Callback} param is a strong reference and will prevent your {@link * android.app.Activity} or {@link android.app.Fragment} from being garbage collected. If you use * this method, it is <b>strongly</b> recommended you invoke an adjacent {@link * Picasso#cancelRequest(android.widget.ImageView)} call to prevent temporary leaking. */ public void into(ImageView target, Callback callback) { if (target == null) { throw new IllegalArgumentException("Target must not be null."); } if (!data.hasImage()) { picasso.cancelRequest(target); PicassoDrawable.setPlaceholder(target, placeholderResId, placeholderDrawable); return; } if (deferred) { if (data.hasSize()) { throw new IllegalStateException("Fit cannot be used with resize."); } int measuredWidth = target.getMeasuredWidth(); int measuredHeight = target.getMeasuredHeight(); if (measuredWidth == 0 || measuredHeight == 0) { PicassoDrawable.setPlaceholder(target, placeholderResId, placeholderDrawable); picasso.defer(target, new DeferredRequestCreator(this, target, callback)); return; } data.resize(measuredWidth, measuredHeight); } Request finalData = picasso.transformRequest(data.build()); String requestKey = createKey(finalData); if (!skipMemoryCache) { Bitmap bitmap = picasso.quickMemoryCacheCheck(requestKey); if (bitmap != null) { picasso.cancelRequest(target); PicassoDrawable.setBitmap( target, picasso.context, bitmap, MEMORY, noFade, picasso.indicatorsEnabled); if (callback != null) { callback.onSuccess(); } return; } } PicassoDrawable.setPlaceholder(target, placeholderResId, placeholderDrawable); Action action = new ImageViewAction( picasso, target, finalData, skipMemoryCache, noFade, errorResId, errorDrawable, requestKey, callback); picasso.enqueueAndSubmit(action); }
public void complete(Bitmap bitmap, Picasso.LoadedFrom loadedfrom) { if (bitmap == null) { throw new AssertionError( String.format("Attempted to complete action with no result!\n%s", new Object[] {this})); } ImageView imageview = (ImageView) target.get(); if (imageview != null) { android.content.Context context = picasso.context; boolean flag = picasso.indicatorsEnabled; PicassoDrawable.setBitmap(imageview, context, bitmap, loadedfrom, noFade, flag); if (callback != null) { callback.onSuccess(); return; } } }