ModelType
- The type of model that will be loaded into the target.public class DrawableRequestBuilder<ModelType> extends GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
GlideDrawable
.
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 |
---|---|
DrawableRequestBuilder<ModelType> |
animate(Animation animation)
Deprecated.
|
DrawableRequestBuilder<ModelType> |
animate(GlideAnimationFactory<GlideDrawable> 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.
|
DrawableRequestBuilder<ModelType> |
animate(int animationId)
Sets an animation to run on the wrapped target when an resource load finishes.
|
DrawableRequestBuilder<ModelType> |
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. |
DrawableRequestBuilder<ModelType> |
bitmapTransform(Transformation<Bitmap>... bitmapTransformations)
Transform
GlideDrawable s using the given Bitmap transformations. |
DrawableRequestBuilder<ModelType> |
cacheDecoder(ResourceDecoder<File,GifBitmapWrapper> cacheDecoder)
Sets the
ResourceDecoder to use to load the resource from the disk cache. |
DrawableRequestBuilder<ModelType> |
centerCrop()
Transform
GlideDrawable s using CenterCrop . |
DrawableRequestBuilder<ModelType> |
clone()
Returns a copy of this request builder with all of the options set so far on this builder.
|
DrawableRequestBuilder<ModelType> |
crossFade()
Applies a cross fade transformation that fades from the placeholder to the loaded
Drawable . |
DrawableRequestBuilder<ModelType> |
crossFade(Animation animation,
int duration)
Deprecated.
|
DrawableRequestBuilder<ModelType> |
crossFade(int duration)
Applies a cross fade transformation that fades from the placeholder to the loaded
Drawable . |
DrawableRequestBuilder<ModelType> |
crossFade(int animationId,
int duration)
Applies a cross fade transformation that des from the placeholder to the loaded
Drawable . |
DrawableRequestBuilder<ModelType> |
decoder(ResourceDecoder<ImageVideoWrapper,GifBitmapWrapper> decoder)
Sets the
ResourceDecoder to use to load the resource from the original data. |
DrawableRequestBuilder<ModelType> |
diskCacheStrategy(DiskCacheStrategy strategy)
Sets the
DiskCacheStrategy to use for this load. |
DrawableRequestBuilder<ModelType> |
dontAnimate()
Removes any existing animation set on the builder.
|
DrawableRequestBuilder<ModelType> |
dontTransform()
Removes the current
Transformation . |
DrawableRequestBuilder<ModelType> |
encoder(ResourceEncoder<GifBitmapWrapper> encoder)
Sets the
Encoder to use to encode the original data directly to cache. |
DrawableRequestBuilder<ModelType> |
error(Drawable drawable)
Sets a
Drawable to display if a load fails. |
DrawableRequestBuilder<ModelType> |
error(int resourceId)
Sets a resource to display if a load fails.
|
DrawableRequestBuilder<ModelType> |
fallback(Drawable drawable)
|
DrawableRequestBuilder<ModelType> |
fallback(int resourceId)
Sets a resource to display if the model provided to
GenericRequestBuilder.load(Object) is null . |
DrawableRequestBuilder<ModelType> |
fitCenter()
Transform
GlideDrawable s using FitCenter . |
Target<GlideDrawable> |
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. |
DrawableRequestBuilder<ModelType> |
listener(RequestListener<? super ModelType,GlideDrawable> requestListener)
Sets a RequestBuilder listener to monitor the resource load.
|
DrawableRequestBuilder<ModelType> |
load(ModelType model)
Sets the specific model to load data for.
|
DrawableRequestBuilder<ModelType> |
override(int width,
int height)
Overrides the
Target 's width and height with the given values. |
DrawableRequestBuilder<ModelType> |
placeholder(Drawable drawable)
Sets an
Drawable to display while a resource is loading. |
DrawableRequestBuilder<ModelType> |
placeholder(int resourceId)
Sets an Android resource id for a
Drawable resource to display while a resource
is loading. |
DrawableRequestBuilder<ModelType> |
priority(Priority priority)
Sets the priority for this load.
|
DrawableRequestBuilder<ModelType> |
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.
|
DrawableRequestBuilder<ModelType> |
sizeMultiplier(float sizeMultiplier)
Applies a multiplier to the
Target 's size before loading the resource. |
DrawableRequestBuilder<ModelType> |
skipMemoryCache(boolean skip)
Allows the loaded resource to skip the memory cache.
|
DrawableRequestBuilder<ModelType> |
sourceEncoder(Encoder<ImageVideoWrapper> sourceEncoder)
Sets the source encoder to use to encode the data retrieved by this request directly into cache.
|
DrawableRequestBuilder<ModelType> |
thumbnail(DrawableRequestBuilder<?> thumbnailRequest)
Loads and displays the
GlideDrawable retrieved by the given thumbnail request if it finishes before this
request. |
DrawableRequestBuilder<ModelType> |
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.
|
DrawableRequestBuilder<ModelType> |
thumbnail(GenericRequestBuilder<?,?,?,GlideDrawable> thumbnailRequest)
Loads and displays the resource retrieved by the given thumbnail request if it finishes before this request.
|
DrawableRequestBuilder<ModelType> |
transcoder(ResourceTranscoder<GifBitmapWrapper,GlideDrawable> transcoder)
Sets the
ResourceTranscoder to use for this load. |
DrawableRequestBuilder<ModelType> |
transform(BitmapTransformation... transformations)
Transform
GlideDrawable s using the given
BitmapTransformation s. |
DrawableRequestBuilder<ModelType> |
transform(Transformation<GifBitmapWrapper>... transformation)
Transform resources with the given
Transformation s. |
into, into, preload, preload
public DrawableRequestBuilder<ModelType> thumbnail(DrawableRequestBuilder<?> thumbnailRequest)
GlideDrawable
retrieved by the given thumbnail request if it finishes before this
request. Best used for loading thumbnail GlideDrawable
s that are smaller and will be loaded more quickly
than the fullsize GlideDrawable
. 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 GlideDrawable
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 GlideDrawable} 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 DrawableRequestBuilder<ModelType> thumbnail(GenericRequestBuilder<?,?,?,GlideDrawable> thumbnailRequest)
thumbnail
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
thumbnailRequest
- The request to use to load the thumbnail.
Recursive calls to thumbnail are supported.
public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
sizeMultiplier
- The multiplier to apply to the Target
's dimensions when loading the thumbnail.public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
sizeMultiplier
- The multiplier to apply to the Target
's dimensions when loading the resource.public DrawableRequestBuilder<ModelType> decoder(ResourceDecoder<ImageVideoWrapper,GifBitmapWrapper> 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,GifBitmapWrapper,GlideDrawable>
decoder
- The ResourceDecoder
to use to decode the resource.GenericRequestBuilder.cacheDecoder(com.bumptech.glide.load.ResourceDecoder)
,
DiskCacheStrategy
public DrawableRequestBuilder<ModelType> cacheDecoder(ResourceDecoder<File,GifBitmapWrapper> 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,GifBitmapWrapper,GlideDrawable>
cacheDecoder
- The decoder to use.GenericRequestBuilder.decoder(com.bumptech.glide.load.ResourceDecoder)
,
DiskCacheStrategy
public DrawableRequestBuilder<ModelType> encoder(ResourceEncoder<GifBitmapWrapper> 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,GifBitmapWrapper,GlideDrawable>
encoder
- The encoder to use.GenericRequestBuilder.sourceEncoder(com.bumptech.glide.load.Encoder)
,
DiskCacheStrategy
public DrawableRequestBuilder<ModelType> priority(Priority priority)
priority
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
priority
- A priority.public DrawableRequestBuilder<ModelType> transform(BitmapTransformation... transformations)
GlideDrawable
s using the given
BitmapTransformation
s.
Note - Bitmap transformations will apply individually to each frame of animated GIF images and also to
individual Bitmap
s.
transformations
- The transformations to apply in order.centerCrop()
,
fitCenter()
,
bitmapTransform(com.bumptech.glide.load.Transformation[])
,
transform(com.bumptech.glide.load.Transformation[])
public DrawableRequestBuilder<ModelType> centerCrop()
GlideDrawable
s using CenterCrop
.public DrawableRequestBuilder<ModelType> fitCenter()
GlideDrawable
s using FitCenter
.public DrawableRequestBuilder<ModelType> bitmapTransform(Transformation<Bitmap>... bitmapTransformations)
GlideDrawable
s using the given Bitmap
transformations. Replaces any
previous transformations.fitCenter()
,
centerCrop()
,
transform(com.bumptech.glide.load.resource.bitmap.BitmapTransformation...)
,
transform(com.bumptech.glide.load.Transformation[])
public DrawableRequestBuilder<ModelType> transform(Transformation<GifBitmapWrapper>... transformation)
Transformation
s. Replaces any existing transformation or
transformations.transform
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
transformation
- the transformations to apply in order.bitmapTransform(com.bumptech.glide.load.Transformation[])
,
centerCrop()
,
fitCenter()
public DrawableRequestBuilder<ModelType> transcoder(ResourceTranscoder<GifBitmapWrapper,GlideDrawable> transcoder)
ResourceTranscoder
to use for this load.transcoder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
transcoder
- The transcoder to use.UnitTranscoder
,
GlideBitmapDrawableTranscoder
,
GifBitmapWrapperDrawableTranscoder
public final DrawableRequestBuilder<ModelType> crossFade()
Drawable
. If no placeholder is set, the Drawable will instead simply fade in.crossFade(int)
,
crossFade(int, int)
public DrawableRequestBuilder<ModelType> 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 DrawableRequestBuilder<ModelType> 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 DrawableRequestBuilder<ModelType> 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 DrawableRequestBuilder<ModelType> dontAnimate()
dontAnimate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
animator
- The ViewPropertyAnimation.Animator
to run.public DrawableRequestBuilder<ModelType> animate(GlideAnimationFactory<GlideDrawable> animationFactory)
animate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
animationFactory
- Animation factory which creates compatible animations.public DrawableRequestBuilder<ModelType> animate(int animationId)
animate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
animationId
- The resource id of the animation to run@Deprecated public DrawableRequestBuilder<ModelType> animate(Animation animation)
animate
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
animation
- The animation to runGenericRequestBuilder.animate(int)
,
GenericRequestBuilder.animate(com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator)
public DrawableRequestBuilder<ModelType> placeholder(int resourceId)
Drawable
resource to display while a resource
is loading.placeholder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
resourceId
- The id of the resource to use as a placeholderpublic DrawableRequestBuilder<ModelType> placeholder(Drawable drawable)
Drawable
to display while a resource is loading.placeholder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
drawable
- The drawable to display as a placeholder.public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
drawable
- The drawable to display as a placeholder.GenericRequestBuilder.placeholder(Drawable)
,
GenericRequestBuilder.placeholder(int)
public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
resourceId
- The id of the resource to use as a fallback.GenericRequestBuilder.placeholder(Drawable)
,
GenericRequestBuilder.placeholder(int)
public DrawableRequestBuilder<ModelType> error(int resourceId)
error
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
resourceId
- The id of the resource to use as a placeholder.public DrawableRequestBuilder<ModelType> error(Drawable drawable)
Drawable
to display if a load fails.error
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
drawable
- The drawable to display.public DrawableRequestBuilder<ModelType> listener(RequestListener<? super ModelType,GlideDrawable> requestListener)
listener
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
requestListener
- The request listener to use.public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
strategy
- The strategy to use.public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
skip
- True to allow the resource to skip the memory cache.public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
width
- The width in pixels to use to load the resource.height
- The height in pixels to use to load the resource.public DrawableRequestBuilder<ModelType> sourceEncoder(Encoder<ImageVideoWrapper> sourceEncoder)
sourceEncoder
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
sourceEncoder
- The encoder to use.DiskCacheStrategy
public DrawableRequestBuilder<ModelType> dontTransform()
Transformation
.dontTransform
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
public DrawableRequestBuilder<ModelType> signature(Key signature)
GenericRequestBuilder
Note - The signature does not replace the cache key, it is purely additive.
signature
in class GenericRequestBuilder<ModelType,ImageVideoWrapper,GifBitmapWrapper,GlideDrawable>
signature
- A unique non-null Key
representing the current state of the
model that will be mixed in to the cache key.StringSignature
public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
model
- The model to load data for, or null.public DrawableRequestBuilder<ModelType> 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,GifBitmapWrapper,GlideDrawable>
public Target<GlideDrawable> 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,GifBitmapWrapper,GlideDrawable>
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)