|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Object com.bumptech.glide.RequestManager
public class RequestManager
A class for managing and starting requests for Glide. Can use activity, fragment and connectivity lifecycle events to intelligently stop, start, and restart requests. Retrieve either by instantiating a new object, or to take advantage built in Activity and Fragment lifecycle handling, use the static Glide.load methods with your Fragment or Activity.
Glide.with(android.app.Activity)
,
Glide.with(android.support.v4.app.FragmentActivity)
,
Glide.with(android.app.Fragment)
,
Glide.with(android.support.v4.app.Fragment)
,
Glide.with(Context)
Nested Class Summary | |
---|---|
static interface |
RequestManager.DefaultOptions
An interface that allows a default set of options to be applied to all requests started from an RequestManager . |
class |
RequestManager.GenericModelRequest<A,T>
A helper class for building requests with custom ModelLoader s that requires the user to provide a
specific model. |
class |
RequestManager.ImageModelRequest<T>
A helper class for building requests with custom ModelLoader s that translate models to
InputStream resources for loading images. |
class |
RequestManager.VideoModelRequest<T>
A helper class for building requests with custom ModelLoader s that translate models to
ParcelFileDescriptor resources for loading video thumbnails. |
Constructor Summary | |
---|---|
RequestManager(Context context,
Lifecycle lifecycle)
|
Method Summary | ||
---|---|---|
boolean |
isPaused()
Returns true if loads for this RequestManager are currently paused. |
|
DrawableTypeRequest<byte[]> |
load(byte[] model)
Use a new StreamByteArrayLoader to load an image from the given model. |
|
DrawableTypeRequest<byte[]> |
load(byte[] model,
String id)
Use a new StreamByteArrayLoader to load an image from the given model. |
|
DrawableTypeRequest<File> |
load(File file)
Use the ModelLoaderFactory currently registered for File to load
the image represented by the given File . |
|
DrawableTypeRequest<Integer> |
load(Integer resourceId)
Use the ModelLoaderFactory currently registered for Integer to load
the image represented by the given Integer resource id. |
|
DrawableTypeRequest<String> |
load(String string)
Use the ModelLoaderFactory currently registered for String to load
the image represented by the given String . |
|
|
load(T model)
Use the ModelLoaderFactory s currently registered for the given model type
for InputStream s and ParcelFileDescriptor s to load a thumbnail from either the image or the video
represented by the given model. |
|
DrawableTypeRequest<Uri> |
load(Uri uri)
Use the ModelLoaderFactory currently registered for Uri to load the
image at the given uri. |
|
DrawableTypeRequest<URL> |
load(URL url)
Use the ModelLoaderFactory currently registered for URL to load the
image represented by the given URL . |
|
DrawableTypeRequest<Uri> |
loadFromMediaStore(Uri uri,
String mimeType,
long dateModified,
int orientation)
Use MediaStore.Images.Thumbnails and
MediaStore.Video.Thumbnails to retrieve pre-generated thumbnails for the given uri. |
|
void |
onDestroy()
Lifecycle callback that cancels all in progress requests and clears and recycles resources for all completed requests. |
|
void |
onStart()
Lifecycle callback that registers for connectivity events (if the android.permission.ACCESS_NETWORK_STATE permission is present) and restarts failed or paused requests. |
|
void |
onStop()
Lifecycle callback that unregisters for connectivity events (if the android.permission.ACCESS_NETWORK_STATE permission is present) and pauses in progress loads. |
|
void |
pauseRequests()
Cancels any in progress loads, but does not clear resources of completed loads. |
|
void |
resumeRequests()
Restarts any loads that have not yet completed. |
|
void |
setDefaultOptions(RequestManager.DefaultOptions options)
Sets an interface that can apply some default options to all Requests started using this RequestManager . |
|
|
using(FileDescriptorModelLoader<T> modelLoader)
Set the ModelLoader to use for a new load where the model loader translates from a model to an
ParcelFileDescriptor resource for loading video thumbnails. |
|
|
using(ModelLoader<A,T> modelLoader,
Class<T> dataClass)
Use the given generic model loader to load the given generic data class. |
|
RequestManager.ImageModelRequest<byte[]> |
using(StreamByteArrayLoader modelLoader)
A convenience method to use a StreamByteArrayLoader to decode an image from a byte array. |
|
|
using(StreamModelLoader<T> modelLoader)
Set the ModelLoader to use for for a new load where the model loader translates from a model to an
InputStream resource for loading images. |
Methods inherited from class java.lang.Object |
---|
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
public RequestManager(Context context, Lifecycle lifecycle)
Method Detail |
---|
public void setDefaultOptions(RequestManager.DefaultOptions options)
RequestManager
.
Note - These options will be retained for the life the of this RequestManager
so be wary of using
GenericRequestBuilder.listener(com.bumptech.glide.request.RequestListener)
} when
starting requests using an Context
or Application
to avoid
leaking memory. Any option that does not use an anonymous inner class is generally safe.
options
- The default options to apply to all requests.public boolean isPaused()
RequestManager
are currently paused.
pauseRequests()
,
resumeRequests()
public void pauseRequests()
isPaused()
,
resumeRequests()
public void resumeRequests()
isPaused()
,
pauseRequests()
public void onStart()
onStart
in interface LifecycleListener
public void onStop()
onStop
in interface LifecycleListener
public void onDestroy()
onDestroy
in interface LifecycleListener
public <A,T> RequestManager.GenericModelRequest<A,T> using(ModelLoader<A,T> modelLoader, Class<T> dataClass)
Warning - This is an experimental api that may change without a change in major version.
A
- The type of the model to be loaded.T
- The type of the data to be loaded from the mode.modelLoader
- The ModelLoader
class to use to load the model.dataClass
- The type of data the ModelLoader
will load.
RequestManager.GenericModelRequest
to set options for the load and ultimately the target to load the model
into.public <T> RequestManager.ImageModelRequest<T> using(StreamModelLoader<T> modelLoader)
ModelLoader
to use for for a new load where the model loader translates from a model to an
InputStream
resource for loading images.
T
- The type of the model.modelLoader
- The model loader to use.
RequestManager.ImageModelRequest
.public RequestManager.ImageModelRequest<byte[]> using(StreamByteArrayLoader modelLoader)
StreamByteArrayLoader
to decode an image from a byte array.
modelLoader
- The byte array loader.
RequestManager.ImageModelRequest
.public <T> RequestManager.VideoModelRequest<T> using(FileDescriptorModelLoader<T> modelLoader)
ModelLoader
to use for a new load where the model loader translates from a model to an
ParcelFileDescriptor
resource for loading video thumbnails.
T
- The type of the model.modelLoader
- The model loader to use.
RequestManager.VideoModelRequest
.public DrawableTypeRequest<String> load(String string)
ModelLoaderFactory
currently registered for String
to load
the image represented by the given String
. Defaults to
StreamStringLoader.Factory
and
StreamStringLoader
to load the given model.
string
- The string representing the image. Must be either a path, or a uri handled by
StreamUriLoader
DrawableTypeRequest
to set options for the load and ultimately the target to load the model
into.using(StreamModelLoader)
public DrawableTypeRequest<Uri> load(Uri uri)
ModelLoaderFactory
currently registered for Uri
to load the
image at the given uri. Defaults to StreamUriLoader.Factory
and
StreamUriLoader
.
uri
- The uri representing the image. Must be a uri handled by
StreamUriLoader
DrawableTypeRequest
to set options for the load and ultimately the target to load the model
into.using(StreamModelLoader)
public DrawableTypeRequest<Uri> loadFromMediaStore(Uri uri, String mimeType, long dateModified, int orientation)
MediaStore.Images.Thumbnails
and
MediaStore.Video.Thumbnails
to retrieve pre-generated thumbnails for the given uri.
Falls back to the registered ModelLoaderFactory
registered for
Uri
s if the given uri is not a media store uri or if no pre-generated thumbnail exists for the given
uri. In addition, mixes the given mimeType, dateModified, and orientation into the cache key to detect and
invalidate thumbnails if content is changed locally.
uri
- The uri representing the media.mimeType
- The mime type of the media store media. Ok to default to empty string "". See
MediaStore.MediaColumns.MIME_TYPE
or
MediaStore.MediaColumns.MIME_TYPE
.dateModified
- The date modified time of the media store media. Ok to default to 0. See
MediaStore.MediaColumns.DATE_MODIFIED
or
MediaStore.MediaColumns.DATE_MODIFIED
.orientation
- The orientation of the media store media. Ok to default to 0. See
MediaStore.Images.ImageColumns.ORIENTATION
.
DrawableRequestBuilder
to set options for the load and ultimately the target to load the
uri into.public DrawableTypeRequest<File> load(File file)
ModelLoaderFactory
currently registered for File
to load
the image represented by the given File
. Defaults to
StreamFileLoader.Factory
and
StreamFileLoader
to load the given model.
file
- The File containing the image
DrawableTypeRequest
to set options for the load and ultimately the target to load the model
into.using(StreamModelLoader)
public DrawableTypeRequest<Integer> load(Integer resourceId)
ModelLoaderFactory
currently registered for Integer
to load
the image represented by the given Integer
resource id. Defaults to
StreamResourceLoader.Factory
and
StreamResourceLoader
to load the given model.
resourceId
- the id of the resource containing the image
DrawableTypeRequest
to set options for the load and ultimately the target to load the model
into.using(StreamModelLoader)
public DrawableTypeRequest<URL> load(URL url)
ModelLoaderFactory
currently registered for URL
to load the
image represented by the given URL
. Defaults to
HttpUrlGlideUrlLoader
and
HttpUrlFetcher
to load the given model.
url
- The URL representing the image.
DrawableTypeRequest
to set options for the load and ultimately the target to load the model
into.using(StreamModelLoader)
public DrawableTypeRequest<byte[]> load(byte[] model, String id)
StreamByteArrayLoader
to load an image from the given model.
model
- The data to load.id
- A unique id that identifies the image represented by the model suitable for use as a cache key
(url, filepath etc). If there is no suitable id, use load(byte[])
instaed.
DrawableTypeRequest
to set options for the load and ultimately the target to load the image
into.load(byte[])
public DrawableTypeRequest<byte[]> load(byte[] model)
StreamByteArrayLoader
to load an image from the given model. Suitable when there is no
simple id that represents the given data.
model
- the data to load.
DrawableTypeRequest
to set options for the load and ultimately the target to load the image
into.public <T> DrawableTypeRequest<T> load(T model)
ModelLoaderFactory
s currently registered for the given model type
for InputStream
s and ParcelFileDescriptor
s to load a thumbnail from either the image or the video
represented by the given model.
T
- The type of the model to load.model
- The model the load.
DrawableTypeRequest
to set options for the load and ultimately the target to load the image
into.
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |