Skip to content

Instantly share code, notes, and snippets.

@ar-android
Created September 21, 2018 16:57
Show Gist options
  • Save ar-android/64b744a16baf5aa648da76446c2df6ef to your computer and use it in GitHub Desktop.
Save ar-android/64b744a16baf5aa648da76446c2df6ef to your computer and use it in GitHub Desktop.
Animation FallUp
var fallUpAnimation: ValueAnimator? = null
private fun fallUp() {
fallDawnAnimation.cancel()
if (fallUpAnimation != null) {
if (fallUpAnimation!!.isRunning) {
fallUpAnimation!!.cancel()
}
}
fallUpAnimation = ValueAnimator.ofInt(circle_height, circle_height - 350)
with(fallUpAnimation!!) {
duration = 450
addUpdateListener {
circle_height = it.animatedValue as Int
invalidate()
}
addListener(object : AnimatorListenerAdapter() {
override fun onAnimationEnd(animation: Animator?) {
fallDown()
}
})
start()
}
}
override fun onTouchEvent(event: MotionEvent?): Boolean {
when (event?.action) {
MotionEvent.ACTION_DOWN -> {
fallUp()
}
}
return super.onTouchEvent(event)
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment