ModelType
- The type of model that will be loaded into the target.TranscodeType
- The type of the transcoded resource that the target will receivepublic class BitmapRequestBuilder<ModelType,TranscodeType> extends GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
Warning - It is not safe to use this builder after calling into()
, it may be pooled and
reused.
context, glide, lifecycle, modelClass, requestTracker, transcodeClass
Modifier and Type | Method and Description |
---|---|
BitmapRequestBuilder<ModelType,TranscodeType> |
animate(Animation animation)
Deprecated.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
animate(GlideAnimationFactory<TranscodeType> animationFactory)
Sets a factory which will create a transition to run on a view that the target may be wrapping when a resource
load finishes.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
animate(int animationId)
Sets an animation to run on the wrapped target when an resource load finishes.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
animate(ViewPropertyAnimation.Animator animator)
Sets an animator to run a
ViewPropertyAnimator on a view that the target may be wrapping
when a resource load finishes. |
BitmapRequestBuilder<ModelType,TranscodeType> |
approximate()
Load images at a size near the size of the target using
Downsampler.AT_LEAST . |
BitmapRequestBuilder<ModelType,TranscodeType> |
asIs()
Load images at their original size using
Downsampler.NONE . |
BitmapRequestBuilder<ModelType,TranscodeType> |
atMost()
Load images at a size that is at most exactly as big as the target using
Downsampler.AT_MOST . |
BitmapRequestBuilder<ModelType,TranscodeType> |
cacheDecoder(ResourceDecoder<File,Bitmap> cacheDecoder)
Sets the
ResourceDecoder to use to load the resource from the disk cache. |
BitmapRequestBuilder<ModelType,TranscodeType> |
centerCrop()
Transform images using
CenterCrop . |
BitmapRequestBuilder<ModelType,TranscodeType> |
clone()
Returns a copy of this request builder with all of the options set so far on this builder.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
crossFade()
Applies a cross fade transformation that fades from the placeholder to the loaded
Drawable . |
BitmapRequestBuilder<ModelType,TranscodeType> |
crossFade(Animation animation,
int duration)
Deprecated.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
crossFade(int duration)
Applies a cross fade transformation that fades from the placeholder to the loaded
Drawable . |
BitmapRequestBuilder<ModelType,TranscodeType> |
crossFade(int animationId,
int duration)
Applies a cross fade transformation that des from the placeholder to the loaded
Drawable . |
BitmapRequestBuilder<ModelType,TranscodeType> |
decoder(ResourceDecoder<ImageVideoWrapper,Bitmap> decoder)
Sets the
ResourceDecoder to use to load the resource from the original data. |
BitmapRequestBuilder<ModelType,TranscodeType> |
diskCacheStrategy(DiskCacheStrategy strategy)
Sets the
DiskCacheStrategy to use for this load. |
BitmapRequestBuilder<ModelType,TranscodeType> |
dontAnimate()
Removes any existing animation set on the builder.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
dontTransform()
Removes the current
Transformation . |
BitmapRequestBuilder<ModelType,TranscodeType> |
encoder(ResourceEncoder<Bitmap> encoder)
Sets the
Encoder to use to encode the original data directly to cache. |
BitmapRequestBuilder<ModelType,TranscodeType> |
error(Drawable drawable)
Sets a
Drawable to display if a load fails. |
BitmapRequestBuilder<ModelType,TranscodeType> |
error(int resourceId)
Sets a resource to display if a load fails.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
fallback(Drawable drawable)
|
BitmapRequestBuilder<ModelType,TranscodeType> |
fallback(int resourceId)
Sets a resource to display if the model provided to
GenericRequestBuilder.load(Object) is null . |
BitmapRequestBuilder<ModelType,TranscodeType> |
fitCenter()
Transform images using
FitCenter . |
BitmapRequestBuilder<ModelType,TranscodeType> |
format(DecodeFormat format)
Sets the preferred format for
Bitmap s decoded in this request. |
BitmapRequestBuilder<ModelType,TranscodeType> |
imageDecoder(ResourceDecoder<InputStream,Bitmap> decoder)
|
Target<TranscodeType> |
into(ImageView view)
Sets the
ImageView the resource will be loaded into, cancels any existing loads into the view, and frees
any resources Glide may have previously loaded into the view so they may be reused. |
BitmapRequestBuilder<ModelType,TranscodeType> |
listener(RequestListener<? super ModelType,TranscodeType> requestListener)
Sets a RequestBuilder listener to monitor the resource load.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
load(ModelType model)
Sets the specific model to load data for.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
override(int width,
int height)
Overrides the
Target 's width and height with the given values. |
BitmapRequestBuilder<ModelType,TranscodeType> |
placeholder(Drawable drawable)
Sets an
Drawable to display while a resource is loading. |
BitmapRequestBuilder<ModelType,TranscodeType> |
placeholder(int resourceId)
Sets an Android resource id for a
Drawable resource to display while a resource
is loading. |
BitmapRequestBuilder<ModelType,TranscodeType> |
priority(Priority priority)
Sets the priority for this load.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
signature(Key signature)
Sets some additional data to be mixed in to the memory and disk cache keys allowing the caller more control over
when cached data is invalidated.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
sizeMultiplier(float sizeMultiplier)
Applies a multiplier to the
Target 's size before loading the resource. |
BitmapRequestBuilder<ModelType,TranscodeType> |
skipMemoryCache(boolean skip)
Allows the loaded resource to skip the memory cache.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
sourceEncoder(Encoder<ImageVideoWrapper> sourceEncoder)
Sets the source encoder to use to encode the data retrieved by this request directly into cache.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
thumbnail(BitmapRequestBuilder<?,TranscodeType> thumbnailRequest)
Loads and displays the
Bitmap retrieved by the given thumbnail request if it finishes
before this request. |
BitmapRequestBuilder<ModelType,TranscodeType> |
thumbnail(float sizeMultiplier)
Loads a resource in an identical manner to this request except with the dimensions of the target multiplied
by the given size multiplier.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
thumbnail(GenericRequestBuilder<?,?,?,TranscodeType> thumbnailRequest)
Loads and displays the resource retrieved by the given thumbnail request if it finishes before this request.
|
BitmapRequestBuilder<ModelType,TranscodeType> |
transcoder(ResourceTranscoder<Bitmap,TranscodeType> transcoder)
Sets the
ResourceTranscoder to use for this load. |
BitmapRequestBuilder<ModelType,TranscodeType> |
transform(BitmapTransformation... transformations)
Transform images using the given
BitmapTransformation s. |
BitmapRequestBuilder<ModelType,TranscodeType> |
transform(Transformation<Bitmap>... transformations)
Transform resources with the given
Transformation s. |
BitmapRequestBuilder<ModelType,TranscodeType> |
videoDecoder(ResourceDecoder<ParcelFileDescriptor,Bitmap> decoder)
|
into, into, preload, preload
public BitmapRequestBuilder<ModelType,TranscodeType> approximate()
Downsampler.AT_LEAST
.downsample(Downsampler)
public BitmapRequestBuilder<ModelType,TranscodeType> asIs()
Downsampler.NONE
.downsample(Downsampler)
public BitmapRequestBuilder<ModelType,TranscodeType> atMost()
Downsampler.AT_MOST
.downsample(com.bumptech.glide.load.resource.bitmap.Downsampler)
public BitmapRequestBuilder<ModelType,TranscodeType> thumbnail(float sizeMultiplier)
Note - The thumbnail resource will be smaller than the size requested so the target (or ImageView
)
must be able to scale the thumbnail appropriately. See ImageView.ScaleType
.
Almost all options will be copied from the original load, including the
ModelLoader
, ResourceDecoder
, and
Transformation
s. However, GenericRequestBuilder.placeholder(int)
and GenericRequestBuilder.error(int)
,
and GenericRequestBuilder.listener(RequestListener)
will only be used on the fullsize load and will not be copied for
the thumbnail load.
Recursive calls to thumbnail are supported.
thumbnail
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
sizeMultiplier
- The multiplier to apply to the Target
's dimensions when loading the thumbnail.public BitmapRequestBuilder<ModelType,TranscodeType> thumbnail(BitmapRequestBuilder<?,TranscodeType> thumbnailRequest)
Bitmap
retrieved by the given thumbnail request if it finishes
before this request. Best used for loading thumbnail Bitmap
s that are smaller and will be loaded more
quickly than the fullsize Bitmap
. There are no guarantees about the order in which the requests will
actually finish. However, if the thumb request completes after the full request, the thumb
Bitmap
will never replace the full image.thumbnailRequest
- The request to use to load the thumbnail.
Note - Any options on the main request will not be passed on to the thumbnail request. For example, if
you want an animation to occur when either the full {@link android.graphics.Bitmap} loads or the thumbnail
loads, you need to call {@link #animate(int)} on both the thumb and the full request. For a simpler thumbnail
option where these options are applied to the humbnail as well, see {@link #thumbnail(float)}.
Only the thumbnail call on the main request will be obeyed, recursive calls to this method are ignored.
public BitmapRequestBuilder<ModelType,TranscodeType> sizeMultiplier(float sizeMultiplier)
Target
's size before loading the resource. Useful for loading thumbnails
or trying to avoid loading huge resources (particularly Bitmap
s on devices with overly
dense screens.sizeMultiplier
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
sizeMultiplier
- The multiplier to apply to the Target
's dimensions when loading the resource.public BitmapRequestBuilder<ModelType,TranscodeType> decoder(ResourceDecoder<ImageVideoWrapper,Bitmap> decoder)
ResourceDecoder
to use to load the resource from the original data.
By default, this decoder will only be used if the final transformed resource is not in the disk cache.decoder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
decoder
- The ResourceDecoder
to use to decode the resource.GenericRequestBuilder.cacheDecoder(com.bumptech.glide.load.ResourceDecoder)
,
DiskCacheStrategy
public BitmapRequestBuilder<ModelType,TranscodeType> cacheDecoder(ResourceDecoder<File,Bitmap> cacheDecoder)
ResourceDecoder
to use to load the resource from the disk cache. By
default, this decoder will only be used if the final transformed resource is already in the disk cache.cacheDecoder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
cacheDecoder
- The decoder to use.GenericRequestBuilder.decoder(com.bumptech.glide.load.ResourceDecoder)
,
DiskCacheStrategy
public BitmapRequestBuilder<ModelType,TranscodeType> encoder(ResourceEncoder<Bitmap> encoder)
Encoder
to use to encode the original data directly to cache. Will only
be used if the original data is not already in cache and if the
DiskCacheStrategy
is set to
DiskCacheStrategy.SOURCE
or
DiskCacheStrategy.ALL
.encoder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
encoder
- The encoder to use.GenericRequestBuilder.sourceEncoder(com.bumptech.glide.load.Encoder)
,
DiskCacheStrategy
public BitmapRequestBuilder<ModelType,TranscodeType> imageDecoder(ResourceDecoder<InputStream,Bitmap> decoder)
decoder
- The decoder to use to decode Bitmap
s.videoDecoder
public BitmapRequestBuilder<ModelType,TranscodeType> videoDecoder(ResourceDecoder<ParcelFileDescriptor,Bitmap> decoder)
decoder
- The decoder to use to decode Bitmap
s.public BitmapRequestBuilder<ModelType,TranscodeType> format(DecodeFormat format)
Bitmap
s decoded in this request. Defaults to
DecodeFormat.PREFER_RGB_565
. This replaces any previous calls to imageDecoder(ResourceDecoder)
,
videoDecoder(ResourceDecoder)
, decoder(ResourceDecoder)
and
cacheDecoder(com.bumptech.glide.load.ResourceDecoder)
} with default decoders with the appropriate
options set.
Note - If using a Transformation
that expect bitmaps to support transparency, this should always be
set to ALWAYS_ARGB_8888. RGB_565 requires fewer bytes per pixel and is generally preferable, but it does not
support transparency.
format
- The format to use.DecodeFormat
public BitmapRequestBuilder<ModelType,TranscodeType> priority(Priority priority)
GenericRequestBuilder
priority
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
priority
- A priority.public BitmapRequestBuilder<ModelType,TranscodeType> transform(BitmapTransformation... transformations)
BitmapTransformation
s.transformations
- The transformations to apply in order.centerCrop()
,
fitCenter()
,
transform(com.bumptech.glide.load.Transformation[])
public BitmapRequestBuilder<ModelType,TranscodeType> centerCrop()
CenterCrop
.fitCenter()
,
transform(com.bumptech.glide.load.resource.bitmap.BitmapTransformation...)
,
transform(com.bumptech.glide.load.Transformation[])
public BitmapRequestBuilder<ModelType,TranscodeType> fitCenter()
FitCenter
.centerCrop()
,
transform(com.bumptech.glide.load.resource.bitmap.BitmapTransformation...)
,
transform(com.bumptech.glide.load.Transformation[])
public BitmapRequestBuilder<ModelType,TranscodeType> transform(Transformation<Bitmap>... transformations)
Transformation
s. Replaces any existing transformation or
transformations.transform
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
transformations
- the transformations to apply in order.fitCenter()
,
centerCrop()
public BitmapRequestBuilder<ModelType,TranscodeType> transcoder(ResourceTranscoder<Bitmap,TranscodeType> transcoder)
ResourceTranscoder
to use for this load.transcoder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
transcoder
- The transcoder to use.UnitTranscoder
,
GlideBitmapDrawableTranscoder
,
GifBitmapWrapperDrawableTranscoder
public final BitmapRequestBuilder<ModelType,TranscodeType> crossFade()
Drawable
. If no placeholder is set, the Drawable will instead simply fade in.crossFade(int)
,
crossFade(int, int)
public BitmapRequestBuilder<ModelType,TranscodeType> crossFade(int duration)
Drawable
. If no placeholder is set the Drawable will instead simply fade in.duration
- The duration of the cross fade and initial fade in.crossFade()
,
crossFade(int, int)
@Deprecated public BitmapRequestBuilder<ModelType,TranscodeType> crossFade(Animation animation, int duration)
Drawable
. If no placeholder is set, the Drawable will instead be animated in
using the given Animation
.animation
- The Animation to use if no placeholder is set.duration
- The duration of the cross fade animation.crossFade()
,
crossFade(int)
,
crossFade(int, int)
public BitmapRequestBuilder<ModelType,TranscodeType> crossFade(int animationId, int duration)
Drawable
. If no placeholder is set, the Drawable will instead be animated in
using the Animation
loaded from the given animation id.animationId
- The id of the Animation to use if no placeholder is set.duration
- The duration of the cross fade animation.crossFade()
,
crossFade(int)
public BitmapRequestBuilder<ModelType,TranscodeType> dontAnimate()
dontAnimate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
public BitmapRequestBuilder<ModelType,TranscodeType> animate(int animationId)
animate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
animationId
- The resource id of the animation to run@Deprecated public BitmapRequestBuilder<ModelType,TranscodeType> animate(Animation animation)
animate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
animation
- The animation to runGenericRequestBuilder.animate(int)
,
GenericRequestBuilder.animate(com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator)
public BitmapRequestBuilder<ModelType,TranscodeType> animate(ViewPropertyAnimation.Animator animator)
ViewPropertyAnimator
on a view that the target may be wrapping
when a resource load finishes. Will only be run if the load was loaded asynchronously (ie was not in the
memory cache).animate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
animator
- The ViewPropertyAnimation.Animator
to run.public BitmapRequestBuilder<ModelType,TranscodeType> animate(GlideAnimationFactory<TranscodeType> animationFactory)
animate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
animationFactory
- Animation factory which creates compatible animations.BitmapContainerCrossFadeFactory
public BitmapRequestBuilder<ModelType,TranscodeType> placeholder(int resourceId)
Drawable
resource to display while a resource
is loading.placeholder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
resourceId
- The id of the resource to use as a placeholderpublic BitmapRequestBuilder<ModelType,TranscodeType> placeholder(Drawable drawable)
Drawable
to display while a resource is loading.placeholder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
drawable
- The drawable to display as a placeholder.public BitmapRequestBuilder<ModelType,TranscodeType> fallback(Drawable drawable)
GenericRequestBuilder
Drawable
to display if the model provided to
GenericRequestBuilder.load(Object)
is null
.
If a fallback is not set, null models will cause the error drawable to be displayed. If the error drawable is not set, the placeholder will be displayed.
fallback
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
drawable
- The drawable to display as a placeholder.GenericRequestBuilder.placeholder(Drawable)
,
GenericRequestBuilder.placeholder(int)
public BitmapRequestBuilder<ModelType,TranscodeType> fallback(int resourceId)
GenericRequestBuilder
GenericRequestBuilder.load(Object)
is null
.
If a fallback is not set, null models will cause the error drawable to be displayed. If the error drawable is not set, the placeholder will be displayed.
fallback
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
resourceId
- The id of the resource to use as a fallback.GenericRequestBuilder.placeholder(Drawable)
,
GenericRequestBuilder.placeholder(int)
public BitmapRequestBuilder<ModelType,TranscodeType> error(int resourceId)
error
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
resourceId
- The id of the resource to use as a placeholder.public BitmapRequestBuilder<ModelType,TranscodeType> error(Drawable drawable)
Drawable
to display if a load fails.error
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
drawable
- The drawable to display.public BitmapRequestBuilder<ModelType,TranscodeType> listener(RequestListener<? super ModelType,TranscodeType> requestListener)
listener
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
requestListener
- The request listener to use.public BitmapRequestBuilder<ModelType,TranscodeType> skipMemoryCache(boolean skip)
Note - this is not a guarantee. If a request is already pending for this resource and that request is not also skipping the memory cache, the resource will be cached in memory.
skipMemoryCache
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
skip
- True to allow the resource to skip the memory cache.public BitmapRequestBuilder<ModelType,TranscodeType> diskCacheStrategy(DiskCacheStrategy strategy)
DiskCacheStrategy
to use for this load. Defaults to
DiskCacheStrategy.RESULT
.
For most applications DiskCacheStrategy.RESULT
is ideal.
Applications that use the same resource multiple times in multiple sizes and are willing to trade off some
speed and disk space in return for lower bandwidth usage may want to consider using
DiskCacheStrategy.SOURCE
or
DiskCacheStrategy.RESULT
. Any download only operations should
typically use DiskCacheStrategy.SOURCE
.
diskCacheStrategy
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
strategy
- The strategy to use.public BitmapRequestBuilder<ModelType,TranscodeType> override(int width, int height)
Target
's width and height with the given values. This is useful almost exclusively for
thumbnails, and should only be used when you both need a very specific sized image and when it is impossible or
impractical to return that size from Target.getSize(com.bumptech.glide.request.target.SizeReadyCallback)
.override
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
width
- The width in pixels to use to load the resource.height
- The height in pixels to use to load the resource.public BitmapRequestBuilder<ModelType,TranscodeType> thumbnail(GenericRequestBuilder<?,?,?,TranscodeType> thumbnailRequest)
thumbnail
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
thumbnailRequest
- The request to use to load the thumbnail.
Recursive calls to thumbnail are supported.
public BitmapRequestBuilder<ModelType,TranscodeType> sourceEncoder(Encoder<ImageVideoWrapper> sourceEncoder)
sourceEncoder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
sourceEncoder
- The encoder to use.DiskCacheStrategy
public BitmapRequestBuilder<ModelType,TranscodeType> dontTransform()
Transformation
.dontTransform
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
public BitmapRequestBuilder<ModelType,TranscodeType> signature(Key signature)
GenericRequestBuilder
Note - The signature does not replace the cache key, it is purely additive.
signature
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
signature
- A unique non-null Key
representing the current state of the
model that will be mixed in to the cache key.StringSignature
public BitmapRequestBuilder<ModelType,TranscodeType> load(ModelType model)
GenericRequestBuilder
This method must be called at least once before GenericRequestBuilder.into(com.bumptech.glide.request.target.Target)
is
called.
load
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
model
- The model to load data for, or null.public BitmapRequestBuilder<ModelType,TranscodeType> clone()
GenericRequestBuilder
This method returns a "deep" copy in that all non-immutable arguments are copied such that changes to one builder will not affect the other builder. However, in addition to immutable arguments, the current model is not copied copied so changes to the model will affect both builders.
clone
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
public Target<TranscodeType> into(ImageView view)
ImageView
the resource will be loaded into, cancels any existing loads into the view, and frees
any resources Glide may have previously loaded into the view so they may be reused.
Note - If no transformation is set for this load, a default transformation will be applied based on the
value returned from ImageView.getScaleType()
. To avoid this default transformation,
use dontTransform()
.
into
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,Bitmap,TranscodeType>
view
- The view to cancel previous loads for and load the new resource into.Target
used to wrap the given ImageView
.Glide.clear(android.view.View)