TranscodeType
- The type of resource that will be delivered to the
Target
.public class RequestBuilder<TranscodeType> extends Object implements Cloneable
Modifier and Type | Field and Description |
---|---|
protected static RequestOptions |
DOWNLOAD_ONLY_OPTIONS |
protected RequestOptions |
requestOptions |
Modifier | Constructor and Description |
---|---|
protected |
RequestBuilder(Class<TranscodeType> transcodeClass,
RequestBuilder<?> other) |
protected |
RequestBuilder(Glide glide,
RequestManager requestManager,
Class<TranscodeType> transcodeClass) |
Modifier and Type | Method and Description |
---|---|
RequestBuilder<TranscodeType> |
apply(RequestOptions requestOptions)
Applies the given options to the request, options set or unset in the given options will
replace those previously set in options in this class.
|
RequestBuilder<TranscodeType> |
clone()
Returns a copy of this request builder with all of the options put so far on this builder.
|
FutureTarget<File> |
downloadOnly(int width,
int height)
Deprecated.
|
<Y extends Target<File>> |
downloadOnly(Y target)
Deprecated.
|
protected RequestBuilder<File> |
getDownloadOnlyRequest() |
protected RequestOptions |
getMutableOptions() |
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)
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 RequestBuilder listener to monitor the resource load.
|
RequestBuilder<TranscodeType> |
load(byte[] model)
Returns a request to load the given byte array.
|
RequestBuilder<TranscodeType> |
load(File file)
Returns a request builder to load the given
File . |
RequestBuilder<TranscodeType> |
load(Integer resourceId)
Returns a request builder to load the given resource id.
|
RequestBuilder<TranscodeType> |
load(Object model)
Sets the specific model to load data for.
|
RequestBuilder<TranscodeType> |
load(String string)
Returns a request builder to load the given
String . |
RequestBuilder<TranscodeType> |
load(Uri uri)
Returns a request builder to load the given
Uri . |
RequestBuilder<TranscodeType> |
load(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> 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. |
protected static final RequestOptions DOWNLOAD_ONLY_OPTIONS
@NonNull protected RequestOptions requestOptions
protected RequestBuilder(Glide glide, RequestManager requestManager, Class<TranscodeType> transcodeClass)
protected RequestBuilder(Class<TranscodeType> transcodeClass, RequestBuilder<?> other)
public RequestBuilder<TranscodeType> apply(@NonNull RequestOptions requestOptions)
RequestOptions.apply(RequestOptions)
protected RequestOptions getMutableOptions()
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.
public RequestBuilder<TranscodeType> listener(@Nullable RequestListener<TranscodeType> requestListener)
requestListener
- The request listener to use.public RequestBuilder<TranscodeType> thumbnail(@Nullable RequestBuilder<TranscodeType> thumbnailRequest)
thumbnailRequest
- The request to use to load the thumbnail. Recursive calls to thumbnail are supported.
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 Transformation
s. However,
RequestOptions.placeholder(int)
and
RequestOptions.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.
sizeMultiplier
- The multiplier to apply to the Target
's dimensions when loading
the thumbnail.public RequestBuilder<TranscodeType> load(@Nullable Object 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 RequestBuilder<TranscodeType> load(@Nullable String string)
String
. signature.
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
RequestOptions.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
RequestOptions.skipMemoryCache(boolean)
may be
appropriate.
string
- A file path, or a uri or url handled by
UriLoader
.load(Object)
public RequestBuilder<TranscodeType> load(@Nullable 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
RequestOptions.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
RequestOptions.skipMemoryCache(boolean)
may be
appropriate.
uri
- The Uri representing the image. Must be of a type handled by
UriLoader
.load(Object)
public RequestBuilder<TranscodeType> load(@Nullable 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
RequestOptions.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
RequestOptions.skipMemoryCache(boolean)
may be
appropriate.
file
- The File containing the imageload(Object)
public RequestBuilder<TranscodeType> load(@Nullable 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 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
RequestOptions.diskCacheStrategy(com.bumptech.glide.load.engine.DiskCacheStrategy)
during development, and re-enabling the default
DiskCacheStrategy.RESOURCE
for release builds.
load(Integer)
,
ApplicationVersionSignature
@Deprecated public RequestBuilder<TranscodeType> load(@Nullable 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)
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)
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.
public <Y extends Target<TranscodeType>> Y into(@NonNull Y target)
target
- The target to load the resource into.RequestManager.clear(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
.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
RequestOptions.override(int, int)
if
previously called.height
- The desired height in pixels, or Target.SIZE_ORIGINAL
. This will be
overridden by
RequestOptions.override(int, int)
} if
previously called).RequestManager.clear(Target)
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 RequestOptions.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)
public FutureTarget<TranscodeType> submit(int width, int height)
width
- The desired width in pixels, or Target.SIZE_ORIGINAL
. This will be
overridden by
RequestOptions.override(int, int)
if
previously called.height
- The desired height in pixels, or Target.SIZE_ORIGINAL
. This will be
overridden by
RequestOptions.override(int, int)
} if
previously called).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
RequestOptions.override(int, int)
if
previously called.height
- The desired height in pixels, or Target.SIZE_ORIGINAL
. This will be
overridden by
RequestOptions.override(int, int)
} if
previously called).Target
that can be used to cancel the load via
RequestManager.clear(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
RequestManager.clear(Target)
preload(int, int)
@Deprecated public <Y extends Target<File>> Y downloadOnly(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 public FutureTarget<File> downloadOnly(int width, int height)
RequestManager.downloadOnly()
and into(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.protected RequestBuilder<File> getDownloadOnlyRequest()