Last active
January 21, 2021 12:10
-
-
Save BhavyaRattan/abf613094efce521d3b185a2ec64b603 to your computer and use it in GitHub Desktop.
Magic Touch Recycler
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class ScaleItemOnTouchListener : RecyclerView.OnItemTouchListener { | |
....... | |
override fun onInterceptTouchEvent(rv: RecyclerView, event: MotionEvent): Boolean { | |
var interceptTouch = false | |
when (event.actionMasked) { | |
MotionEvent.ACTION_DOWN -> { | |
previousMotionX = event.x | |
previousMotionY = event.y | |
} | |
MotionEvent.ACTION_MOVE -> { | |
interceptTouch = !(abs(event.x - previousMotionX) > DRAG_THRESHOLD || | |
abs(event.y - previousMotionY) > DRAG_THRESHOLD) | |
} | |
MotionEvent.ACTION_UP -> { | |
previousMotionX = 0f | |
previousMotionY = 0f | |
} | |
} | |
return interceptTouch | |
} | |
........ | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment