public final class

ImageManager

extends Object
java.lang.Object
   ↳ com.google.android.gms.common.images.ImageManager

Class Overview

This class is used to load images from the network and handles local caching for you.

Summary

Nested Classes
class ImageManager.ImageReceiver  
interface ImageManager.OnImageLoadedListener  
Public Methods
static ImageManager create(Context context)
Returns a new ImageManager for loading images from the network.
void loadImage(ImageView imageView, Uri uri)
Loads an image to display from a URI.
void loadImage(ImageView imageView, int resId)
Loads an image to display from the given resource ID.
void loadImage(ImageManager.OnImageLoadedListener listener, Uri uri, int defaultResId)
Load an image to display from a URI.
void loadImage(ImageManager.OnImageLoadedListener listener, Uri uri)
Load an image to display from a URI.
void loadImage(ImageView imageView, Uri uri, int defaultResId)
Loads an image to display from a URI, using the given resource ID as the default.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public static ImageManager create (Context context)

Returns a new ImageManager for loading images from the network.

Parameters
context The context used by the ImageManager.
Returns
  • A new ImageManager.

public void loadImage (ImageView imageView, Uri uri)

Loads an image to display from a URI. Note that this does not support arbitrary URIs - the URI must be something that was retrieved from another call to Google Play services.

The image view will be cleared out (the drawable set to null) if the image needs to be loaded asynchronously.

The result (if non-null) is set on the given image view on the main thread.

Note that if the ImageView used for this call is hosted in a ListAdapter (or any other class that recycles ImageView instances), then ALL calls to set the contents of that ImageView must be done via one of the calls on this ImageManager.

Parameters
imageView The image view to populate with the image.
uri Uri to load the image data from.

public void loadImage (ImageView imageView, int resId)

Loads an image to display from the given resource ID. If your ImageView is hosted in a ListAdapter (or any other class that recycles ImageView instances), then this call should be used rather than setting the resource directly.

Parameters
imageView The image view to populate with the image.
resId Resource ID to use for the image.

public void loadImage (ImageManager.OnImageLoadedListener listener, Uri uri, int defaultResId)

Load an image to display from a URI. Note that this does not support arbitrary URIs - the URI must be something that was retrieved from another call to Google Play services.

The result is delivered to the given listener on the main thread.

If we don't find a result image view will be set to the given default resource if the image needs to be loaded asynchronously.

Parameters
listener The listener that is called when the load is complete.
uri Uri to load the image data from.
defaultResId Resource ID to use by default for the image.

public void loadImage (ImageManager.OnImageLoadedListener listener, Uri uri)

Load an image to display from a URI. Note that this does not support arbitrary URIs - the URI must be something that was retrieved from another call to Google Play services.

The result is delivered to the given listener on the main thread.

Parameters
listener The listener that is called when the load is complete.
uri Uri to load the image data from.

public void loadImage (ImageView imageView, Uri uri, int defaultResId)

Loads an image to display from a URI, using the given resource ID as the default. Note that this does not support arbitrary URIs - the URI must be something that was retrieved from another call to Google Play services.

The image view will be set to the given default resource if the image needs to be loaded asynchronously.

The result (if non-null) is set on the given image view on the main thread.

Note that if the ImageView used for this call is hosted in a ListAdapter (or any other class that recycles ImageView instances), then ALL calls to set the contents of that ImageView must be done via one of the calls on this ImageManager.

Parameters
imageView The image view to populate with the image.
uri Uri to load the image data from.
defaultResId Resource ID to use by default for the image.