From 00ba1bcf7a756252baa808e62a0916fd18e95946 Mon Sep 17 00:00:00 2001 From: Allan Wang Date: Tue, 2 Jul 2019 16:48:43 -0700 Subject: Add disallow on touch and document --- core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt | 2 +- core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt | 5 +++++ 2 files changed, 6 insertions(+), 1 deletion(-) (limited to 'core/src/main/kotlin/ca') diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt index 8f1da04..c5b64e3 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackLayout.kt @@ -245,7 +245,7 @@ internal class SwipeBackLayout @JvmOverloads constructor( @SuppressLint("ClickableViewAccessibility") override fun onTouchEvent(event: MotionEvent): Boolean { - if (!swipeEnabled) return false + if (!swipeEnabled || disallowIntercept) return false try { dragHelper.processTouchEvent(event) } catch (e: Exception) { diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt index bc5b459..c85625a 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/SwipeBackPage.kt @@ -75,6 +75,7 @@ internal interface SwipeBackContractInternal : SwipeBackContract { interface SwipeBackContract { /** * Toggle main touch intercept + * Disabling will remove the swipe back handler */ var swipeEnabled: Boolean /** @@ -91,6 +92,10 @@ interface SwipeBackContract { * Set the scrolling threshold for wish a page is deemed closing */ var scrollThreshold: Float + /** + * Toggle main touch intercept + * Disabling will just ignore touch events, but the handler will remain attached + */ var disallowIntercept: Boolean /** * Set the min velocity of the view drag helper -- cgit v1.2.3