java.lang.Object | |
↳ | com.facebook.imagepipeline.request.MediaVariations |
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.
Nested Classes | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
class | MediaVariations.Builder | ||||||||||
@interface | MediaVariations.Source | Defines the range of valid source values to be held by an instance. | |||||||||
class | MediaVariations.Variant |
Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
String | SOURCE_ID_EXTRACTOR | ||||||||||
String | SOURCE_IMAGE_REQUEST | ||||||||||
String | SOURCE_INDEX_DB |
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> |
getSortedVariants(Comparator<MediaVariations.Variant> comparator)
Gets a list of the variants in an order determined by the provided comparator.
| ||||||||||
String |
getSource()
Get the source of these variations, for the purposes of logging.
| ||||||||||
MediaVariations.Variant |
getVariant(int index)
Gets the variant at the specified index.
| ||||||||||
int |
getVariantsCount()
Get the number of contained variants.
| ||||||||||
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 | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Creates an instance with a media ID and without specific variants. If a null or empty ID is given, null is returned.
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). |
---|
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).
Gets a list of the variants in an order determined by the provided comparator.
Get the source of these variations, for the purposes of logging.
Gets the variant at the specified index.
index | index of the element to return |
---|
IndexOutOfBoundsException | if the index is out of range (index < 0 || index >= getVariantsCount()) |
---|---|
NullPointerException | if there are no variants |
Get the number of contained variants. This may not be an exhaustive set of variants and these sets may be combined over time to allow the possibilities of fallbacks being offered even when not specified in a later request.
Creates a builder for a new MediaVariations to which you can add specific variants.
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). |
---|
Gets whether the URI in the original request should be downloaded even if another cached image appears to be big enough for the request.