feat: 优化代码

pull/106/head
kunfei 5 years ago
parent 1b58489ee3
commit 7737089ee4
  1. 14
      app/src/main/java/io/legado/app/ui/book/read/ReadBookActivity.kt
  2. 8
      app/src/main/java/io/legado/app/ui/book/read/page/ContentView.kt
  3. 8
      app/src/main/java/io/legado/app/ui/book/read/page/PageView.kt

@ -1,5 +1,6 @@
package io.legado.app.ui.book.read package io.legado.app.ui.book.read
import android.annotation.SuppressLint
import android.app.Activity import android.app.Activity
import android.content.Intent import android.content.Intent
import android.net.Uri import android.net.Uri
@ -312,9 +313,16 @@ class ReadBookActivity : VMBaseActivity<ReadBookViewModel>(R.layout.activity_boo
/** /**
* view触摸 * view触摸
*/ */
override fun onTouch(v: View?, event: MotionEvent?): Boolean { @SuppressLint("ClickableViewAccessibility")
override fun onTouch(v: View, event: MotionEvent): Boolean {
when (event.action) {
MotionEvent.ACTION_MOVE, MotionEvent.ACTION_UP -> {
when (v.id) {
R.id.cursor_left -> page_view.selectStartMove(event.x, event.y)
R.id.cursor_right -> page_view.selectEndMove(event.x, event.y)
}
}
}
return true return true
} }

@ -121,6 +121,14 @@ class ContentView : FrameLayout {
return selectPoint return selectPoint
} }
fun selectStartMove(x: Float, y: Float) {
}
fun selectEndMove(x: Float, y: Float) {
}
fun scrollTo(pos: Int?) { fun scrollTo(pos: Int?) {
if (pos != null) { if (pos != null) {
content_text_view.post { content_text_view.post {

@ -184,6 +184,14 @@ class PageView(context: Context, attrs: AttributeSet) :
nextPage.upBattery(battery) nextPage.upBattery(battery)
} }
fun selectStartMove(x: Float, y: Float) {
curPage.selectStartMove(x, y)
}
fun selectEndMove(x: Float, y: Float) {
curPage.selectEndMove(x, y)
}
override val isScrollDelegate: Boolean override val isScrollDelegate: Boolean
get() = pageDelegate is ScrollPageDelegate get() = pageDelegate is ScrollPageDelegate

Loading…
Cancel
Save