TranscodeType - The type of resource that will be delivered to the Target.public class RequestBuilder<TranscodeType> extends BaseRequestOptions<RequestBuilder<TranscodeType>> implements java.lang.Cloneable
| Modifier and Type | Field and Description |
|---|---|
protected static RequestOptions |
DOWNLOAD_ONLY_OPTIONS |
| Modifier | Constructor and Description |
|---|---|
protected |
RequestBuilder(java.lang.Class<TranscodeType> transcodeClass,
RequestBuilder<?> other) |
protected |
RequestBuilder(Glide glide,
RequestManager requestManager,
java.lang.Class<TranscodeType> transcodeClass,
android.content.Context context) |
| Modifier and Type | Method and Description |
|---|---|
RequestBuilder<TranscodeType> |
addListener(RequestListener<TranscodeType> requestListener)
Adds a
RequestListener. |
RequestBuilder<TranscodeType> |
apply(BaseRequestOptions<?> requestOptions)
Applies the given options to the request.
|
RequestBuilder<TranscodeType> |
clone()
Returns a copy of this request builder with all of the options put so far on this builder.
|
FutureTarget<java.io.File> |
downloadOnly(int width,
int height)
Deprecated.
|
<Y extends Target<java.io.File>> |
downloadOnly(Y target)
Deprecated.
|
RequestBuilder<TranscodeType> |
error(RequestBuilder<TranscodeType> errorBuilder)
Sets a
RequestBuilder that is built and run if the load started by this RequestBuilder fails. |
protected RequestBuilder<java.io.File> |
getDownloadOnlyRequest() |
ViewTarget<android.widget.ImageView,TranscodeType> |
into(android.widget.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)
Deprecated.
Use
submit(int, int) instead. |
<Y extends Target<TranscodeType>> |
into(Y target)
Set the target the resource will be loaded into.
|
RequestBuilder<TranscodeType> |
listener(RequestListener<TranscodeType> requestListener)
Sets a
RequestListener to monitor the resource load. |
RequestBuilder<TranscodeType> |
load(android.graphics.Bitmap bitmap)
Returns an object to load the given
Bitmap. |
RequestBuilder<TranscodeType> |
load(byte[] model)
Returns a request to load the given byte array.
|
RequestBuilder<TranscodeType> |
load(android.graphics.drawable.Drawable drawable)
Returns a request builder to load the given
Drawable. |
RequestBuilder<TranscodeType> |
load(java.io.File file)
Returns a request builder to load the given
File. |
RequestBuilder<TranscodeType> |
load(java.lang.Integer resourceId)
Returns a request builder that uses the
ModelLoaderFactory currently registered or Integer to
load the image represented by the given Integer resource id. |
RequestBuilder<TranscodeType> |
load(java.lang.Object model)
Sets the specific model to load data for.
|
RequestBuilder<TranscodeType> |
load(java.lang.String string)
Returns a request builder to load the given
String. |
RequestBuilder<TranscodeType> |
load(android.net.Uri uri)
Returns a request builder to load the given
Uri. |
RequestBuilder<TranscodeType> |
load(java.net.URL url)
Deprecated.
The
URL class has a number of
performance problems and should generally be avoided when possible. Prefer load(android.net.Uri) or load(String). |
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.
|
FutureTarget<TranscodeType> |
submit()
Returns a future that can be used to do a blocking get on a background thread.
|
FutureTarget<TranscodeType> |
submit(int width,
int height)
Returns a future that can be used to do a blocking get on a background thread.
|
RequestBuilder<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.
|
RequestBuilder<TranscodeType> |
thumbnail(RequestBuilder<TranscodeType>... thumbnails)
Recursively applies
thumbnail(RequestBuilder) so that the RequestBuilders are
loaded as thumbnails in the given priority order. |
RequestBuilder<TranscodeType> |
thumbnail(RequestBuilder<TranscodeType> thumbnailRequest)
Loads and displays the resource retrieved by the given thumbnail request if it finishes before
this request.
|
RequestBuilder<TranscodeType> |
transition(TransitionOptions<?,? super TranscodeType> transitionOptions)
Sets the
TransitionOptions to use to transition from the placeholder or thumbnail when
this load completes. |
autoClone, centerCrop, centerInside, circleCrop, decode, disallowHardwareConfig, diskCacheStrategy, dontAnimate, dontTransform, downsample, encodeFormat, encodeQuality, equals, error, error, fallback, fallback, fitCenter, format, frame, getDiskCacheStrategy, getErrorId, getErrorPlaceholder, getFallbackDrawable, getFallbackId, getOnlyRetrieveFromCache, getOptions, getOverrideHeight, getOverrideWidth, getPlaceholderDrawable, getPlaceholderId, getPriority, getResourceClass, getSignature, getSizeMultiplier, getTheme, getTransformations, getUseAnimationPool, getUseUnlimitedSourceGeneratorsPool, hashCode, isAutoCloneEnabled, isDiskCacheStrategySet, isLocked, isMemoryCacheable, isPrioritySet, isSkipMemoryCacheSet, isTransformationAllowed, isTransformationRequired, isTransformationSet, isValidOverride, lock, onlyRetrieveFromCache, optionalCenterCrop, optionalCenterInside, optionalCircleCrop, optionalFitCenter, optionalTransform, optionalTransform, override, override, placeholder, placeholder, priority, set, signature, sizeMultiplier, skipMemoryCache, theme, timeout, transform, transform, transform, transforms, useAnimationPool, useUnlimitedSourceGeneratorsPoolprotected static final RequestOptions DOWNLOAD_ONLY_OPTIONS
protected RequestBuilder(@NonNull
Glide glide,
RequestManager requestManager,
java.lang.Class<TranscodeType> transcodeClass,
android.content.Context context)
protected RequestBuilder(java.lang.Class<TranscodeType> transcodeClass, RequestBuilder<?> other)
@NonNull @CheckResult public RequestBuilder<TranscodeType> apply(@NonNull BaseRequestOptions<?> requestOptions)
As with BaseRequestOptions.apply(BaseRequestOptions), #apply only replaces those
values that are explicitly set in the given RequestOptions object. If you need to
completely reset all previously set options, create a new RequestBuilder instead of
using this method.
apply in class BaseRequestOptions<RequestBuilder<TranscodeType>>BaseRequestOptions.apply(BaseRequestOptions)@NonNull @CheckResult public RequestBuilder<TranscodeType> transition(@NonNull TransitionOptions<?,? super TranscodeType> transitionOptions)
TransitionOptions to use to transition from the placeholder or thumbnail when
this load completes.
The given TransitionOptions will replace any TransitionOptions set
previously.
@NonNull @CheckResult public RequestBuilder<TranscodeType> listener(@Nullable RequestListener<TranscodeType> requestListener)
RequestListener to monitor the resource load. It's best to create a single
instance of an exception handler per type of request (usually activity/fragment) rather than
pass one in per request to avoid some redundant object allocation.
Subsequent calls to this method will replace previously set listeners. To set multiple
listeners, use addListener(com.bumptech.glide.request.RequestListener<TranscodeType>) instead.
requestListener - The request listener to use.@NonNull @CheckResult public RequestBuilder<TranscodeType> addListener(@Nullable RequestListener<TranscodeType> requestListener)
RequestListener. If called multiple times, all passed listeners will be called in order.requestListener - The request listener to use. If null, this method is a noop.@NonNull public RequestBuilder<TranscodeType> error(@Nullable RequestBuilder<TranscodeType> errorBuilder)
RequestBuilder that is built and run if the load started by this RequestBuilder fails.
If this RequestBuilder uses a thumbnail that succeeds the given error RequestBuilder will be started anyway if the non-thumbnail request fails.
Recursive calls to this method as well as calls to thumbnail(float) and thumbnail(RequestBuilder) are supported for the given error RequestBuilder.
Unlike thumbnail(RequestBuilder) and thumbnail(float), no options from
this primary RequestBuilder are propagated to the given error RequestBuilder.
Options like priority, override widths and heights and transitions must be applied
independently to the error builder.
The given RequestBuilder will start and potentially override a fallback drawable if
it's set on this RequestBuilder via BaseRequestOptions.fallback(android.graphics.drawable.Drawable) or BaseRequestOptions.fallback(int).
RequestBuilder.@NonNull @CheckResult public RequestBuilder<TranscodeType> thumbnail(@Nullable RequestBuilder<TranscodeType> thumbnailRequest)
Recursive calls to thumbnail are supported.
Overrides any previous calls to this method, thumbnail(float) and thumbnail(RequestBuilder[]).
thumbnailRequest - The request to use to load the thumbnail.thumbnail(float),
thumbnail(RequestBuilder[])@NonNull @CheckResult public RequestBuilder<TranscodeType> thumbnail(@Nullable RequestBuilder<TranscodeType>... thumbnails)
thumbnail(RequestBuilder) so that the RequestBuilders are
loaded as thumbnails in the given priority order.
thumbnail(RequestBuilder) is applied in the order given so that the RequestBuilder at position 0 has the RequestBuilder at position 1 applied as using its
thumbnail method, the RequestBuilder at position 1 has the RequestBuilder at
position 2 applied using its thumbnail method and so on.
Calling this method with an null array of RequestBuilder thumbnails or an
empty array of RequestBuilder thumbnails is equivalent to calling thumbnail(RequestBuilder) with null.
Any individual RequestBuilder in the array of thumbnails provided here may be null. null RequestBuilders are ignored and excluded from the recursive chain.
The RequestBuilder objects provided here may be mutated and have any previous calls
to this method or thumbnail(RequestBuilder) methods overridden.
Overrides any previous calls to thumbnail(RequestBuilder), thumbnail(float) and this method.
thumbnail(float),
thumbnail(RequestBuilder)@NonNull @CheckResult public RequestBuilder<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 Transformations. However, BaseRequestOptions.placeholder(int) and BaseRequestOptions.error(int), and listener(RequestListener)
will only be used on the full size load and will not be copied for the thumbnail load.
Recursive calls to thumbnail are supported.
Overrides any previous calls to this method, thumbnail(RequestBuilder[]), and
thumbnail(RequestBuilder).
sizeMultiplier - The multiplier to apply to the Target's dimensions when loading
the thumbnail.thumbnail(RequestBuilder),
thumbnail(RequestBuilder[])@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@Nullable java.lang.Object model)
model - The model to load data for, or null.@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@Nullable android.graphics.Bitmap bitmap)
Bitmap.
It's almost always better to allow Glide to load Bitmaps than pass Bitmaps
into Glide. If you have a custom way to obtain Bitmaps that is not supported by Glide
by default, consider registering a custom ModelLoader or
ResourceDecoder instead of using this method.
The DiskCacheStrategy is set to DiskCacheStrategy.NONE. Previous calls to
apply(BaseRequestOptions) or previously applied DiskCacheStrategys will be
overridden by this method. Applying an DiskCacheStrategy other than DiskCacheStrategy.NONE after calling this method may result in undefined behavior.
In memory caching relies on Object equality. The contents of the Bitmaps are not
compared.
load(Object)@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@Nullable android.graphics.drawable.Drawable drawable)
Drawable.
It's almost always better to allow Glide to load Bitmaps than to pass Bitmaps into Glide using this method . If you have a custom way to obtain Bitmaps that
is not supported by Glide by default, consider registering a custom ModelLoader or ResourceDecoder
instead of using this method.
The DiskCacheStrategy is set to DiskCacheStrategy.NONE. Previous calls to
apply(BaseRequestOptions) or previously applied DiskCacheStrategys will be
overridden by this method. Applying an DiskCacheStrategy other than DiskCacheStrategy.NONE after calling this method may result in undefined behavior.
In memory caching relies on Object equality. The contents of the Drawables are not
compared.
load(Object)@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@Nullable java.lang.String string)
String.
Note - this method caches data using only the given String as the cache key. If the data is
a Uri outside of your control, or you otherwise expect the data represented by the given String
to change without the String identifier changing, Consider using BaseRequestOptions.signature(com.bumptech.glide.load.Key) to mixin a
signature you create that identifies the data currently at the given String that will
invalidate the cache if that data changes. Alternatively, using DiskCacheStrategy.NONE and/or BaseRequestOptions.skipMemoryCache(boolean) may be appropriate.
string - A file path, or a uri or url handled by UriLoader.load(Object)@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@Nullable android.net.Uri uri)
Uri.
Note - this method caches data at Uris using only the Uri itself as the cache key. The data
represented by Uris from some content providers may change without the Uri changing, which
means using this method can lead to displaying stale data. Consider using BaseRequestOptions.signature(com.bumptech.glide.load.Key) to mixin a
signature you create based on the data at the given Uri that will invalidate the cache if that
data changes. Alternatively, using DiskCacheStrategy.NONE and/or BaseRequestOptions.skipMemoryCache(boolean) may be appropriate.
uri - The Uri representing the image. Must be of a type handled by UriLoader.load(Object)@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@Nullable java.io.File file)
File.
Note - this method caches data for Files using only the file path itself as the cache key.
The data in the File can change so using this method can lead to displaying stale data. If you
expect the data in the File to change, Consider using BaseRequestOptions.signature(com.bumptech.glide.load.Key) to mixin a
signature you create that identifies the data currently in the File that will invalidate the
cache if that data changes. Alternatively, using DiskCacheStrategy.NONE and/or BaseRequestOptions.skipMemoryCache(boolean) may be appropriate.
file - The File containing the imageload(Object)@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@RawRes @DrawableRes @Nullable java.lang.Integer resourceId)
ModelLoaderFactory currently registered or Integer to
load the image represented by the given Integer resource id. Defaults to ResourceLoader to load resource id models.
By default this method adds a version code and night mode based signature to the cache key
used to cache this resource in Glide. This signature is sufficient to guarantee that end users
will see the most up to date versions of your Drawables, but during development if you do not
increment your version code before each install and you replace a Drawable with different data
without changing the Drawable name, you may see inconsistent cached data. To get around this,
consider using DiskCacheStrategy.NONE via BaseRequestOptions.diskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy) during
development, and re-enabling the default DiskCacheStrategy.RESOURCE for release builds.
This method will load non-Bitmap resources like VectorDrawables. Although Glide makes a best effort to apply Transformations to these Drawables by either extracting the
underlying Bitmap or by converting the Drawable to a Bitmap, Glide is
still not able to transform all types of resources. Animated Drawables cannot be
transformed (other than GifDrawable). To avoid
load failures if a Drawable can't be transformed, use the optional transformation
methods like BaseRequestOptions.optionalTransform(Class, Transformation).
In some cases converting Drawables to Bitmaps may be inefficient. Use this
method, especially in conjunction with Transformations with
caution for non-Bitmap Drawables.
load(Integer),
AndroidResourceSignature@Deprecated @CheckResult public RequestBuilder<TranscodeType> load(@Nullable java.net.URL url)
URL class has a number of
performance problems and should generally be avoided when possible. Prefer load(android.net.Uri) or load(String).URL.url - The URL representing the image.load(Object)@NonNull @CheckResult public RequestBuilder<TranscodeType> load(@Nullable byte[] model)
Note - by default loads for bytes are not cached in either the memory or the disk cache.
model - the data to load.load(Object)@CheckResult public RequestBuilder<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 BaseRequestOptions<RequestBuilder<TranscodeType>>@NonNull public <Y extends Target<TranscodeType>> Y into(@NonNull Y target)
target - The target to load the resource into.RequestManager.clear(Target)@NonNull public ViewTarget<android.widget.ImageView,TranscodeType> into(@NonNull android.widget.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.RequestManager.clear(Target)@Deprecated public FutureTarget<TranscodeType> into(int width, int height)
submit(int, int) instead.width - The desired width in pixels, or Target.SIZE_ORIGINAL. This will be
overridden by BaseRequestOptions.override(int, int) if
previously called.height - The desired height in pixels, or Target.SIZE_ORIGINAL. This will be
overridden by BaseRequestOptions.override(int, int)} if
previously called).RequestManager.clear(Target)@NonNull public FutureTarget<TranscodeType> submit()
This method defaults to Target.SIZE_ORIGINAL for the width and the height. However,
since the width and height will be overridden by values passed to BaseRequestOptions.override(int, int), this method can be used whenever RequestOptions
with override values are applied, or whenever you want to retrieve the image in its original
size.
submit(int, int),
into(Target)@NonNull public FutureTarget<TranscodeType> submit(int width, int height)
width - The desired width in pixels, or Target.SIZE_ORIGINAL. This will be
overridden by BaseRequestOptions.override(int, int) if
previously called.height - The desired height in pixels, or Target.SIZE_ORIGINAL. This will be
overridden by BaseRequestOptions.override(int, int)} if
previously called).@NonNull 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 BaseRequestOptions.override(int, int) if
previously called.height - The desired height in pixels, or Target.SIZE_ORIGINAL. This will be
overridden by BaseRequestOptions.override(int, int)} if
previously called).Target that can be used to cancel the load via RequestManager.clear(Target).ListPreloader@NonNull 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 RequestManager.clear(Target)preload(int, int)@Deprecated @CheckResult public <Y extends Target<java.io.File>> Y downloadOnly(@NonNull Y target)
RequestManager.downloadOnly() and into(Target).Y - The type of Target.target - The Target that will receive the cache File when the load completes@Deprecated @CheckResult public FutureTarget<java.io.File> downloadOnly(int width, int height)
RequestManager.downloadOnly() and submit(int, int).Future that can be used to retrieve the cache File containing the data.width - The width in pixels to use to fetch the data.height - The height in pixels to use to fetch the data.Future that can be used to retrieve the cache File
containing the data.@NonNull @CheckResult protected RequestBuilder<java.io.File> getDownloadOnlyRequest()