diff options
Diffstat (limited to 'core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java')
-rw-r--r-- | core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java | 21 |
1 files changed, 21 insertions, 0 deletions
diff --git a/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java b/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java index 6b34af3..c6ff116 100644 --- a/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java +++ b/core/src/main/kotlin/ca/allanwang/kau/swipe/ViewDragHelper.java @@ -385,6 +385,27 @@ public class ViewDragHelper implements ViewDragHelperExtras { } /** + * Sets the sensitivity of the dragger. + * + * @param context The application context. + * @param sensitivity value between 0 and 1, the final value for touchSlop = + * ViewConfiguration.getScaledTouchSlop * (1 / s); + * 1 is the default + */ + @Override + public void setSensitivity(Context context, float sensitivity) { + float s = Math.max(0f, Math.min(1.0f, sensitivity)); + ViewConfiguration viewConfiguration = ViewConfiguration.get(context); + mTouchSlop = (int) (viewConfiguration.getScaledTouchSlop() * (1 / s)); + } + + @Override + public float getSensitivity() { + return mTouchSlop; + } + + + /** * Set the minimum velocity that will be detected as having a magnitude greater than zero * in pixels per second. Callback methods accepting a velocity will be clamped appropriately. * |