pull/37/head
kunfei 5 years ago
parent 262d9c0b42
commit 483bf92003
  1. 1
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt
  2. 22
      app/src/main/java/io/legado/app/ui/widget/page/curl/CurlView.kt
  3. 3
      app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt
  4. 6
      app/src/main/java/io/legado/app/ui/widget/page/delegate/SimulationPageDelegate.kt

@ -122,6 +122,7 @@ class PageView(context: Context, attrs: AttributeSet) :
prevPage?.scrollToBottom() prevPage?.scrollToBottom()
} }
} }
pageDelegate?.onPageUp()
} }
fun moveToPrevPage(noAnim: Boolean = true) { fun moveToPrevPage(noAnim: Boolean = true) {

@ -48,8 +48,6 @@ class CurlView : GLSurfaceView, View.OnTouchListener, CurlRenderer.Observer {
private var mPageLeft: CurlMesh private var mPageLeft: CurlMesh
private var mPageRight: CurlMesh private var mPageRight: CurlMesh
private var mPageProvider: PageProvider? = null
private val mPointerPos = PointerPosition() private val mPointerPos = PointerPosition()
private var mRenderer: CurlRenderer = CurlRenderer(this) private var mRenderer: CurlRenderer = CurlRenderer(this)
@ -59,6 +57,14 @@ class CurlView : GLSurfaceView, View.OnTouchListener, CurlRenderer.Observer {
// One page is the default. // One page is the default.
private var mViewMode = SHOW_ONE_PAGE private var mViewMode = SHOW_ONE_PAGE
var mPageProvider: PageProvider? = null
set(value) {
field = value
mCurrentIndex = 0
updatePages()
requestRender()
}
/** /**
* Get current page index. Page indices are zero based values presenting * Get current page index. Page indices are zero based values presenting
* page being shown on right side of the book. * page being shown on right side of the book.
@ -407,16 +413,6 @@ class CurlView : GLSurfaceView, View.OnTouchListener, CurlRenderer.Observer {
mRenderer.setMargins(left, top, right, bottom) mRenderer.setMargins(left, top, right, bottom)
} }
/**
* Update/set page provider.
*/
fun setPageProvider(pageProvider: PageProvider) {
mPageProvider = pageProvider
mCurrentIndex = 0
updatePages()
requestRender()
}
/** /**
* Setter for whether left side page is rendered. This is useful mostly for * Setter for whether left side page is rendered. This is useful mostly for
* situations where right (main) page is aligned to left side of screen and * situations where right (main) page is aligned to left side of screen and
@ -645,7 +641,7 @@ class CurlView : GLSurfaceView, View.OnTouchListener, CurlRenderer.Observer {
/** /**
* Updates bitmaps for page meshes. * Updates bitmaps for page meshes.
*/ */
private fun updatePages() { fun updatePages() {
if (mPageProvider == null || mPageBitmapWidth <= 0 if (mPageProvider == null || mPageBitmapWidth <= 0
|| mPageBitmapHeight <= 0 || mPageBitmapHeight <= 0
) { ) {

@ -209,6 +209,9 @@ abstract class PageDelegate(protected val pageView: PageView) {
open fun onScroll() {//移动contentView, slidePage open fun onScroll() {//移动contentView, slidePage
} }
open fun onPageUp() {
}
enum class Direction { enum class Direction {
NONE, PREV, NEXT NONE, PREV, NEXT
} }

@ -13,7 +13,7 @@ class SimulationPageDelegate(pageView: PageView) : PageDelegate(pageView) {
pageView.curlView ?: let { pageView.curlView ?: let {
pageView.curlView = CurlView(pageView.context) pageView.curlView = CurlView(pageView.context)
pageView.addView(pageView.curlView) pageView.addView(pageView.curlView)
pageView.curlView?.setPageProvider(PageProvider()) pageView.curlView?.mPageProvider = PageProvider()
pageView.curlView?.setSizeChangedObserver(SizeChangedObserver()) pageView.curlView?.setSizeChangedObserver(SizeChangedObserver())
pageView.curlView?.currentIndex = 0 pageView.curlView?.currentIndex = 0
} }
@ -33,6 +33,10 @@ class SimulationPageDelegate(pageView: PageView) : PageDelegate(pageView) {
override fun onScrollStop() { override fun onScrollStop() {
} }
override fun onPageUp() {
pageView.curlView?.updatePages()
}
private inner class PageProvider : CurlView.PageProvider { private inner class PageProvider : CurlView.PageProvider {
override val pageCount: Int override val pageCount: Int

Loading…
Cancel
Save