mirror of
https://github.com/gedoor/legado.git
synced 2024-07-06 23:47:49 +08:00
优化
This commit is contained in:
parent
d157bb2c45
commit
83a264e6ba
@ -845,7 +845,9 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
success: (() -> Unit)?
|
||||
) {
|
||||
lifecycleScope.launch {
|
||||
autoPageProgress = 0
|
||||
if (relativePosition == 0) {
|
||||
autoPageProgress = 0
|
||||
}
|
||||
binding.readView.upContent(relativePosition, resetPageOffset)
|
||||
upSeekBarProgress()
|
||||
loadStates = false
|
||||
@ -964,12 +966,14 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
isAutoPage = false
|
||||
autoPageRenderer.stop()
|
||||
binding.readView.invalidate()
|
||||
binding.readView.clearNextPageBitmap()
|
||||
binding.readMenu.setAutoPage(false)
|
||||
upScreenTimeOut()
|
||||
}
|
||||
}
|
||||
|
||||
private fun autoPagePlus() {
|
||||
autoPageProgress = 0
|
||||
autoPageScrollOffset = 0.0
|
||||
autoPageRenderer.start()
|
||||
}
|
||||
@ -997,6 +1001,8 @@ class ReadBookActivity : BaseReadBookActivity(),
|
||||
autoPageProgress = 0
|
||||
if (!binding.readView.fillPage(PageDirection.NEXT)) {
|
||||
autoPageStop()
|
||||
} else {
|
||||
binding.readView.clearNextPageBitmap()
|
||||
}
|
||||
} else {
|
||||
binding.readView.invalidate()
|
||||
|
@ -2,6 +2,7 @@ package io.legado.app.ui.book.read.page
|
||||
|
||||
import android.annotation.SuppressLint
|
||||
import android.content.Context
|
||||
import android.graphics.Bitmap
|
||||
import android.graphics.Canvas
|
||||
import android.graphics.Paint
|
||||
import android.graphics.Rect
|
||||
@ -97,6 +98,7 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
private val autoPageRect by lazy { Rect() }
|
||||
private val autoPagePint by lazy { Paint().apply { color = context.accentColor } }
|
||||
private val boundary by lazy { BreakIterator.getWordInstance(Locale.getDefault()) }
|
||||
private var nextPageBitmap: Bitmap? = null
|
||||
|
||||
init {
|
||||
addView(nextPage)
|
||||
@ -141,7 +143,8 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
pageDelegate?.onDraw(canvas)
|
||||
if (!isInEditMode && callBack.isAutoPage && !isScroll) {
|
||||
// 自动翻页
|
||||
nextPage.screenshot()?.let {
|
||||
val bitmap = nextPageBitmap ?: nextPage.screenshot()?.also { nextPageBitmap = it }
|
||||
bitmap?.let {
|
||||
val bottom = callBack.autoPageProgress
|
||||
autoPageRect.set(0, 0, width, bottom)
|
||||
canvas.drawBitmap(it, autoPageRect, autoPageRect, null)
|
||||
@ -152,7 +155,6 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
bottom.toFloat(),
|
||||
autoPagePint
|
||||
)
|
||||
it.recycle()
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -526,6 +528,9 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
if (isScroll && !callBack.isAutoPage) {
|
||||
curPage.setContent(pageFactory.curPage, resetPageOffset)
|
||||
} else {
|
||||
if (callBack.isAutoPage && relativePosition >= 0) {
|
||||
clearNextPageBitmap()
|
||||
}
|
||||
when (relativePosition) {
|
||||
-1 -> prevPage.setContent(pageFactory.prevPage)
|
||||
1 -> nextPage.setContent(pageFactory.nextPage)
|
||||
@ -628,6 +633,11 @@ class ReadView(context: Context, attrs: AttributeSet) :
|
||||
return curPage.getCurVisibleFirstLine()?.pagePosition ?: 0
|
||||
}
|
||||
|
||||
fun clearNextPageBitmap() {
|
||||
nextPageBitmap?.recycle()
|
||||
nextPageBitmap = null
|
||||
}
|
||||
|
||||
override val currentChapter: TextChapter?
|
||||
get() {
|
||||
return if (callBack.isInitFinish) ReadBook.textChapter(0) else null
|
||||
|
Loading…
Reference in New Issue
Block a user