feat: 优化

pull/219/head
kunfei 5 years ago
parent d23344f6af
commit d943716487
  1. 8
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 6
      app/src/main/java/io/legado/app/ui/book/read/ReadMenu.kt
  3. 13
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -86,8 +86,8 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(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<ReadBookViewModel>(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)
}

@ -140,7 +140,11 @@ class ReadMenu : FrameLayout {
})
//自动翻页
fabAutoPage.onClick { callBack?.autoPage() }
fabAutoPage.onClick {
runMenuOut {
callBack?.autoPage()
}
}
//替换
fabReplaceRule.onClick { callBack?.openReplaceRule() }

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

Loading…
Cancel
Save