update glide usage from ver bump

This commit is contained in:
Hailey
2024-11-10 15:03:22 -08:00
parent 194808cc3b
commit 932fc75f96
@@ -5,6 +5,7 @@ import android.graphics.Color
import android.graphics.drawable.Animatable import android.graphics.drawable.Animatable
import android.graphics.drawable.Drawable import android.graphics.drawable.Drawable
import com.bumptech.glide.Glide import com.bumptech.glide.Glide
import com.bumptech.glide.load.DataSource
import com.bumptech.glide.load.engine.DiskCacheStrategy import com.bumptech.glide.load.engine.DiskCacheStrategy
import com.bumptech.glide.load.engine.GlideException import com.bumptech.glide.load.engine.GlideException
import com.bumptech.glide.request.RequestListener import com.bumptech.glide.request.RequestListener
@@ -85,29 +86,25 @@ class GifView(
.load(source) .load(source)
.diskCacheStrategy(DiskCacheStrategy.DATA) .diskCacheStrategy(DiskCacheStrategy.DATA)
.skipMemoryCache(false) .skipMemoryCache(false)
.listener( .listener(object : RequestListener<Drawable> {
object : RequestListener<Drawable> {
override fun onResourceReady( override fun onResourceReady(
resource: Drawable?, resource: Drawable,
model: Any?, model: Any,
target: Target<Drawable>?, target: Target<Drawable>?,
dataSource: com.bumptech.glide.load.DataSource?, dataSource: DataSource,
isFirstResource: Boolean, isFirstResource: Boolean
): Boolean { ): Boolean {
if (placeholderRequest != null) { isLoaded = true
glide.clear(placeholderRequest)
}
return false return false
} }
override fun onLoadFailed( override fun onLoadFailed(
e: GlideException?, e: GlideException?,
model: Any?, model: Any?,
target: Target<Drawable>?, target: Target<Drawable>,
isFirstResource: Boolean, isFirstResource: Boolean
): Boolean = true ): Boolean = true
}, }).into(this.imageView)
).into(this.imageView)
if (this.imageView.drawable == null || this.imageView.drawable !is Animatable) { if (this.imageView.drawable == null || this.imageView.drawable !is Animatable) {
this.placeholderRequest = this.placeholderRequest =
@@ -119,11 +116,11 @@ class GifView(
.listener( .listener(
object : RequestListener<Drawable> { object : RequestListener<Drawable> {
override fun onResourceReady( override fun onResourceReady(
resource: Drawable?, resource: Drawable,
model: Any?, model: Any,
target: Target<Drawable>?, target: Target<Drawable>?,
dataSource: com.bumptech.glide.load.DataSource?, dataSource: DataSource,
isFirstResource: Boolean, isFirstResource: Boolean
): Boolean { ): Boolean {
// Incase this request finishes after the webp, let's just not set // Incase this request finishes after the webp, let's just not set
// the drawable. This shouldn't happen because the request should get cancelled // the drawable. This shouldn't happen because the request should get cancelled
@@ -136,8 +133,8 @@ class GifView(
override fun onLoadFailed( override fun onLoadFailed(
e: GlideException?, e: GlideException?,
model: Any?, model: Any?,
target: Target<Drawable>?, target: Target<Drawable>,
isFirstResource: Boolean, isFirstResource: Boolean
): Boolean = true ): Boolean = true
}, },
).submit() ).submit()