Skip to content

Commit

Permalink
fix gif support
Browse files Browse the repository at this point in the history
  • Loading branch information
az4521 committed Mar 31, 2024
1 parent 9d1b1ae commit 893415f
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 15 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -483,31 +483,30 @@ class PagerPageHolder(
*/
private fun ImageView.setImage(stream: InputStream) {
GlideApp.with(this)
.asGif()
.load(stream)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.transition(DrawableTransitionOptions.with(NoTransition.getFactory()))
.listener(object : RequestListener<Drawable> {
.listener(object : RequestListener<GifDrawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>,
target: Target<GifDrawable>,
isFirstResource: Boolean
): Boolean {
onImageDecodeError()
return false
}

override fun onResourceReady(
resource: Drawable,
resource: GifDrawable,
model: Any,
target: Target<Drawable>,
target: Target<GifDrawable>,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
if (resource is GifDrawable) {
resource.setLoopCount(GifDrawable.LOOP_INTRINSIC)
}
resource.setLoopCount(GifDrawable.LOOP_INTRINSIC)
onImageDecoded()
return false
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package eu.kanade.tachiyomi.ui.reader.viewer.webtoon

import android.annotation.SuppressLint
import android.content.res.Resources
import android.graphics.drawable.Drawable
import android.view.Gravity
import android.view.ViewGroup
import android.view.ViewGroup.LayoutParams.MATCH_PARENT
Expand Down Expand Up @@ -489,31 +488,30 @@ class WebtoonPageHolder(
*/
private fun ImageView.setImage(stream: InputStream) {
GlideApp.with(this)
.asGif()
.load(stream)
.skipMemoryCache(true)
.diskCacheStrategy(DiskCacheStrategy.NONE)
.transition(DrawableTransitionOptions.with(NoTransition.getFactory()))
.listener(object : RequestListener<Drawable> {
.listener(object : RequestListener<GifDrawable> {
override fun onLoadFailed(
e: GlideException?,
model: Any?,
target: Target<Drawable>,
target: Target<GifDrawable>,
isFirstResource: Boolean
): Boolean {
onImageDecodeError()
return false
}

override fun onResourceReady(
resource: Drawable,
resource: GifDrawable,
model: Any,
target: Target<Drawable>?,
target: Target<GifDrawable>?,
dataSource: DataSource,
isFirstResource: Boolean
): Boolean {
if (resource is GifDrawable) {
resource.setLoopCount(GifDrawable.LOOP_INTRINSIC)
}
resource.setLoopCount(GifDrawable.LOOP_INTRINSIC)
onImageDecoded()
return false
}
Expand Down

0 comments on commit 893415f

Please sign in to comment.