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() { 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) mHandler.removeCallbacks(autoPageRunnable)
if (binding.readView.isScroll) { if (binding.readView.isScroll) {
binding.readView.curPage.scroll(-binding.readView.height / ReadBookConfig.autoReadSpeed / 50) binding.readView.curPage.scroll(-scrollOffset)
} else { } else {
autoPageProgress++ autoPageProgress += scrollOffset
if (autoPageProgress >= ReadBookConfig.autoReadSpeed * 50) { if (autoPageProgress >= binding.readView.height) {
autoPageProgress = 0 autoPageProgress = 0
binding.readView.fillPage(PageDirection.NEXT) binding.readView.fillPage(PageDirection.NEXT)
} else { } else {
binding.readView.invalidate() binding.readView.invalidate()
} }
} }
mHandler.postDelayed(autoPageRunnable, 20) mHandler.postDelayed(autoPageRunnable, delayMillis)
} }
override fun openSourceEditActivity() { override fun openSourceEditActivity() {

@ -122,9 +122,9 @@ class ReadView(context: Context, attrs: AttributeSet) :
super.dispatchDraw(canvas) super.dispatchDraw(canvas)
pageDelegate?.onDraw(canvas) pageDelegate?.onDraw(canvas)
if (!isInEditMode && callBack.isAutoPage && !isScroll) { if (!isInEditMode && callBack.isAutoPage && !isScroll) {
// TODO 自动翻页
nextPage.screenshot()?.let { nextPage.screenshot()?.let {
val bottom = val bottom = callBack.autoPageProgress
height * callBack.autoPageProgress / (ReadBookConfig.autoReadSpeed * 50)
autoPageRect.set(0, 0, width, bottom) autoPageRect.set(0, 0, width, bottom)
canvas.drawBitmap(it, autoPageRect, autoPageRect, null) canvas.drawBitmap(it, autoPageRect, autoPageRect, null)
canvas.drawRect( canvas.drawRect(

Loading…
Cancel
Save