From 0eb8c3717fe3720bdda171202016566922ce9eb0 Mon Sep 17 00:00:00 2001 From: Horis <8674809+821938089@users.noreply.github.com> Date: Sun, 6 Jul 2025 15:30:10 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BC=98=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../legado/app/ui/book/read/page/AutoPager.kt | 37 +++++++++++++++---- 1 file changed, 29 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/AutoPager.kt b/app/src/main/java/io/legado/app/ui/book/read/page/AutoPager.kt index 340dd9896..093914e5a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/AutoPager.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/AutoPager.kt @@ -14,11 +14,12 @@ import io.legado.app.utils.canvasrecorder.recordIfNeeded /** * 自动翻页 */ -class AutoPager(private val readView: ReadView) { +class AutoPager(private val readView: ReadView) : Runnable { private var progress = 0 var isRunning = false private set private var isPausing = false + private var isEInkMode = false private var scrollOffsetRemain = 0.0 private var scrollOffset = 0 private var lastTimeMillis = 0L @@ -28,10 +29,15 @@ class AutoPager(private val readView: ReadView) { fun start() { isRunning = true - paint.color = ThemeStore.accentColor - lastTimeMillis = SystemClock.uptimeMillis() + isEInkMode = AppConfig.isEInkMode readView.curPage.upSelectAble(false) - readView.invalidate() + if (isEInkMode) { + readView.postDelayed(this, ReadBookConfig.autoReadSpeed * 1000L) + } else { + paint.color = ThemeStore.accentColor + lastTimeMillis = SystemClock.uptimeMillis() + readView.invalidate() + } } fun stop() { @@ -40,6 +46,8 @@ class AutoPager(private val readView: ReadView) { } isRunning = false isPausing = false + isEInkMode = false + readView.removeCallbacks(this) readView.curPage.upSelectAble(AppConfig.textSelectAble) readView.invalidate() reset() @@ -51,6 +59,7 @@ class AutoPager(private val readView: ReadView) { return } isPausing = true + readView.removeCallbacks(this) } fun resume() { @@ -58,8 +67,12 @@ class AutoPager(private val readView: ReadView) { return } isPausing = false - lastTimeMillis = SystemClock.uptimeMillis() - readView.invalidate() + if (isEInkMode) { + readView.postDelayed(this, ReadBookConfig.autoReadSpeed * 1000L) + } else { + lastTimeMillis = SystemClock.uptimeMillis() + readView.invalidate() + } } fun reset() { @@ -75,7 +88,7 @@ class AutoPager(private val readView: ReadView) { } fun onDraw(canvas: Canvas) { - if (!isRunning) { + if (!isRunning || isEInkMode) { return } @@ -106,7 +119,7 @@ class AutoPager(private val readView: ReadView) { } fun computeOffset() { - if (!isRunning || isPausing) { + if (!isRunning || isPausing || isEInkMode) { return } @@ -134,4 +147,12 @@ class AutoPager(private val readView: ReadView) { } } + override fun run() { + if (!readView.fillPage(PageDirection.NEXT)) { + stop() + } else { + readView.postDelayed(this, ReadBookConfig.autoReadSpeed * 1000L) + } + } + }