|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bumptech.glide.GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType>
ModelType
- The type of model representing the resource.DataType
- The data type that the resource ModelLoader
will provide that
can be decoded by the ResourceDecoder
.ResourceType
- The type of the resource that will be loaded.TranscodeType
- The type of resource the decoded resource will be transcoded to.public class GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType>
A generic class that can handle setting options and staring loads for generic resource types.
Field Summary | |
---|---|
protected Context |
context
|
protected Glide |
glide
|
protected Lifecycle |
lifecycle
|
protected Class<ModelType> |
modelClass
|
protected RequestTracker |
requestTracker
|
protected Class<TranscodeType> |
transcodeClass
|
Method Summary | ||
---|---|---|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
animate(Animation animation)
Deprecated. If this builder is used for multiple loads, using this method will result in multiple view's being asked to start an animation using a single Animation object which results in
views animating repeatedly. Use animate(int) or
animate(com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator) . Scheduled to be removed in
Glide 4.0. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
animate(int animationId)
Sets an animation to run on the wrapped target when an resource load finishes. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,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. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
cacheDecoder(ResourceDecoder<File,ResourceType> cacheDecoder)
Sets the ResourceDecoder to use to load the resource from the disk cache. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
clone()
Returns a copy of this request builder with all of the options set so far on this builder. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
decoder(ResourceDecoder<DataType,ResourceType> decoder)
Sets the ResourceDecoder to use to load the resource from the original data. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
diskCacheStrategy(DiskCacheStrategy strategy)
Sets the DiskCacheStrategy to use for this load. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
dontAnimate()
Removes any existing animation set on the builder. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
dontTransform()
Removes the current Transformation . |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
encoder(ResourceEncoder<ResourceType> encoder)
Sets the Encoder to use to encode the original data directly to cache. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
error(Drawable drawable)
Sets a Drawable to display if a load fails. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
error(int resourceId)
Sets a resource to display if a load fails. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
fallback(Drawable drawable)
Sets an Drawable to display if the model provided to
load(Object) is null . |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
fallback(int resourceId)
Sets a resource to display if the model provided to load(Object) is null . |
|
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. |
|
FutureTarget<TranscodeType> |
into(int width,
int height)
Returns a future that can be used to do a blocking get on a background thread. |
|
|
into(Y target)
Set the target the resource will be loaded into. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
listener(RequestListener<? super ModelType,TranscodeType> requestListener)
Sets a RequestBuilder listener to monitor the resource load. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
load(ModelType model)
Sets the specific model to load data for. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
override(int width,
int height)
Overrides the Target 's width and height with the given values. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
placeholder(Drawable drawable)
Sets an Drawable to display while a resource is loading. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
placeholder(int resourceId)
Sets an Android resource id for a Drawable resourceto display while a resource
is loading. |
|
Target<TranscodeType> |
preload()
Preloads the resource into the cache using Target.SIZE_ORIGINAL as the target width and height. |
|
Target<TranscodeType> |
preload(int width,
int height)
Preloads the resource into the cache using the given width and height. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
priority(Priority priority)
Sets the priority for this load. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,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. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
sizeMultiplier(float sizeMultiplier)
Applies a multiplier to the Target 's size before loading the resource. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
skipMemoryCache(boolean skip)
Allows the loaded resource to skip the memory cache. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
sourceEncoder(Encoder<DataType> sourceEncoder)
Sets the source encoder to use to encode the data retrieved by this request directly into cache. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,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. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
thumbnail(GenericRequestBuilder<?,?,?,TranscodeType> thumbnailRequest)
Loads and displays the resource retrieved by the given thumbnail request if it finishes before this request. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
transcoder(ResourceTranscoder<ResourceType,TranscodeType> transcoder)
Sets the ResourceTranscoder to use for this load. |
|
GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> |
transform(Transformation<ResourceType>... transformations)
Transform resources with the given Transformation s. |
Methods inherited from class java.lang.Object |
---|
equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Field Detail |
---|
protected final Class<ModelType> modelClass
protected final Context context
protected final Glide glide
protected final Class<TranscodeType> transcodeClass
protected final RequestTracker requestTracker
protected final Lifecycle lifecycle
Method Detail |
---|
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> thumbnail(GenericRequestBuilder<?,?,?,TranscodeType> thumbnailRequest)
thumbnailRequest
- The request to use to load the thumbnail.
Recursive calls to thumbnail are supported.
public GenericRequestBuilder<ModelType,DataType,ResourceType,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, placeholder(int)
and error(int)
,
and 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.
sizeMultiplier
- The multiplier to apply to the Target
's dimensions when loading the thumbnail.
public GenericRequestBuilder<ModelType,DataType,ResourceType,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
- The multiplier to apply to the Target
's dimensions when loading the resource.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> decoder(ResourceDecoder<DataType,ResourceType> 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
- The ResourceDecoder
to use to decode the resource.
cacheDecoder(com.bumptech.glide.load.ResourceDecoder)
,
DiskCacheStrategy
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> cacheDecoder(ResourceDecoder<File,ResourceType> 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
- The decoder to use.
decoder(com.bumptech.glide.load.ResourceDecoder)
,
DiskCacheStrategy
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> sourceEncoder(Encoder<DataType> sourceEncoder)
sourceEncoder
- The encoder to use.
DiskCacheStrategy
public GenericRequestBuilder<ModelType,DataType,ResourceType,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
.
strategy
- The strategy to use.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> encoder(ResourceEncoder<ResourceType> 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
- The encoder to use.
sourceEncoder(com.bumptech.glide.load.Encoder)
,
DiskCacheStrategy
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> priority(Priority priority)
priority
- A priority.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> transform(Transformation<ResourceType>... transformations)
Transformation
s. Replaces any existing transformation or
transformations.
transformations
- the transformations to apply in order.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> dontTransform()
Transformation
.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> transcoder(ResourceTranscoder<ResourceType,TranscodeType> transcoder)
ResourceTranscoder
to use for this load.
transcoder
- The transcoder to use.
UnitTranscoder
,
GlideBitmapDrawableTranscoder
,
GifBitmapWrapperDrawableTranscoder
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> dontAnimate()
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> animate(int animationId)
animationId
- The resource id of the animation to run
@Deprecated public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> animate(Animation animation)
Animation
object which results in
views animating repeatedly. Use animate(int)
or
animate(com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator)
. Scheduled to be removed in
Glide 4.0.
animation
- The animation to run
animate(int)
,
animate(com.bumptech.glide.request.animation.ViewPropertyAnimation.Animator)
public GenericRequestBuilder<ModelType,DataType,ResourceType,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).
animator
- The ViewPropertyAnimation.Animator
to run.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> placeholder(int resourceId)
Drawable
resourceto display while a resource
is loading.
resourceId
- The id of the resource to use as a placeholder
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> placeholder(Drawable drawable)
Drawable
to display while a resource is loading.
drawable
- The drawable to display as a placeholder.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> fallback(Drawable drawable)
Drawable
to display if the model provided to
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.
drawable
- The drawable to display as a placeholder.
placeholder(Drawable)
,
placeholder(int)
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> fallback(int resourceId)
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.
resourceId
- The id of the resource to use as a fallback.
placeholder(Drawable)
,
placeholder(int)
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> error(int resourceId)
resourceId
- The id of the resource to use as a placeholder.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> error(Drawable drawable)
Drawable
to display if a load fails.
drawable
- The drawable to display.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> listener(RequestListener<? super ModelType,TranscodeType> requestListener)
requestListener
- The request listener to use.
public GenericRequestBuilder<ModelType,DataType,ResourceType,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.
skip
- True to allow the resource to skip the memory cache.
public GenericRequestBuilder<ModelType,DataType,ResourceType,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)
.
width
- The width in pixels to use to load the resource.height
- The height in pixels to use to load the resource.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> signature(Key signature)
Note - The signature does not replace the cache key, it is purely additive.
signature
- A unique non-null Key
representing the current state of the
model that will be mixed in to the cache key.
StringSignature
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> load(ModelType model)
This method must be called at least once before into(com.bumptech.glide.request.target.Target)
is
called.
model
- The model to load data for, or null.
public GenericRequestBuilder<ModelType,DataType,ResourceType,TranscodeType> clone()
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 Object
public <Y extends Target<TranscodeType>> Y into(Y target)
target
- The target to load the resource into.
Glide.clear(com.bumptech.glide.request.target.Target)
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.
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)
public FutureTarget<TranscodeType> into(int width, int height)
width
- The desired width in pixels, or Target.SIZE_ORIGINAL
. This will be overridden by
* (int, int)
if previously called.height
- The desired height in pixels, or Target.SIZE_ORIGINAL
. This will be overridden by
* (int, int)
} if previously called).
FutureTarget
that can be used to obtain the
resource in a blocking manner.Glide.clear(com.bumptech.glide.request.FutureTarget)
public Target<TranscodeType> preload(int width, int height)
Pre-loading is useful for making sure that resources you are going to to want in the near future are available quickly.
width
- The desired width in pixels, or Target.SIZE_ORIGINAL
. This will be overridden by
* (int, int)
if previously called.height
- The desired height in pixels, or Target.SIZE_ORIGINAL
. This will be overridden by
* (int, int)
} if previously called).
Target
that can be used to cancel the load via
Glide.clear(com.bumptech.glide.request.target.Target)
.ListPreloader
public Target<TranscodeType> preload()
Target.SIZE_ORIGINAL
as the target width and height.
Equivalent to calling preload(int, int)
with Target.SIZE_ORIGINAL
as the width and height.
Target
that can be used to cancel the load via
Glide.clear(com.bumptech.glide.request.target.Target)
.preload(int, int)
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |