Horis 3 년 전
부모
커밋
33364e7f99
2개의 변경된 파일과 19개의 추가작업 그리고 3개의 파일을 삭제
  1. 7 1
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 12 2
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt

+ 7 - 1
app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt

@@ -845,7 +845,9 @@ class ReadBookActivity : BaseReadBookActivity(),
         success: (() -> Unit)?
         success: (() -> Unit)?
     ) {
     ) {
         lifecycleScope.launch {
         lifecycleScope.launch {
-            autoPageProgress = 0
+            if (relativePosition == 0) {
+                autoPageProgress = 0
+            }
             binding.readView.upContent(relativePosition, resetPageOffset)
             binding.readView.upContent(relativePosition, resetPageOffset)
             upSeekBarProgress()
             upSeekBarProgress()
             loadStates = false
             loadStates = false
@@ -964,12 +966,14 @@ class ReadBookActivity : BaseReadBookActivity(),
             isAutoPage = false
             isAutoPage = false
             autoPageRenderer.stop()
             autoPageRenderer.stop()
             binding.readView.invalidate()
             binding.readView.invalidate()
+            binding.readView.clearNextPageBitmap()
             binding.readMenu.setAutoPage(false)
             binding.readMenu.setAutoPage(false)
             upScreenTimeOut()
             upScreenTimeOut()
         }
         }
     }
     }
 
 
     private fun autoPagePlus() {
     private fun autoPagePlus() {
+        autoPageProgress = 0
         autoPageScrollOffset = 0.0
         autoPageScrollOffset = 0.0
         autoPageRenderer.start()
         autoPageRenderer.start()
     }
     }
@@ -997,6 +1001,8 @@ class ReadBookActivity : BaseReadBookActivity(),
                 autoPageProgress = 0
                 autoPageProgress = 0
                 if (!binding.readView.fillPage(PageDirection.NEXT)) {
                 if (!binding.readView.fillPage(PageDirection.NEXT)) {
                     autoPageStop()
                     autoPageStop()
+                } else {
+                    binding.readView.clearNextPageBitmap()
                 }
                 }
             } else {
             } else {
                 binding.readView.invalidate()
                 binding.readView.invalidate()

+ 12 - 2
app/src/main/java/io/legado/app/ui/book/read/page/ReadView.kt

@@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.page
 
 
 import android.annotation.SuppressLint
 import android.annotation.SuppressLint
 import android.content.Context
 import android.content.Context
+import android.graphics.Bitmap
 import android.graphics.Canvas
 import android.graphics.Canvas
 import android.graphics.Paint
 import android.graphics.Paint
 import android.graphics.Rect
 import android.graphics.Rect
@@ -97,6 +98,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
     private val autoPageRect by lazy { Rect() }
     private val autoPageRect by lazy { Rect() }
     private val autoPagePint by lazy { Paint().apply { color = context.accentColor } }
     private val autoPagePint by lazy { Paint().apply { color = context.accentColor } }
     private val boundary by lazy { BreakIterator.getWordInstance(Locale.getDefault()) }
     private val boundary by lazy { BreakIterator.getWordInstance(Locale.getDefault()) }
+    private var nextPageBitmap: Bitmap? = null
 
 
     init {
     init {
         addView(nextPage)
         addView(nextPage)
@@ -141,7 +143,8 @@ class ReadView(context: Context, attrs: AttributeSet) :
         pageDelegate?.onDraw(canvas)
         pageDelegate?.onDraw(canvas)
         if (!isInEditMode && callBack.isAutoPage && !isScroll) {
         if (!isInEditMode && callBack.isAutoPage && !isScroll) {
             // 自动翻页
             // 自动翻页
-            nextPage.screenshot()?.let {
+            val bitmap = nextPageBitmap ?: nextPage.screenshot()?.also { nextPageBitmap = it }
+            bitmap?.let {
                 val bottom = callBack.autoPageProgress
                 val bottom = callBack.autoPageProgress
                 autoPageRect.set(0, 0, width, bottom)
                 autoPageRect.set(0, 0, width, bottom)
                 canvas.drawBitmap(it, autoPageRect, autoPageRect, null)
                 canvas.drawBitmap(it, autoPageRect, autoPageRect, null)
@@ -152,7 +155,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
                     bottom.toFloat(),
                     bottom.toFloat(),
                     autoPagePint
                     autoPagePint
                 )
                 )
-                it.recycle()
             }
             }
         }
         }
     }
     }
@@ -526,6 +528,9 @@ class ReadView(context: Context, attrs: AttributeSet) :
         if (isScroll && !callBack.isAutoPage) {
         if (isScroll && !callBack.isAutoPage) {
             curPage.setContent(pageFactory.curPage, resetPageOffset)
             curPage.setContent(pageFactory.curPage, resetPageOffset)
         } else {
         } else {
+            if (callBack.isAutoPage && relativePosition >= 0) {
+                clearNextPageBitmap()
+            }
             when (relativePosition) {
             when (relativePosition) {
                 -1 -> prevPage.setContent(pageFactory.prevPage)
                 -1 -> prevPage.setContent(pageFactory.prevPage)
                 1 -> nextPage.setContent(pageFactory.nextPage)
                 1 -> nextPage.setContent(pageFactory.nextPage)
@@ -628,6 +633,11 @@ class ReadView(context: Context, attrs: AttributeSet) :
         return curPage.getCurVisibleFirstLine()?.pagePosition ?: 0
         return curPage.getCurVisibleFirstLine()?.pagePosition ?: 0
     }
     }
 
 
+    fun clearNextPageBitmap() {
+        nextPageBitmap?.recycle()
+        nextPageBitmap = null
+    }
+
     override val currentChapter: TextChapter?
     override val currentChapter: TextChapter?
         get() {
         get() {
             return if (callBack.isInitFinish) ReadBook.textChapter(0) else null
             return if (callBack.isInitFinish) ReadBook.textChapter(0) else null