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.
ImageRequestBuilder disableMemoryCache()
Disables memory cache for this request.
static ImageRequestBuilder fromRequest(ImageRequest imageRequest)
Creates a new request builder instance with the same parameters as the imageRequest passed in.
BytesRange getBytesRange()
Gets the range of bytes if set, null otherwise.
ImageRequest.CacheChoice getCacheChoice()
Gets the cache choice (profile image or default).
int getDelayMs()
ImageDecodeOptions getImageDecodeOptions()
ImageRequest.RequestLevel getLowestPermittedRequestLevel()
Gets the lowest permitted request level.
Postprocessor getPostprocessor()
Gets postprocessor if set, null otherwise.
RequestListener getRequestListener()
Priority getRequestPriority()
Returns the request priority.
ResizeOptions getResizeOptions()
Gets the resize options if set, null otherwise.
Boolean getResizingAllowedOverride()
RotationOptions getRotationOptions()
Gets the rotation options if set, null otherwise.
Uri getSourceUri()
Gets the source Uri.
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 isMemoryCacheEnabled()
Returns whether the use of the memory cache 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)
This method is deprecated. Use #setRotationOptions(RotationOptions)
ImageRequestBuilder setBytesRange(BytesRange bytesRange)
Set the range of bytes to request from the network (in the case of an HTTP request).
ImageRequestBuilder setCacheChoice(ImageRequest.CacheChoice cacheChoice)
Sets the cache option.
ImageRequestBuilder setDelayMs(int delayMs)
Add an artificial delay for this image, in milliseconds.
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 setRequestListener(RequestListener requestListener)
Sets a request listener to use for just this image request
ImageRequestBuilder setRequestPriority(Priority requestPriority)
Set priority for the request.
ImageRequestBuilder setResizeOptions(ResizeOptions resizeOptions)
Sets resize options in case resize should be performed.
ImageRequestBuilder setResizingAllowedOverride(Boolean resizingAllowedOverride)
ImageRequestBuilder setRotationOptions(RotationOptions rotationOptions)
Sets rotation options for the image, whether to rotate by a multiple of 90 degrees, use the EXIF metadata (relevant to JPEGs only) or to not rotate.
ImageRequestBuilder setShouldDecodePrefetches(Boolean shouldDecodePrefetches)
ImageRequestBuilder setSource(Uri uri)
Sets the source uri (both network and local uris are supported).
Boolean shouldDecodePrefetches()
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 ImageRequestBuilder disableMemoryCache ()

Disables memory cache for this request.

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 BytesRange getBytesRange ()

Gets the range of bytes if set, null otherwise.

public ImageRequest.CacheChoice getCacheChoice ()

Gets the cache choice (profile image or default).

public int getDelayMs ()

public ImageDecodeOptions getImageDecodeOptions ()

public ImageRequest.RequestLevel getLowestPermittedRequestLevel ()

Gets the lowest permitted request level.

public Postprocessor getPostprocessor ()

Gets postprocessor if set, null otherwise.

public RequestListener getRequestListener ()

Returns
  • the additional request listener to use for this image request

public Priority getRequestPriority ()

Returns the request priority.

public ResizeOptions getResizeOptions ()

Gets the resize options if set, null otherwise.

public Boolean getResizingAllowedOverride ()

public RotationOptions getRotationOptions ()

Gets the rotation options if set, null otherwise.

public Uri getSourceUri ()

Gets the source Uri.

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 isMemoryCacheEnabled ()

Returns whether the use of the memory cache 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)

This method is deprecated.
Use #setRotationOptions(RotationOptions)

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

Returns
  • the updated builder instance

public ImageRequestBuilder setBytesRange (BytesRange bytesRange)

Set the range of bytes to request from the network (in the case of an HTTP request). This is only used if isPartialImageCachingEnabled() is true and your NetworkFetcher makes use of it.

Even where this is supported, there is no contract that this must be followed. The response may contain the full image data, more than is requested or less, depending on what's already in cache and external factors.

Parameters
bytesRange the range of bytes
Returns
  • the modified 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 setDelayMs (int delayMs)

Add an artificial delay for this image, in milliseconds.

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.
Returns
  • the modified builder instance

public ImageRequestBuilder setProgressiveRenderingEnabled (boolean enabled)

Enables or disables progressive rendering.

Returns
  • the modified builder instance

public ImageRequestBuilder setRequestListener (RequestListener requestListener)

Sets a request listener to use for just this image request

Parameters
requestListener a request listener to use in addition to the global ones set in the ImagePipelineConfig
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 setResizingAllowedOverride (Boolean resizingAllowedOverride)

public ImageRequestBuilder setRotationOptions (RotationOptions rotationOptions)

Sets rotation options for the image, whether to rotate by a multiple of 90 degrees, use the EXIF metadata (relevant to JPEGs only) or to not rotate. This also specifies whether the rotation should be left until the bitmap is rendered (as the GPU can do this more efficiently than the effort to change the bitmap object).

Parameters
rotationOptions rotation options
Returns
  • the modified builder instance

public ImageRequestBuilder setShouldDecodePrefetches (Boolean shouldDecodePrefetches)

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

public Boolean shouldDecodePrefetches ()

Protected Methods

protected void validate ()

Performs validation.