public interface RequestCreatorCompat
| Modifier and Type | Method and Description |
|---|---|
RequestCreatorCompat |
centerCrop()
Crops an image inside of the bounds specified by
resize(int, int) rather than
distorting the aspect ratio. |
RequestCreatorCompat |
centerInside()
Centers an image inside of the bounds specified by
resize(int, int). |
RequestCreatorCompat |
config(android.graphics.Bitmap.Config config)
Attempt to decode the image using the specified config.
|
RequestCreatorCompat |
error(android.graphics.drawable.Drawable errorDrawable)
An error drawable to be used if the request image could not be loaded.
|
RequestCreatorCompat |
error(int errorResId)
An error drawable to be used if the request image could not be loaded.
|
void |
fetch()
Asynchronously fulfills the request without a
ImageView or Target. |
void |
fetch(CallbackCompat callback)
Asynchronously fulfills the request without a
ImageView or Target,
and invokes the target CallbackCompat with the result. |
RequestCreatorCompat |
fit()
Attempt to resize the image to fit exactly into the target
ImageView's bounds. |
android.graphics.Bitmap |
get()
Synchronously fulfill this request.
|
void |
into(android.widget.ImageView target)
Asynchronously fulfills the request into the specified
ImageView. |
void |
into(android.widget.ImageView target,
CallbackCompat callback)
Asynchronously fulfills the request into the specified
ImageView and invokes the
target CallbackCompat if it's not null. |
void |
into(android.widget.RemoteViews remoteViews,
int viewId,
int[] appWidgetIds)
Asynchronously fulfills the request into the specified
RemoteViews object with the
given viewId. |
void |
into(android.widget.RemoteViews remoteViews,
int viewId,
int notificationId,
android.app.Notification notification)
Asynchronously fulfills the request into the specified
RemoteViews object with the
given viewId. |
void |
into(TargetCompat target)
Asynchronously fulfills the request into the specified
Target. |
RequestCreatorCompat |
noFade()
Disable brief fade in of images loaded from the disk cache or network.
|
RequestCreatorCompat |
noPlaceholder()
Explicitly opt-out to having a placeholder set when calling
into. |
RequestCreatorCompat |
onlyScaleDown()
Only resize an image if the original image size is bigger than the target size
specified by
resize(int, int). |
RequestCreatorCompat |
placeholder(android.graphics.drawable.Drawable placeholderDrawable)
A placeholder drawable to be used while the image is being loaded.
|
RequestCreatorCompat |
placeholder(int placeholderResId)
A placeholder drawable to be used while the image is being loaded.
|
RequestCreatorCompat |
priority(PicassoCompat.Priority priority)
Set the priority of this request.
|
RequestCreatorCompat |
resize(int targetWidth,
int targetHeight)
Resize the image to the specified size in pixels.
|
RequestCreatorCompat |
resizeDimen(int targetWidthResId,
int targetHeightResId)
Resize the image to the specified dimension size.
|
RequestCreatorCompat |
rotate(float degrees)
Rotate the image by the specified degrees.
|
RequestCreatorCompat |
rotate(float degrees,
float pivotX,
float pivotY)
Rotate the image by the specified degrees around a pivot point.
|
RequestCreatorCompat |
stableKey(java.lang.String stableKey)
Sets the stable key for this request to be used instead of the URI or resource ID when
caching.
|
RequestCreatorCompat |
tag(java.lang.Object tag)
Assign a tag to this request.
|
RequestCreatorCompat |
transform(java.util.List<? extends TransformationCompat> transformations)
Add a list of custom transformations to be applied to the image.
|
RequestCreatorCompat |
transform(TransformationCompat transformation)
Add a custom transformation to be applied to the image.
|
RequestCreatorCompat noPlaceholder()
into.
By default, Picasso will either set a supplied placeholder or clear the target
ImageView in order to ensure behavior in situations where views are recycled. This
method will prevent that behavior and retain any already set image.
RequestCreatorCompat placeholder(int placeholderResId)
ImageView.RequestCreatorCompat placeholder(android.graphics.drawable.Drawable placeholderDrawable)
ImageView.
If you are not using a placeholder image but want to clear an existing image (such as when
used in an adapter), pass in null.
RequestCreatorCompat error(int errorResId)
RequestCreatorCompat error(android.graphics.drawable.Drawable errorDrawable)
RequestCreatorCompat tag(java.lang.Object tag)
You can either use simple String tags or objects that naturally
define the scope of your requests within your app such as a
Context, an Activity, or a
Fragment.
WARNING:: Picasso will keep a reference to the tag for
as long as this tag is paused and/or has active requests. Look out for
potential leaks.
RequestCreatorCompat fit()
ImageView's bounds. This
will result in delayed execution of the request until the ImageView has been laid out.
Note: This method works only when your target is an ImageView.
RequestCreatorCompat resizeDimen(int targetWidthResId, int targetHeightResId)
RequestCreatorCompat resize(int targetWidth, int targetHeight)
RequestCreatorCompat centerCrop()
resize(int, int) rather than
distorting the aspect ratio. This cropping technique scales the image so that it fills the
requested bounds and then crops the extra.RequestCreatorCompat centerInside()
resize(int, int). This scales
the image so that both dimensions are equal to or less than the requested bounds.RequestCreatorCompat onlyScaleDown()
resize(int, int).RequestCreatorCompat rotate(float degrees)
RequestCreatorCompat rotate(float degrees, float pivotX, float pivotY)
RequestCreatorCompat config(android.graphics.Bitmap.Config config)
RequestCreatorCompat stableKey(java.lang.String stableKey)
RequestCreatorCompat priority(PicassoCompat.Priority priority)
This will affect the order in which the requests execute but does not guarantee it.
By default, all requests have PicassoCompat.Priority.NORMAL priority, except for
fetch() requests, which have PicassoCompat.Priority.LOW priority by default.
RequestCreatorCompat transform(TransformationCompat transformation)
Custom transformations will always be run after the built-in transformations.
RequestCreatorCompat transform(java.util.List<? extends TransformationCompat> transformations)
Custom transformations will always be run after the built-in transformations.
RequestCreatorCompat noFade()
android.graphics.Bitmap get()
throws java.io.IOException
java.io.IOExceptionvoid fetch()
ImageView or Target. This is
useful when you want to warm up the cache with an image.
Note: It is safe to invoke this method from any thread.
void fetch(CallbackCompat callback)
ImageView or Target,
and invokes the target CallbackCompat with the result. This is useful when you want to warm
up the cache with an image.
Note: The CallbackCompat param is a strong reference and will prevent your
Activity or Fragment from being garbage collected
until the request is completed.
void into(TargetCompat target)
Target. In most cases, you
should use this when you are dealing with a custom View or view
holder which should implement the Target interface.
Implementing on a View:
public class ProfileView extends FrameLayout implements Target {
@Override public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
setBackgroundDrawable(new BitmapDrawable(bitmap));
}
@Override public void onBitmapFailed() {
setBackgroundResource(R.drawable.profile_error);
}
@Override public void onPrepareLoad(Drawable placeHolderDrawable) {
frame.setBackgroundDrawable(placeHolderDrawable);
}
}
Implementing on a view holder object for use inside of an adapter:
public class ViewHolder implements Target {
public FrameLayout frame;
public TextView name;
@Override public void onBitmapLoaded(Bitmap bitmap, LoadedFrom from) {
frame.setBackgroundDrawable(new BitmapDrawable(bitmap));
}
@Override public void onBitmapFailed() {
frame.setBackgroundResource(R.drawable.profile_error);
}
@Override public void onPrepareLoad(Drawable placeHolderDrawable) {
frame.setBackgroundDrawable(placeHolderDrawable);
}
}
Note: This method keeps a weak reference to the Target instance and will be
garbage collected if you do not keep a strong reference to it. To receive callbacks when an
image is loaded use #into(ImageView, Callback).
void into(android.widget.RemoteViews remoteViews,
int viewId,
int notificationId,
android.app.Notification notification)
RemoteViews object with the
given viewId. This is used for loading bitmaps into a Notification.void into(android.widget.RemoteViews remoteViews,
int viewId,
int[] appWidgetIds)
RemoteViews object with the
given viewId. This is used for loading bitmaps into all instances of a widget.void into(android.widget.ImageView target)
ImageView.
Note: This method keeps a weak reference to the ImageView instance and will
automatically support object recycling.
void into(android.widget.ImageView target,
CallbackCompat callback)
ImageView and invokes the
target CallbackCompat if it's not null.
Note: The CallbackCompat param is a strong reference and will prevent your
Activity or Fragment from being garbage collected. If
you use this method, it is strongly recommended you invoke an adjacent
PicassoCompat.cancelRequest(ImageView) call to prevent temporary leaking.