From 39286d296deb42cf0aa3560f5b9bba7f31a4a57f Mon Sep 17 00:00:00 2001 From: gedoor Date: Tue, 8 Dec 2020 15:47:11 +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 --- .../io/legado/app/ui/book/read/ReadBookActivity.kt | 14 ++++++++++---- .../io/legado/app/ui/book/read/page/ReadView.kt | 4 ++-- 2 files changed, 12 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt index e5510821e..ebed4ee51 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt @@ -595,19 +595,25 @@ class ReadBookActivity : ReadBookBaseActivity(), } private fun autoPagePlus() { + var delayMillis = ReadBookConfig.autoReadSpeed * 1000L / binding.readView.height + var scrollOffset = 1 + if (delayMillis < 20) { + scrollOffset = 20 / delayMillis.toInt() + delayMillis = 20 + } mHandler.removeCallbacks(autoPageRunnable) if (binding.readView.isScroll) { - binding.readView.curPage.scroll(-binding.readView.height / ReadBookConfig.autoReadSpeed / 50) + binding.readView.curPage.scroll(-scrollOffset) } else { - autoPageProgress++ - if (autoPageProgress >= ReadBookConfig.autoReadSpeed * 50) { + autoPageProgress += scrollOffset + if (autoPageProgress >= binding.readView.height) { autoPageProgress = 0 binding.readView.fillPage(PageDirection.NEXT) } else { binding.readView.invalidate() } } - mHandler.postDelayed(autoPageRunnable, 20) + mHandler.postDelayed(autoPageRunnable, delayMillis) } override fun openSourceEditActivity() { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt index 038373430..4cab060e4 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt @@ -122,9 +122,9 @@ class ReadView(context: Context, attrs: AttributeSet) : super.dispatchDraw(canvas) pageDelegate?.onDraw(canvas) if (!isInEditMode && callBack.isAutoPage && !isScroll) { + // TODO 自动翻页 nextPage.screenshot()?.let { - val bottom = - height * callBack.autoPageProgress / (ReadBookConfig.autoReadSpeed * 50) + val bottom = callBack.autoPageProgress autoPageRect.set(0, 0, width, bottom) canvas.drawBitmap(it, autoPageRect, autoPageRect, null) canvas.drawRect(