From 41ea3a7eb4761ae03735187503238e5cfe508e78 Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 24 Feb 2020 14:48:19 +0800 Subject: [PATCH] =?UTF-8?q?feat:=20=E4=BC=98=E5=8C=96=E4=BB=A3=E7=A0=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../ui/book/read/page/delegate/PageDelegate.kt | 18 ++++++------------ .../read/page/delegate/ScrollPageDelegate.kt | 3 +-- 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt index 681159059..fec677deb 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/PageDelegate.kt @@ -34,14 +34,9 @@ abstract class PageDelegate(protected val pageView: PageView) : protected var touchX: Float = 0f protected var touchY: Float = 0f - protected val nextPage: ContentView - get() = pageView.nextPage - - protected val curPage: ContentView - get() = pageView.curPage - - protected val prevPage: ContentView - get() = pageView.prevPage + protected val nextPage: ContentView get() = pageView.nextPage + protected val curPage: ContentView get() = pageView.curPage + protected val prevPage: ContentView get() = pageView.prevPage protected var bitmap: Bitmap? = null @@ -90,7 +85,7 @@ abstract class PageDelegate(protected val pageView: PageView) : touchY = y if (invalidate) { - pageView.postInvalidate() + pageView.invalidate() } onScroll() @@ -187,12 +182,11 @@ abstract class PageDelegate(protected val pageView: PageView) : abstract fun onAnimStart()//scroller start - abstract fun onDraw(canvas: Canvas)//绘制 + open fun onDraw(canvas: Canvas) {}//绘制 abstract fun onAnimStop()//scroller finish - open fun onScroll() {//移动contentView, slidePage - } + open fun onScroll() {}//移动contentView, slidePage @CallSuper open fun setDirection(direction: Direction) { diff --git a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt index 894e4b9b8..eca83b12a 100644 --- a/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt @@ -1,6 +1,5 @@ package io.legado.app.ui.book.read.page.delegate -import android.graphics.Canvas import android.view.MotionEvent import android.view.VelocityTracker import io.legado.app.ui.book.read.page.PageView @@ -21,7 +20,7 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) { ) } - override fun onDraw(canvas: Canvas) { + override fun onScroll() { curPage.onScroll(touchY - lastY) }