From 278d7e0f5d1c24820caabc2d3d37f7bf532ed2c6 Mon Sep 17 00:00:00 2001 From: wangyiqian Date: Mon, 22 Apr 2024 15:20:45 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BA=A4=E4=BA=92=E7=BB=86=E8=8A=82=E4=BC=98?= =?UTF-8?q?=E5=8C=96?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/github/wangyiqian/stockchart/MatrixHelper.kt | 7 +++++++ .../java/com/github/wangyiqian/stockchart/StockChart.kt | 4 ++++ .../java/com/github/wangyiqian/stockchart/TouchHelper.kt | 6 ++++++ 3 files changed, 17 insertions(+) diff --git a/lib/src/main/java/com/github/wangyiqian/stockchart/MatrixHelper.kt b/lib/src/main/java/com/github/wangyiqian/stockchart/MatrixHelper.kt index 0d85d14..b82b338 100644 --- a/lib/src/main/java/com/github/wangyiqian/stockchart/MatrixHelper.kt +++ b/lib/src/main/java/com/github/wangyiqian/stockchart/MatrixHelper.kt @@ -53,6 +53,13 @@ internal class MatrixHelper(private val stockChart: IStockChart) { scrollMatrix.reset() } + /** + * 处理开始触摸 + */ + fun handleTouchDown(){ + scroller.forceFinished(true) + } + /** * 处理开始双指缩放 */ diff --git a/lib/src/main/java/com/github/wangyiqian/stockchart/StockChart.kt b/lib/src/main/java/com/github/wangyiqian/stockchart/StockChart.kt index fa4daac..4c91d00 100644 --- a/lib/src/main/java/com/github/wangyiqian/stockchart/StockChart.kt +++ b/lib/src/main/java/com/github/wangyiqian/stockchart/StockChart.kt @@ -308,6 +308,10 @@ class StockChart @JvmOverloads constructor(context: Context, attrs: AttributeSet inner class TouchHelperCallBack : TouchHelper.CallBack { + override fun onTouchDown() { + matrixHelper.handleTouchDown() + } + override fun onTouchScaleBegin(focusX: Float) { if (getConfig().scaleAble) { requestDisallowInterceptTouchEvent(true) diff --git a/lib/src/main/java/com/github/wangyiqian/stockchart/TouchHelper.kt b/lib/src/main/java/com/github/wangyiqian/stockchart/TouchHelper.kt index 23bec88..d4816ea 100644 --- a/lib/src/main/java/com/github/wangyiqian/stockchart/TouchHelper.kt +++ b/lib/src/main/java/com/github/wangyiqian/stockchart/TouchHelper.kt @@ -57,6 +57,7 @@ internal class TouchHelper(private val stockChart: IStockChart, private val call // 不在允许的触摸范围 return false } + callBack.onTouchDown() } MotionEvent.ACTION_MOVE -> { if (isLongPressing && event.getPointerId(event.actionIndex) == inLongPressingPointerId) { @@ -169,6 +170,11 @@ internal class TouchHelper(private val stockChart: IStockChart, private val call interface CallBack { + /** + * 触摸开始 + */ + fun onTouchDown() + /** * 开始双指缩放 */