mirror of
https://github.com/null2264/yokai.git
synced 2025-06-21 10:44:42 +00:00
Handle webtoon page load crash
This commit is contained in:
parent
8ab47139f2
commit
63f9ed84ab
1 changed files with 12 additions and 6 deletions
|
@ -29,6 +29,7 @@ import kotlinx.coroutines.flow.collectLatest
|
||||||
import kotlinx.coroutines.launch
|
import kotlinx.coroutines.launch
|
||||||
import kotlinx.coroutines.supervisorScope
|
import kotlinx.coroutines.supervisorScope
|
||||||
import kotlinx.coroutines.suspendCancellableCoroutine
|
import kotlinx.coroutines.suspendCancellableCoroutine
|
||||||
|
import timber.log.Timber
|
||||||
import java.io.BufferedInputStream
|
import java.io.BufferedInputStream
|
||||||
import java.io.InputStream
|
import java.io.InputStream
|
||||||
|
|
||||||
|
@ -231,14 +232,19 @@ class WebtoonPageHolder(
|
||||||
|
|
||||||
val streamFn = page?.stream ?: return
|
val streamFn = page?.stream ?: return
|
||||||
|
|
||||||
val (openStream, isAnimated) = withIOContext {
|
val (openStream, isAnimated) = try {
|
||||||
|
withIOContext {
|
||||||
val stream = streamFn().buffered(16)
|
val stream = streamFn().buffered(16)
|
||||||
val openStream = process(stream)
|
val openStream = process(stream)
|
||||||
|
|
||||||
val isAnimated = ImageUtil.isAnimatedAndSupported(stream)
|
val isAnimated = ImageUtil.isAnimatedAndSupported(stream)
|
||||||
Pair(openStream, isAnimated)
|
Pair(openStream, isAnimated)
|
||||||
}
|
}
|
||||||
|
} catch (e: Exception) {
|
||||||
|
Timber.e(e)
|
||||||
|
setError()
|
||||||
|
return
|
||||||
|
}
|
||||||
withUIContext {
|
withUIContext {
|
||||||
frame.setImage(
|
frame.setImage(
|
||||||
openStream,
|
openStream,
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue