[Glide] Add Gif support with GlideImage
See original GitHub issueThe LocalGlideProvider
only supports Drawable?
:
public val LocalGlideRequestBuilder: ProvidableCompositionLocal<RequestBuilder<Drawable>?> =
staticCompositionLocalOf { null }
By changing this to support GifDrawable?
, we can support Glide’s .asGif()
:
/**
* Local containing the preferred [RequestOptions] for providing the same instance
* in our composable hierarchy.
*/
public val LocalGlideGifRequestOptions: ProvidableCompositionLocal<RequestOptions?> =
staticCompositionLocalOf { null }
/**
* Local containing the preferred [RequestBuilder] for providing the same instance
* in our composable hierarchy.staticCompositionLocalOf
*/
public val LocalGlideGifRequestBuilder: ProvidableCompositionLocal<RequestBuilder<GifDrawable>?> =
staticCompositionLocalOf { null }
/**
* Local containing the preferred [RequestManager] for providing the same instance
* in our composable hierarchy.staticCompositionLocalOf
*/
public val LocalGlideGifRequestManager: ProvidableCompositionLocal<RequestManager?> =
staticCompositionLocalOf { null }
/** A provider for taking the local instances related to the `GlideImage`. */
internal object LocalGlideGifProvider {
/** Returns the current or default [RequestOptions] for the `GlideImage` parameter. */
@Composable
fun getGlideRequestOptions(): RequestOptions {
return LocalGlideGifRequestOptions.current ?: RequestOptions()
}
/** Returns the current or default [RequestBuilder] for the `GlideImage` parameter. */
@Composable
fun getGlideRequestBuilder(): RequestBuilder<GifDrawable> {
return LocalGlideGifRequestBuilder.current
?: getGlideRequestManager()
.asGif()
}
/** Returns the current or default [RequestManager] for the `GlideImage` processor. */
@Composable
fun getGlideRequestManager(): RequestManager {
// By default Glide tries to install lifecycle listeners to automatically re-trigger
// requests when resumed. We don't want that with Compose, since we rely on composition
// for our 'lifecycle'. We can stop Glide doing this by using the application context.
return LocalGlideGifRequestManager.current
?: GlideApp.with(LocalContext.current.applicationContext)
}
}
Can we provide a LocalGlideGifProvider
, LocalGlideBitmapProvider
and LocalGlideDrawableProvider
providers?
Issue Analytics
- State:
- Created a year ago
- Comments:6 (4 by maintainers)
Top Results From Across the Web
Show GIF file with Glide (image loading and caching library)
The above answer didn't work for me. The below code works. ImageView imageView = (ImageView) findViewById(R.id.imageView); GlideDrawableImageViewTarget ...
Read more >Load image and GIF using Glide - Medium
First, we will add Glide on our build.gradle (app level), like this: apply plugin: 'com.android.application' apply plugin: 'kotlin-android'
Read more >Displaying Images with the Glide Library - CodePath Cliffnotes
Glide is an Image Loader Library for Android developed by bumptech and is a library ... It provides animated GIF support and handles...
Read more >Glide v4 : Fast and efficient image loading for Android
Glide supports fetching, decoding, and displaying video stills, images, and animated GIFs. Glide includes a flexible api that allows developers to plug in ......
Read more >Loading images for Jetpack Compose using ... - ProAndroidDev
This library also supports loading animated images such as GIFs, WebP and ... You can load images simply by using GlideImage composable function...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
@skydoves Thanks. I got it working. I appreciate the update.
The example below works well for me 🤔