public class Picasso
extends java.lang.Object
Use get()
for the global singleton instance
or construct your own instance with Picasso.Builder
.
Modifier and Type | Class and Description |
---|---|
static class |
Picasso.Builder
Fluent API for creating
Picasso instances. |
static interface |
Picasso.Listener
Callbacks for Picasso events.
|
static class |
Picasso.LoadedFrom
Describes where the image was loaded from.
|
static class |
Picasso.Priority
The priority of a request.
|
static interface |
Picasso.RequestTransformer
A transformer that is called immediately before every request is submitted.
|
Modifier and Type | Method and Description |
---|---|
boolean |
areIndicatorsEnabled()
true if debug indicators should are displayed on images. |
void |
cancelRequest(android.widget.ImageView view)
Cancel any existing requests for the specified target
ImageView . |
void |
cancelRequest(android.widget.RemoteViews remoteViews,
int viewId)
Cancel any existing requests for the specified
RemoteViews target with the given viewId . |
void |
cancelRequest(Target target)
Cancel any existing requests for the specified
Target instance. |
void |
cancelTag(java.lang.Object tag)
Cancel any existing requests with given tag.
|
static Picasso |
get()
The global
Picasso instance. |
StatsSnapshot |
getSnapshot()
Creates a
StatsSnapshot of the current stats for this instance. |
void |
invalidate(java.io.File file)
Invalidate all memory cached images for the specified
file . |
void |
invalidate(java.lang.String path)
Invalidate all memory cached images for the specified
path . |
void |
invalidate(android.net.Uri uri)
Invalidate all memory cached images for the specified
uri . |
boolean |
isLoggingEnabled()
true if debug logging is enabled. |
RequestCreator |
load(java.io.File file)
Start an image request using the specified image file.
|
RequestCreator |
load(int resourceId)
Start an image request using the specified drawable resource ID.
|
RequestCreator |
load(java.lang.String path)
Start an image request using the specified path.
|
RequestCreator |
load(android.net.Uri uri)
Start an image request using the specified URI.
|
void |
pauseTag(java.lang.Object tag)
Pause existing requests with the given tag.
|
void |
resumeTag(java.lang.Object tag)
Resume paused requests with the given tag.
|
void |
setIndicatorsEnabled(boolean enabled)
Toggle whether to display debug indicators on images.
|
void |
setLoggingEnabled(boolean enabled)
Toggle whether debug logging is enabled.
|
static void |
setSingletonInstance(Picasso picasso)
Set the global instance returned from
get() . |
void |
shutdown()
Stops this instance from accepting further requests.
|
public void cancelRequest(android.widget.ImageView view)
ImageView
.public void cancelRequest(Target target)
Target
instance.public void cancelRequest(android.widget.RemoteViews remoteViews, int viewId)
RemoteViews
target with the given viewId
.public void cancelTag(java.lang.Object tag)
RequestCreator.tag(Object)
.RequestCreator.tag(Object)
public void pauseTag(java.lang.Object tag)
resumeTag(Object)
to resume requests with the given tag.resumeTag(Object)
,
RequestCreator.tag(Object)
public void resumeTag(java.lang.Object tag)
pauseTag(Object)
to pause requests with the given tag.pauseTag(Object)
,
RequestCreator.tag(Object)
public RequestCreator load(android.net.Uri uri)
Passing null
as a uri
will not trigger any request but will set a placeholder,
if one is specified.
load(File)
,
load(String)
,
load(int)
public RequestCreator load(java.lang.String path)
load(Uri)
.
This path may be a remote URL, file resource (prefixed with file:
), content resource
(prefixed with content:
), or android resource (prefixed with android.resource:
.
Passing null
as a path
will not trigger any request but will set a
placeholder, if one is specified.
java.lang.IllegalArgumentException
- if path
is empty or blank string.load(Uri)
,
load(File)
,
load(int)
public RequestCreator load(java.io.File file)
load(Uri)
.
Passing null
as a file
will not trigger any request but will set a
placeholder, if one is specified.
Equivalent to calling load(Uri.fromFile(file))
.
load(Uri)
,
load(String)
,
load(int)
public RequestCreator load(int resourceId)
load(Uri)
,
load(String)
,
load(File)
public void invalidate(android.net.Uri uri)
uri
.invalidate(String)
,
invalidate(File)
public void invalidate(java.lang.String path)
path
. You can also pass a
stable key.invalidate(Uri)
,
invalidate(File)
public void invalidate(java.io.File file)
file
.invalidate(Uri)
,
invalidate(String)
public void setIndicatorsEnabled(boolean enabled)
public boolean areIndicatorsEnabled()
true
if debug indicators should are displayed on images.public void setLoggingEnabled(boolean enabled)
WARNING: Enabling this will result in excessive object allocation. This should be only
be used for debugging Picasso behavior. Do NOT pass BuildConfig.DEBUG
.
public boolean isLoggingEnabled()
true
if debug logging is enabled.public StatsSnapshot getSnapshot()
StatsSnapshot
of the current stats for this instance.
NOTE: The snapshot may not always be completely up-to-date if requests are still in progress.
public void shutdown()
public static Picasso get()
Picasso
instance.
This instance is automatically initialized with defaults that are suitable to most implementations.
If these settings do not meet the requirements of your application you can construct your own
with full control over the configuration by using Picasso.Builder
to create a
Picasso
instance. You can either use this directly or by setting it as the global
instance with setSingletonInstance(com.squareup.picasso.Picasso)
.
public static void setSingletonInstance(Picasso picasso)