Created
September 21, 2018 16:57
-
-
Save ar-android/64b744a16baf5aa648da76446c2df6ef to your computer and use it in GitHub Desktop.
Animation FallUp
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
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