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 6d39baa83..886f7938f 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 @@ -86,8 +86,8 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo private val mHandler = Handler() private val keepScreenRunnable: Runnable = Runnable { Help.keepScreenOn(window, false) } private val autoPageRunnable: Runnable = Runnable { autoPagePlus() } - private var autoPageProgress = 0 - private var isAutoPage = false + override var autoPageProgress = 0 + override var isAutoPage = false private var screenTimeOut: Long = 0 private var timeBatteryReceiver: TimeBatteryReceiver? = null override val pageFactory: TextPageFactory get() = page_view.pageFactory @@ -574,9 +574,11 @@ class ReadBookActivity : VMBaseActivity(R.layout.activity_boo private fun autoPagePlus() { mHandler.removeCallbacks(autoPageRunnable) autoPageProgress++ - if (autoPageProgress >= 46) { + if (autoPageProgress >= 460) { autoPageProgress = 0 ReadBook.moveToNextPage() + } else { + page_view.invalidate() } mHandler.postDelayed(autoPageRunnable, 100) } diff --git a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt index 254d037ad..317af6aab 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt @@ -140,7 +140,11 @@ class ReadMenu : FrameLayout { }) //自动翻页 - fabAutoPage.onClick { callBack?.autoPage() } + fabAutoPage.onClick { + runMenuOut { + callBack?.autoPage() + } + } //替换 fabReplaceRule.onClick { callBack?.openReplaceRule() } diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt index 3a996bfe9..3be9bf48c 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt @@ -3,6 +3,7 @@ package io.legado.app.ui.book.read.page import android.annotation.SuppressLint import android.content.Context import android.graphics.Canvas +import android.graphics.Rect import android.util.AttributeSet import android.view.MotionEvent import android.widget.FrameLayout @@ -11,6 +12,8 @@ import io.legado.app.service.help.ReadBook import io.legado.app.ui.book.read.page.delegate.* import io.legado.app.ui.book.read.page.entities.TextChapter import io.legado.app.utils.activity +import io.legado.app.utils.screenshot +import kotlinx.android.synthetic.main.activity_book_read.view.* class PageView(context: Context, attrs: AttributeSet) : FrameLayout(context, attrs), @@ -44,8 +47,14 @@ class PageView(context: Context, attrs: AttributeSet) : override fun dispatchDraw(canvas: Canvas) { super.dispatchDraw(canvas) - pageDelegate?.onDraw(canvas) + if (callBack.isAutoPage) { + nextPage.screenshot()?.let { + val rect = + Rect(0, 0, page_view.width, page_view.height * callBack.autoPageProgress / 460) + canvas.drawBitmap(it, rect, rect, null) + } + } } override fun computeScroll() { @@ -169,6 +178,8 @@ class PageView(context: Context, attrs: AttributeSet) : interface CallBack { val isInitFinish: Boolean + val isAutoPage: Boolean + val autoPageProgress: Int fun clickCenter() fun screenOffTimerStart() fun showTextActionMenu()