Created
August 15, 2017 09:51
-
-
Save sagar-viradiya/9d8d24976d5901bee878c424b6328393 to your computer and use it in GitHub Desktop.
This file contains 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
private fun setupTouchListener() { | |
android_bot.setOnTouchListener { view, motionEvent -> | |
when(motionEvent?.action) { | |
MotionEvent.ACTION_DOWN -> { | |
xDiffInTouchPointAndViewTopLeftCorner = motionEvent.rawX - view.x | |
yDiffInTouchPointAndViewTopLeftCorner = motionEvent.rawY - view.y | |
springAnimationTranslationX.cancel() | |
springAnimationTranslationY.cancel() | |
} | |
MotionEvent.ACTION_MOVE -> { | |
android_bot.x = motionEvent.rawX - xDiffInTouchPointAndViewTopLeftCorner | |
android_bot.y = motionEvent.rawY - yDiffInTouchPointAndViewTopLeftCorner | |
} | |
MotionEvent.ACTION_UP -> { | |
springAnimationTranslationX.start() | |
springAnimationTranslationY.start() | |
} | |
} | |
true | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment