Skip to content

Instantly share code, notes, and snippets.

@sagar-viradiya
Created August 15, 2017 10:45
Show Gist options
  • Save sagar-viradiya/9451d391d7fe4b43c7ef5db46a27ed2b to your computer and use it in GitHub Desktop.
Save sagar-viradiya/9451d391d7fe4b43c7ef5db46a27ed2b to your computer and use it in GitHub Desktop.
val gestureListener = object : GestureDetector.SimpleOnGestureListener() {
override fun onDown(e: MotionEvent?): Boolean {
return true
}
override fun onFling(e1: MotionEvent?, e2: MotionEvent?, velocityX: Float, velocityY: Float): Boolean {
flingAnimationX.setStartVelocity(velocityX)
flingAnimationY.setStartVelocity(velocityY)
flingAnimationX.start()
flingAnimationY.start()
return true
}
}
val gestureDetector = GestureDetector(context, gestureListener)
android_bot.setOnTouchListener { _, motionEvent ->
gestureDetector.onTouchEvent(motionEvent)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment