mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-23 01:11:48 +01:00
parent
ddd180e56a
commit
8ef200861c
@ -246,28 +246,30 @@ class WebtoonPageHolder(
|
|||||||
unsubscribeReadImageHeader()
|
unsubscribeReadImageHeader()
|
||||||
val streamFn = page?.stream ?: return
|
val streamFn = page?.stream ?: return
|
||||||
|
|
||||||
|
var openStream: InputStream? = null
|
||||||
readImageHeaderSubscription = Observable
|
readImageHeaderSubscription = Observable
|
||||||
.fromCallable {
|
.fromCallable {
|
||||||
val stream = streamFn().buffered(16)
|
val stream = streamFn().buffered(16)
|
||||||
val imageStream = process(stream)
|
openStream = process(stream)
|
||||||
val isAnimated = ImageUtil.isAnimatedAndSupported(stream)
|
|
||||||
Pair(imageStream, isAnimated)
|
ImageUtil.isAnimatedAndSupported(stream)
|
||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnNext { (imageStream, isAnimated) ->
|
.doOnNext { isAnimated ->
|
||||||
imageStream.use {
|
frame.setImage(
|
||||||
frame.setImage(
|
openStream!!,
|
||||||
it,
|
isAnimated,
|
||||||
isAnimated,
|
ReaderPageImageView.Config(
|
||||||
ReaderPageImageView.Config(
|
zoomDuration = viewer.config.doubleTapAnimDuration,
|
||||||
zoomDuration = viewer.config.doubleTapAnimDuration,
|
minimumScaleType = SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH,
|
||||||
minimumScaleType = SubsamplingScaleImageView.SCALE_TYPE_FIT_WIDTH,
|
cropBorders = viewer.config.imageCropBorders,
|
||||||
cropBorders = viewer.config.imageCropBorders,
|
),
|
||||||
),
|
)
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
// Keep the Rx stream alive to close the input stream only when unsubscribed
|
||||||
|
.flatMap { Observable.never<Unit>() }
|
||||||
|
.doOnUnsubscribe { openStream?.close() }
|
||||||
.subscribe({}, {})
|
.subscribe({}, {})
|
||||||
|
|
||||||
addSubscription(readImageHeaderSubscription)
|
addSubscription(readImageHeaderSubscription)
|
||||||
|
Loading…
Reference in New Issue
Block a user