public class

ImageRequestBuilder

extends Object
java.lang.Object
   ↳ com.facebook.imagepipeline.request.ImageRequestBuilder

Class Overview

Builder class for ImageRequests.

Summary

Nested Classes
class ImageRequestBuilder.BuilderException An exception class for builder methods. 
Public Methods
ImageRequest build()
Builds the Request.
ImageRequestBuilder disableDiskCache()
Disables disk cache for this request, regardless where the image will come from.
static ImageRequestBuilder fromRequest(ImageRequest imageRequest)
Creates a new request builder instance with the same parameters as the imageRequest passed in.
ImageRequest.CacheChoice getCacheChoice()
Gets the cache choice (profile image or default).
ImageDecodeOptions getImageDecodeOptions()
ImageRequest.RequestLevel getLowestPermittedRequestLevel()
Gets the lowest permitted request level.
Postprocessor getPostprocessor()
Gets postprocessor if set, null otherwise.
Priority getRequestPriority()
Returns the request priority.
ResizeOptions getResizeOptions()
Gets the resize options if set, null otherwise.
Uri getSourceUri()
Gets the source Uri.
boolean isAutoRotateEnabled()
Returns whether auto-rotate is enabled.
boolean isDiskCacheEnabled()
Returns whether the use of the disk cache is enabled, which is partly dependent on the URI.
boolean isLocalThumbnailPreviewsEnabled()
Returns whether the use of local thumbnails for previews is enabled.
boolean isProgressiveRenderingEnabled()
Returns whether progressive loading is enabled.
static ImageRequestBuilder newBuilderWithResourceId(int resId)
Creates a new request builder instance for a local resource image.
static ImageRequestBuilder newBuilderWithSource(Uri uri)
Creates a new request builder instance.
ImageRequestBuilder setAutoRotateEnabled(boolean enabled)
Enables or disables auto-rotate for the image in case image has orientation.
ImageRequestBuilder setCacheChoice(ImageRequest.CacheChoice cacheChoice)
Sets the cache option.
ImageRequestBuilder setImageDecodeOptions(ImageDecodeOptions imageDecodeOptions)
ImageRequestBuilder setLocalThumbnailPreviewsEnabled(boolean enabled)
Enables or disables the use of local thumbnails as previews.
ImageRequestBuilder setLowestPermittedRequestLevel(ImageRequest.RequestLevel requestLevel)
Sets the lowest level that is permitted to request the image from.
ImageRequestBuilder setPostprocessor(Postprocessor postprocessor)
Sets the postprocessor.
ImageRequestBuilder setProgressiveRenderingEnabled(boolean enabled)
Enables or disables progressive rendering.
ImageRequestBuilder setRequestPriority(Priority requestPriority)
Set priority for the request.
ImageRequestBuilder setResizeOptions(ResizeOptions resizeOptions)
Sets resize options in case resize should be performed.
ImageRequestBuilder setSource(Uri uri)
Sets the source uri (both network and local uris are supported).
Protected Methods
void validate()
Performs validation.
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public ImageRequest build ()

Builds the Request.

Returns
  • a valid image request

public ImageRequestBuilder disableDiskCache ()

Disables disk cache for this request, regardless where the image will come from.

public static ImageRequestBuilder fromRequest (ImageRequest imageRequest)

Creates a new request builder instance with the same parameters as the imageRequest passed in.

Parameters
imageRequest the ImageRequest from where to copy the parameters to the builder.
Returns
  • a new request builder instance

public ImageRequest.CacheChoice getCacheChoice ()

Gets the cache choice (profile image or default).

public ImageDecodeOptions getImageDecodeOptions ()

public ImageRequest.RequestLevel getLowestPermittedRequestLevel ()

Gets the lowest permitted request level.

public Postprocessor getPostprocessor ()

Gets postprocessor if set, null otherwise.

public Priority getRequestPriority ()

Returns the request priority.

public ResizeOptions getResizeOptions ()

Gets the resize options if set, null otherwise.

public Uri getSourceUri ()

Gets the source Uri.

public boolean isAutoRotateEnabled ()

Returns whether auto-rotate is enabled.

public boolean isDiskCacheEnabled ()

Returns whether the use of the disk cache is enabled, which is partly dependent on the URI.

public boolean isLocalThumbnailPreviewsEnabled ()

Returns whether the use of local thumbnails for previews is enabled.

public boolean isProgressiveRenderingEnabled ()

Returns whether progressive loading is enabled.

public static ImageRequestBuilder newBuilderWithResourceId (int resId)

Creates a new request builder instance for a local resource image.

Only image resources can be used with the image pipeline (PNG, JPG, GIF). Other resource types such as Strings or XML Drawables make no sense in the context of the image pipeline and so cannot be supported. Attempts to do so will throw an java.lang.IllegalArgumentException when the pipeline tries to decode the resource.

One potentially confusing case is drawable declared in XML (e.g. ShapeDrawable). This is not an image. If you want to display an XML drawable as the main image, then set it as a placeholder and do not set a URI.

Parameters
resId local image resource id.
Returns
  • a new request builder instance.

public static ImageRequestBuilder newBuilderWithSource (Uri uri)

Creates a new request builder instance. The setting will be done according to the source type.

Parameters
uri the uri to fetch
Returns
  • a new request builder instance

public ImageRequestBuilder setAutoRotateEnabled (boolean enabled)

Enables or disables auto-rotate for the image in case image has orientation.

Returns
  • the updated builder instance

public ImageRequestBuilder setCacheChoice (ImageRequest.CacheChoice cacheChoice)

Sets the cache option. Pipeline might use different caches and eviction policies for each image type.

Parameters
cacheChoice the cache choice to set
Returns
  • the modified builder instance

public ImageRequestBuilder setImageDecodeOptions (ImageDecodeOptions imageDecodeOptions)

public ImageRequestBuilder setLocalThumbnailPreviewsEnabled (boolean enabled)

Enables or disables the use of local thumbnails as previews.

Returns
  • the modified builder instance

public ImageRequestBuilder setLowestPermittedRequestLevel (ImageRequest.RequestLevel requestLevel)

Sets the lowest level that is permitted to request the image from.

Parameters
requestLevel the lowest request level that is allowed
Returns
  • the updated builder instance

public ImageRequestBuilder setPostprocessor (Postprocessor postprocessor)

Sets the postprocessor.

Parameters
postprocessor postprocessor to postprocess the output bitmap with.

public ImageRequestBuilder setProgressiveRenderingEnabled (boolean enabled)

Enables or disables progressive rendering.

Returns
  • the modified builder instance

public ImageRequestBuilder setRequestPriority (Priority requestPriority)

Set priority for the request.

Returns
  • the modified builder instance

public ImageRequestBuilder setResizeOptions (ResizeOptions resizeOptions)

Sets resize options in case resize should be performed.

Parameters
resizeOptions resize options
Returns
  • the modified builder instance

public ImageRequestBuilder setSource (Uri uri)

Sets the source uri (both network and local uris are supported). Note: this will enable disk caching for network sources, and disable it for local sources.

Parameters
uri the uri to fetch the image from
Returns
  • the updated builder instance

Protected Methods

protected void validate ()

Performs validation.