Refactor: fix deprecations
parent
8378b3dd90
commit
1b7c8355ec
@ -0,0 +1,20 @@
|
||||
package org.koitharu.kotatsu.utils.ext
|
||||
|
||||
import androidx.core.graphics.drawable.toBitmap
|
||||
import coil.request.ErrorResult
|
||||
import coil.request.RequestResult
|
||||
import coil.request.SuccessResult
|
||||
|
||||
fun RequestResult.requireBitmap() = when(this) {
|
||||
is SuccessResult -> drawable.toBitmap()
|
||||
is ErrorResult -> throw throwable
|
||||
}
|
||||
|
||||
fun RequestResult.toBitmapOrNull() = when(this) {
|
||||
is SuccessResult -> try {
|
||||
drawable.toBitmap()
|
||||
} catch (_: Throwable) {
|
||||
null
|
||||
}
|
||||
is ErrorResult -> null
|
||||
}
|
||||
Loading…
Reference in New Issue