mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
refactor: Simplify code
This commit is contained in:
parent
b4317f8f3b
commit
e49e4f2895
2 changed files with 21 additions and 12 deletions
|
@ -225,11 +225,7 @@ open class ReaderPageImageView @JvmOverloads constructor(
|
|||
)
|
||||
|
||||
val useCoilPipeline = if (isWebtoon) {
|
||||
when (data) {
|
||||
is BitmapDrawable -> !ImageUtil.isMaxTextureSizeExceeded(data.bitmap)
|
||||
is BufferedSource -> !ImageUtil.isMaxTextureSizeExceeded(data)
|
||||
else -> false
|
||||
}
|
||||
!ImageUtil.isMaxTextureSizeExceeded(data)
|
||||
} else {
|
||||
false
|
||||
}
|
||||
|
|
|
@ -783,12 +783,25 @@ object ImageUtil {
|
|||
"image/jxl" to "jxl",
|
||||
)
|
||||
|
||||
fun isMaxTextureSizeExceeded(bitmap: Bitmap): Boolean {
|
||||
return maxOf(bitmap.width, bitmap.height) > GLUtil.maxTextureSize
|
||||
}
|
||||
|
||||
fun isMaxTextureSizeExceeded(imageSource: BufferedSource): Boolean {
|
||||
val opts = extractImageOptions(imageSource)
|
||||
return maxOf(opts.outWidth, opts.outHeight) > GLUtil.maxTextureSize
|
||||
fun isMaxTextureSizeExceeded(data: Any): Boolean {
|
||||
val width: Int
|
||||
val height: Int
|
||||
when (data) {
|
||||
is BufferedSource -> {
|
||||
val opts = extractImageOptions(data)
|
||||
width = opts.outWidth
|
||||
height = opts.outHeight
|
||||
}
|
||||
is BitmapDrawable -> {
|
||||
width = data.bitmap.width
|
||||
height = data.bitmap.height
|
||||
}
|
||||
is Bitmap -> {
|
||||
width = data.width
|
||||
height = data.height
|
||||
}
|
||||
else -> throw IllegalArgumentException("Not implemented for class ${data::class.simpleName}")
|
||||
}
|
||||
return maxOf(width, height) > GLUtil.maxTextureSize
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue