From b909b53161cd6e943e6b530a8975d105abb9851a Mon Sep 17 00:00:00 2001 From: John Carlson Date: Thu, 18 Jan 2024 01:13:05 -0600 Subject: [PATCH] Check AndroidX version --- README.md | 2 +- .../sample/DragFrameLayout.kt | 22 +++++++++++++++++++ 2 files changed, 23 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 82ec462..4e611e5 100644 --- a/README.md +++ b/README.md @@ -39,7 +39,7 @@ val viewDragHelper = TranslationViewDragHelper.create( See the sample [custom view](https://github.com/Commit451/TranslationViewDragHelper/blob/master/app/src/main/java/com/commit451/betterviewdraghelper/sample/AllowsForDragFrameLayout.java) for a more complete example # Basis -The current version of this helper is derived from `ViewDragHelper` source from `24.2.0` of the Support Library. Due to private constructor access on ViewDragHelper, the source has to be copied out into the `TranslationViewDragHelper`. You can check the diff [here](https://www.diffchecker.com/) +The current version of this helper is derived from `ViewDragHelper` source from `24.2.0` of the Support Library (pre AndroidX). Due to private constructor access on ViewDragHelper, the source has to be copied out into the `TranslationViewDragHelper`. License -------- diff --git a/app/src/main/java/com/commit451/translationviewdraghelper/sample/DragFrameLayout.kt b/app/src/main/java/com/commit451/translationviewdraghelper/sample/DragFrameLayout.kt index 65bc42b..7574b81 100644 --- a/app/src/main/java/com/commit451/translationviewdraghelper/sample/DragFrameLayout.kt +++ b/app/src/main/java/com/commit451/translationviewdraghelper/sample/DragFrameLayout.kt @@ -13,6 +13,9 @@ import com.commit451.translationviewdraghelper.TranslationViewDragHelper class DragFrameLayout : FrameLayout { private var viewDragHelper: TranslationViewDragHelper + // uncomment this and the rest to see how the real ViewDragHelper is +// private var viewDragHelper: ViewDragHelper + private var callback: TranslationViewDragHelper.Callback = object : TranslationViewDragHelper.Callback() { @@ -32,6 +35,24 @@ class DragFrameLayout : FrameLayout { } } +// private var callback: ViewDragHelper.Callback = +// object : ViewDragHelper.Callback() { +// override fun tryCaptureView(child: View, pointerId: Int): Boolean { +// //Any children can be captured +// return true +// } +// +// override fun clampViewPositionHorizontal(child: View, left: Int, dx: Int): Int { +// //allow full movement along horizontal axis +// return left +// } +// +// override fun clampViewPositionVertical(child: View, top: Int, dy: Int): Int { +// //allow full movement along vertical axis +// return top +// } +// } + constructor(context: Context) : super(context) constructor(context: Context, attrs: AttributeSet) : super(context, attrs) @@ -51,6 +72,7 @@ class DragFrameLayout : FrameLayout { init { viewDragHelper = TranslationViewDragHelper.create(this, 1.0f, callback) + //viewDragHelper = ViewDragHelper.create(this, 1.0f, callback) } override fun onInterceptTouchEvent(ev: MotionEvent): Boolean {