RequestManager

open class RequestManager : LifecycleListener, ModelTypes<T>

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.

See also

Constructors

Link copied to clipboard
open fun RequestManager(    glide: Glide,     lifecycle: Lifecycle,     treeNode: RequestManagerTreeNode,     context: Context)

Functions

Link copied to clipboard
open fun addDefaultRequestListener(requestListener: RequestListener<Any>): RequestManager
Adds a default RequestListener that will be added to every request started with this RequestManager.
Link copied to clipboard
open fun applyDefaultRequestOptions(requestOptions: RequestOptions): RequestManager
Updates the default RequestOptions for all loads started with this request manager with the given RequestOptions.
Link copied to clipboard
open fun <ResourceType> as(resourceClass: Class<ResourceType>): RequestBuilder<ResourceType>
Attempts to load the resource using any registered s that can decode the given resource class or any subclass of the given resource class.
Link copied to clipboard
open fun asBitmap(): RequestBuilder<Bitmap>
Attempts to always load the resource as a android.graphics.
Link copied to clipboard
open fun asDrawable(): RequestBuilder<Drawable>
Attempts to always load the resource using any registered s that can decode any subclass of Drawable.
Link copied to clipboard
open fun asFile(): RequestBuilder<File>
Attempts to always load a File containing the resource, either using a file path obtained from the media store (for local images/videos), or using Glide's disk cache (for remote images/videos).
Link copied to clipboard
open fun asGif(): RequestBuilder<GifDrawable>
Attempts to always load the resource as a .
Link copied to clipboard
open fun clear(view: View)
Cancel any pending loads Glide may have for the view and free any resources that may have been loaded for the view.
open fun clear(target: Target<out Any>)
Cancel any pending loads Glide may have for the target and free any resources (such as s) that may have been loaded for the target so they may be reused.
Link copied to clipboard
open fun download(model: Any): RequestBuilder<File>
A helper method equivalent to calling downloadOnly ()} and then load with the given model.
Link copied to clipboard
open fun downloadOnly(): RequestBuilder<File>
Attempts always load the resource into the cache and return the File containing the cached source data.
Link copied to clipboard
open fun isPaused(): Boolean
Returns true if loads for this RequestManager are currently paused.
Link copied to clipboard
open fun load(bitmap: Bitmap): RequestBuilder<Drawable>
open fun load(drawable: Drawable): RequestBuilder<Drawable>
open fun load(uri: Uri): RequestBuilder<Drawable>
open fun load(model: Array<Byte>): RequestBuilder<Drawable>
open fun load(file: File): RequestBuilder<Drawable>
open fun load(resourceId: Integer): RequestBuilder<Drawable>
open fun load(string: String): RequestBuilder<Drawable>
open fun load(url: URL): RequestBuilder<Drawable>
Equivalent to calling asDrawable and then load.
open fun load(model: Any): RequestBuilder<Drawable>
A helper method equivalent to calling asDrawable and then load with the given model.
Link copied to clipboard
open fun onConfigurationChanged(newConfig: Configuration)
Link copied to clipboard
open fun onDestroy()
Lifecycle callback that cancels all in progress requests and clears and recycles resources for all completed requests.
Link copied to clipboard
open fun onLowMemory()
Link copied to clipboard
open fun onStart()
Lifecycle callback that registers for connectivity events (if the android.permission.ACCESS_NETWORK_STATE permission is present) and restarts failed or paused requests.
Link copied to clipboard
open fun onStop()
Lifecycle callback that unregisters for connectivity events (if the android.permission.ACCESS_NETWORK_STATE permission is present) and pauses in progress loads.
Link copied to clipboard
open fun onTrimMemory(level: Int)
Link copied to clipboard
open fun pauseAllRequests()
Cancels any in progress loads and clears resources of completed loads.
Link copied to clipboard
open fun pauseAllRequestsRecursive()
Performs pauseAllRequests recursively for all managers that are contextually descendant to this manager based on the Activity/Fragment hierarchy.
Link copied to clipboard
open fun pauseRequests()
Cancels any in progress loads, but does not clear resources of completed loads.
Link copied to clipboard
open fun pauseRequestsRecursive()
Performs pauseRequests recursively for all managers that are contextually descendant to this manager based on the Activity/Fragment hierarchy:
  • When pausing on an Activity all attached fragments will also get paused.
  • When pausing on an attached Fragment all descendant fragments will also get paused.
  • When pausing on a detached Fragment or the application context only the current RequestManager is paused.
Note, on pre-Jelly Bean MR1 calling pause on a Fragment will not cause child fragments to pause, in this case either call pause on the Activity or use a support Fragment.
Link copied to clipboard
open fun resumeRequests()
Restarts any loads that have not yet completed.
Link copied to clipboard
open fun resumeRequestsRecursive()
Performs resumeRequests recursively for all managers that are contextually descendant to this manager based on the Activity/Fragment hierarchy.
Link copied to clipboard
open fun setDefaultRequestOptions(requestOptions: RequestOptions): RequestManager
Replaces the default RequestOptions for all loads started with this request manager with the given RequestOptions.
Link copied to clipboard
open fun setPauseAllRequestsOnTrimMemoryModerate(pauseAllOnTrim: Boolean)
If true then clear all in-progress and completed requests when the platform sends onTrimMemory with level = TRIM_MEMORY_MODERATE.
Link copied to clipboard
open fun toString(): String