mirror of
https://github.com/tachiyomiorg/tachiyomi.git
synced 2024-12-22 19:41:50 +01:00
Don't update page progress and allow preload when on StencilPage (#7899)
Also cleanup a little in WebtoonPageHolder
This commit is contained in:
parent
81f49f34ef
commit
fddca15182
@ -39,6 +39,7 @@ import eu.kanade.tachiyomi.ui.reader.loader.HttpPageLoader
|
|||||||
import eu.kanade.tachiyomi.ui.reader.model.InsertPage
|
import eu.kanade.tachiyomi.ui.reader.model.InsertPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderChapter
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
import eu.kanade.tachiyomi.ui.reader.model.ReaderPage
|
||||||
|
import eu.kanade.tachiyomi.ui.reader.model.StencilPage
|
||||||
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
import eu.kanade.tachiyomi.ui.reader.model.ViewerChapters
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
import eu.kanade.tachiyomi.ui.reader.setting.OrientationType
|
||||||
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
import eu.kanade.tachiyomi.ui.reader.setting.ReadingModeType
|
||||||
@ -414,8 +415,8 @@ class ReaderPresenter(
|
|||||||
|
|
||||||
val selectedChapter = page.chapter
|
val selectedChapter = page.chapter
|
||||||
|
|
||||||
// Insert page doesn't change page progress
|
// InsertPage and StencilPage doesn't change page progress
|
||||||
if (page is InsertPage) {
|
if (page is InsertPage || page is StencilPage) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -246,19 +246,19 @@ 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)
|
||||||
openStream = process(stream)
|
val imageStream = process(stream)
|
||||||
|
val isAnimated = ImageUtil.isAnimatedAndSupported(stream)
|
||||||
ImageUtil.isAnimatedAndSupported(stream)
|
Pair(imageStream, isAnimated)
|
||||||
}
|
}
|
||||||
.subscribeOn(Schedulers.io())
|
.subscribeOn(Schedulers.io())
|
||||||
.observeOn(AndroidSchedulers.mainThread())
|
.observeOn(AndroidSchedulers.mainThread())
|
||||||
.doOnNext { isAnimated ->
|
.doOnNext { (imageStream, isAnimated) ->
|
||||||
|
imageStream.use {
|
||||||
frame.setImage(
|
frame.setImage(
|
||||||
openStream!!,
|
it,
|
||||||
isAnimated,
|
isAnimated,
|
||||||
ReaderPageImageView.Config(
|
ReaderPageImageView.Config(
|
||||||
zoomDuration = viewer.config.doubleTapAnimDuration,
|
zoomDuration = viewer.config.doubleTapAnimDuration,
|
||||||
@ -267,9 +267,7 @@ class WebtoonPageHolder(
|
|||||||
),
|
),
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
// 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)
|
||||||
|
@ -210,6 +210,11 @@ class WebtoonViewer(val activity: ReaderActivity, val isContinuous: Boolean = tr
|
|||||||
logcat { "onPageSelected: ${page.number}/${pages.size}" }
|
logcat { "onPageSelected: ${page.number}/${pages.size}" }
|
||||||
activity.onPageSelected(page)
|
activity.onPageSelected(page)
|
||||||
|
|
||||||
|
// Skip preload on StencilPage
|
||||||
|
if (page is StencilPage) {
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
// Preload next chapter once we're within the last 5 pages of the current chapter
|
// Preload next chapter once we're within the last 5 pages of the current chapter
|
||||||
val inPreloadRange = pages.size - page.number < 5
|
val inPreloadRange = pages.size - page.number < 5
|
||||||
if (inPreloadRange && allowPreload && page.chapter == adapter.currentChapter) {
|
if (inPreloadRange && allowPreload && page.chapter == adapter.currentChapter) {
|
||||||
|
Loading…
Reference in New Issue
Block a user