feat: 优化

pull/219/head
kunfei 5 years ago
parent 4ea0bc8937
commit d23344f6af
  1. 22
      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/delegate/HorizontalPageDelegate.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt
  4. 4
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt

@ -85,7 +85,9 @@ 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
private var screenTimeOut: Long = 0
private var timeBatteryReceiver: TimeBatteryReceiver? = null
override val pageFactory: TextPageFactory get() = page_view.pageFactory
@ -558,7 +560,25 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
* 自动翻页
*/
override fun autoPage() {
if (isAutoPage) {
isAutoPage = false
mHandler.removeCallbacks(autoPageRunnable)
page_view.upContent()
} else {
isAutoPage = true
autoPagePlus()
}
read_menu.setAutoPage(isAutoPage)
}
private fun autoPagePlus() {
mHandler.removeCallbacks(autoPageRunnable)
autoPageProgress++
if (autoPageProgress >= 46) {
autoPageProgress = 0
ReadBook.moveToNextPage()
}
mHandler.postDelayed(autoPageRunnable, 100)
}
/**

@ -104,7 +104,7 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie
}
override fun nextPageByAnim() {
super.nextPageByAnim()
abort()
if (!hasNext()) return
setDirection(Direction.NEXT)
setTouchPoint(viewWidth.toFloat(), 0f)
@ -112,7 +112,7 @@ abstract class HorizontalPageDelegate(pageView: PageView) : PageDelegate(pageVie
}
override fun prevPageByAnim() {
super.prevPageByAnim()
abort()
if (!hasPrev()) return
setDirection(Direction.PREV)
setTouchPoint(0f, 0f)

@ -170,13 +170,9 @@ abstract class PageDelegate(protected val pageView: PageView) :
open fun onScroll() {}//移动contentView, slidePage
open fun nextPageByAnim() {
abort()
}
abstract fun nextPageByAnim()
open fun prevPageByAnim() {
abort()
}
abstract fun prevPageByAnim()
open fun keyTurnPage(direction: Direction) {
if (isRunning) return

@ -79,12 +79,12 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) {
}
override fun nextPageByAnim() {
super.nextPageByAnim()
abort()
startScroll(0, 0, 0, -ChapterProvider.visibleHeight)
}
override fun prevPageByAnim() {
super.prevPageByAnim()
abort()
startScroll(0, 0, 0, ChapterProvider.visibleHeight)
}
}
Loading…
Cancel
Save