Skip to content

Commit

Permalink
Check AndroidX version
Browse files Browse the repository at this point in the history
  • Loading branch information
Jawnnypoo committed Jan 18, 2024
1 parent 75ec4dd commit b909b53
Show file tree
Hide file tree
Showing 2 changed files with 23 additions and 1 deletion.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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
--------
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand All @@ -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)
Expand All @@ -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 {
Expand Down

0 comments on commit b909b53

Please sign in to comment.