public final class

MediaVariations

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

Class Overview

An optional part of image requests which describes the piece of media being requested.

This allows for the provision of a number of image variants which are identical in content but at different resolutions. This way if the image at the source URI isn't already cached an appropriate fallback may be used instead.

Even without explicitly including the variants, by using the same media ID across multiple image requests, the pipeline may build up a knowledge of these and fulfil requests accordingly.

This extra functionality is currently only enabled if getMediaVariationsIndexEnabled() is true in the image pipeline config.

Summary

Nested Classes
class MediaVariations.Builder  
class MediaVariations.Variant  
Public Methods
boolean equals(Object o)
static MediaVariations forMediaId(String mediaId)
Creates an instance with a media ID and without specific variants.
String getMediaId()
Get the unique ID for this piece of media.
List<MediaVariations.Variant> getVariants()
Get all known variants of this media.
int hashCode()
static MediaVariations.Builder newBuilderForMediaId(String mediaId)
Creates a builder for a new MediaVariations to which you can add specific variants.
boolean shouldForceRequestForSpecifiedUri()
Gets whether the URI in the original request should be downloaded even if another cached image appears to be big enough for the request.
String toString()
[Expand]
Inherited Methods
From class java.lang.Object

Public Methods

public boolean equals (Object o)

public static MediaVariations forMediaId (String mediaId)

Creates an instance with a media ID and without specific variants. If a null or empty ID is given, null is returned.

Parameters
mediaId the unique ID for this piece of media. If this is neither null or empty, it must be unique for this piece of media (i.e. another request for the same picture at a different size should share the ID but not an unrelated image and not the same media at a different orientation).

public String getMediaId ()

Get the unique ID for this piece of media. This must be non-null, not empty and unique for this piece of media (i.e. another request for the same picture at a different size should share the ID but not an unrelated image and not the same media at a different orientation).

public List<MediaVariations.Variant> getVariants ()

Get all known variants of this media. This may not be exhaustive and these sets may be combined over time to allow the possibilities of fallbacks being offered even when not specified in a later request.

public int hashCode ()

public static MediaVariations.Builder newBuilderForMediaId (String mediaId)

Creates a builder for a new MediaVariations to which you can add specific variants.

Parameters
mediaId the unique ID for this piece of media. This must be non-null and unique for this piece of media (i.e. another request for the same picture at a different size should share the ID but not an unrelated image and not the same media at a different orientation).

public boolean shouldForceRequestForSpecifiedUri ()

Gets whether the URI in the original request should be downloaded even if another cached image appears to be big enough for the request.

Returns
  • true if any found image should only be used as a placeholder, whatever the size

public String toString ()