pull/525/head
gedoor 4 years ago
parent 79e19186ea
commit 39286d296d
  1. 14
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/read/page/ReadView.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() {

@ -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(

Loading…
Cancel
Save