Skip to content

Commit

Permalink
Fix regression from coil3 migration
Browse files Browse the repository at this point in the history
Fixes #495

Co-authored-by: jobobby04 <17078382+jobobby04@users.noreply.github.com>
  • Loading branch information
AntsyLich and jobobby04 committed Mar 18, 2024
1 parent ebee275 commit 59bedb3
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 8 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -349,8 +349,9 @@ open class ReaderPageImageView @JvmOverloads constructor(
.diskCachePolicy(CachePolicy.DISABLED)
.target(
onSuccess = { result ->
setImageDrawable(result.asDrawable(context.resources))
(result as? Animatable)?.start()
val drawable = result.asDrawable(context.resources)
setImageDrawable(drawable)
(drawable as? Animatable)?.start()
isVisible = true
this@ReaderPageImageView.onImageLoaded()
},
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -77,19 +77,20 @@ object ImageUtil {
}

fun isAnimatedAndSupported(stream: InputStream): Boolean {
try {
return try {
val type = getImageType(stream) ?: return false
return when (type.format) {
// https://coil-kt.github.io/coil/getting_started/#supported-image-formats
when (type.format) {
Format.Gif -> true
// Coil supports animated WebP on Android 9.0+
// https://coil-kt.github.io/coil/getting_started/#supported-image-formats
// Animated WebP on Android 9+
Format.Webp -> type.isAnimated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.P
// Animated Heif on Android 11+
Format.Heif -> type.isAnimated && Build.VERSION.SDK_INT >= Build.VERSION_CODES.R
else -> false
}
} catch (e: Exception) {
/* Do Nothing */
false
}
return false
}

private fun getImageType(stream: InputStream): tachiyomi.decoder.ImageType? {
Expand Down

0 comments on commit 59bedb3

Please sign in to comment.