From 2941f0ee371c0c5269a9f81ff9b02affb3a8379c Mon Sep 17 00:00:00 2001 From: kunfei Date: Mon, 23 Sep 2019 08:14:32 +0800 Subject: [PATCH] up --- .../widget/page/delegate/EventExtensions.kt | 20 +++++++++++++++++++ .../ui/widget/page/delegate/PageDelegate.kt | 13 +++--------- 2 files changed, 23 insertions(+), 10 deletions(-) create mode 100644 app/src/main/java/io/legado/app/ui/widget/page/delegate/EventExtensions.kt diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/EventExtensions.kt b/app/src/main/java/io/legado/app/ui/widget/page/delegate/EventExtensions.kt new file mode 100644 index 000000000..99916e27a --- /dev/null +++ b/app/src/main/java/io/legado/app/ui/widget/page/delegate/EventExtensions.kt @@ -0,0 +1,20 @@ +package io.legado.app.ui.widget.page.delegate + +import android.view.MotionEvent + +fun MotionEvent.toAction(action: Int): MotionEvent { + return MotionEvent.obtain( + downTime, + eventTime, + action, + x, + y, + pressure, + size, + metaState, + xPrecision, + yPrecision, + deviceId, + edgeFlags + ) +} \ No newline at end of file diff --git a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt b/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt index 1017b2314..96483e499 100644 --- a/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt +++ b/app/src/main/java/io/legado/app/ui/widget/page/delegate/PageDelegate.kt @@ -188,9 +188,6 @@ abstract class PageDelegate(protected val pageView: PageView) { if (event.action == MotionEvent.ACTION_DOWN) { curPage?.let { it.contentTextView()?.let { contentTextView -> - if (!contentTextView.isTextSelectable) { - contentTextView.setTextIsSelectable(true) - } atTop = contentTextView.atTop() atBottom = contentTextView.atBottom() } @@ -279,17 +276,11 @@ abstract class PageDelegate(protected val pageView: PageView) { distanceX: Float, distanceY: Float ): Boolean { - curPage?.contentTextView()?.let { - //滑动时禁止选择文字 - if (it.isTextSelectable) { - it.setTextIsSelectable(false) - it.movementMethod = scrollingMovementMethod - } - } if (pageView.isScrollDelegate()) { if (!isMoved && abs(distanceX) < abs(distanceY)) { if (distanceY < 0) { if (atTop) { + curPage?.dispatchTouchEvent(e1.toAction(MotionEvent.ACTION_UP)) //上一页的参数配置 direction = Direction.PREV //判断是否上一页存在 @@ -304,6 +295,7 @@ abstract class PageDelegate(protected val pageView: PageView) { } } else { if (atBottom) { + curPage?.dispatchTouchEvent(e1.toAction(MotionEvent.ACTION_UP)) //进行下一页的配置 direction = Direction.NEXT //判断是否下一页存在 @@ -324,6 +316,7 @@ abstract class PageDelegate(protected val pageView: PageView) { curPage?.dispatchTouchEvent(e2) } } else if (!isMoved && abs(distanceX) > abs(distanceY)) { + curPage?.dispatchTouchEvent(e1.toAction(MotionEvent.ACTION_UP)) if (distanceX < 0) { //上一页的参数配置 direction = Direction.PREV