pull/34/head
kunfei 5 years ago
parent a2f49c7c0b
commit 22f25494d6
  1. 5
      app/src/main/java/io/legado/app/ui/widget/page/ContentTextView.kt
  2. 9
      app/src/main/java/io/legado/app/ui/widget/page/ContentView.kt
  3. 5
      app/src/main/java/io/legado/app/ui/widget/page/PageView.kt

@ -98,6 +98,11 @@ class ContentTextView : AppCompatTextView {
mOffsetHeight = mLayoutHeight + totalPaddingTop + totalPaddingBottom - measuredHeight mOffsetHeight = mLayoutHeight + totalPaddingTop + totalPaddingBottom - measuredHeight
} }
override fun scrollTo(x: Int, y: Int) {
setScrollState(scrollStateIdle)
super.scrollTo(x, min(y, mOffsetHeight))
}
@SuppressLint("ClickableViewAccessibility") @SuppressLint("ClickableViewAccessibility")
override fun onTouchEvent(event: MotionEvent?): Boolean { override fun onTouchEvent(event: MotionEvent?): Boolean {
event?.let { event?.let {

@ -134,6 +134,15 @@ class ContentView : FrameLayout {
} }
} }
fun scrollToBottom() {
content_text_view.post {
content_text_view.scrollTo(
0,
content_text_view.layout.getLineTop(content_text_view.lineCount)
)
}
}
interface CallBack { interface CallBack {
fun scrollToLine(line: Int) fun scrollToLine(line: Int)
} }

@ -70,14 +70,17 @@ class PageView(context: Context, attrs: AttributeSet) :
when (direction) { when (direction) {
PageDelegate.Direction.PREV -> { PageDelegate.Direction.PREV -> {
it.moveToPrevious() it.moveToPrevious()
upContent()
curPage?.scrollToBottom()
} }
PageDelegate.Direction.NEXT -> { PageDelegate.Direction.NEXT -> {
it.moveToNext() it.moveToNext()
upContent()
curPage?.scrollTo(0)
} }
else -> return else -> return
} }
} }
upContent()
} }
fun upPageAnim() { fun upPageAnim() {

Loading…
Cancel
Save