mirror of
https://github.com/aniyomiorg/aniyomi.git
synced 2024-12-18 03:02:17 +03:00
parent
ddd180e56a
commit
8ef200861c
1 changed files with 17 additions and 15 deletions
|
@ -246,19 +246,19 @@ class WebtoonPageHolder(
|
|||
unsubscribeReadImageHeader()
|
||||
val streamFn = page?.stream ?: return
|
||||
|
||||
var openStream: InputStream? = null
|
||||
readImageHeaderSubscription = Observable
|
||||
.fromCallable {
|
||||
val stream = streamFn().buffered(16)
|
||||
val imageStream = process(stream)
|
||||
val isAnimated = ImageUtil.isAnimatedAndSupported(stream)
|
||||
Pair(imageStream, isAnimated)
|
||||
openStream = process(stream)
|
||||
|
||||
ImageUtil.isAnimatedAndSupported(stream)
|
||||
}
|
||||
.subscribeOn(Schedulers.io())
|
||||
.observeOn(AndroidSchedulers.mainThread())
|
||||
.doOnNext { (imageStream, isAnimated) ->
|
||||
imageStream.use {
|
||||
.doOnNext { isAnimated ->
|
||||
frame.setImage(
|
||||
it,
|
||||
openStream!!,
|
||||
isAnimated,
|
||||
ReaderPageImageView.Config(
|
||||
zoomDuration = viewer.config.doubleTapAnimDuration,
|
||||
|
@ -267,7 +267,9 @@ class WebtoonPageHolder(
|
|||
),
|
||||
)
|
||||
}
|
||||
}
|
||||
// Keep the Rx stream alive to close the input stream only when unsubscribed
|
||||
.flatMap { Observable.never<Unit>() }
|
||||
.doOnUnsubscribe { openStream?.close() }
|
||||
.subscribe({}, {})
|
||||
|
||||
addSubscription(readImageHeaderSubscription)
|
||||
|
|
Loading…
Reference in a new issue