feat: 优化代码

pull/115/head
kunfei 5 years ago
parent 2864bc28ea
commit 3c8def787d
  1. 2
      app/src/main/java/io/legado/app/ui/book/read/page/ContentTextView.kt
  2. 4
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  3. 1
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt
  4. 13
      app/src/main/java/io/legado/app/ui/book/read/page/delegate/ScrollPageDelegate.kt

@ -35,7 +35,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
private val maxScrollOffset = 100f
private var pageOffset = 0f
private var linePos = 0
private var isLastPage = false
init {
callBack = activity as CallBack
@ -163,7 +162,6 @@ class ContentTextView(context: Context, attrs: AttributeSet?) : View(context, at
fun resetPageOffset() {
pageOffset = 0f
linePos = 0
isLastPage = false
}
fun selectText(x: Float, y: Float): Boolean {

@ -111,6 +111,10 @@ class ContentView(context: Context) : FrameLayout(context) {
content_text_view.onScroll(offset)
}
fun resetPageOffset() {
content_text_view.resetPageOffset()
}
fun upSelectAble(selectAble: Boolean) {
content_text_view.selectAble = selectAble
}

@ -100,6 +100,7 @@ class PageView(context: Context, attrs: AttributeSet) :
fun upContent(position: Int = 0) {
if (ReadBookConfig.isScroll) {
curPage.resetPageOffset()
curPage.setContent(pageFactory.currentPage)
} else {
when (position) {

@ -31,11 +31,14 @@ class ScrollPageDelegate(pageView: PageView) : PageDelegate(pageView) {
}
}
override fun onDown(e: MotionEvent): Boolean {
abort()
mVelocity.clear()
mVelocity.addMovement(e)
return super.onDown(e)
override fun onTouch(event: MotionEvent): Boolean {
if (event.action == MotionEvent.ACTION_DOWN) {
setStartPoint(event.x, event.y)
abort()
mVelocity.clear()
mVelocity.addMovement(event)
}
return super.onTouch(event)
}
override fun onScroll(

Loading…
Cancel
Save