Created
January 4, 2018 20:48
-
-
Save amanjeetsingh150/ba034d072f034692bb076846b989435e to your computer and use it in GitHub Desktop.
OnAnimationEnd of SpringAnimation
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
override fun onAnimationEnd(animation: DynamicAnimation<out DynamicAnimation<*>>?, canceled: Boolean, value: Float, velocity: Float) { | |
val displayMetrics = DisplayMetrics() | |
windowManager.defaultDisplay.getMetrics(displayMetrics) | |
val height = displayMetrics.heightPixels.toFloat() | |
val width = displayMetrics.widthPixels | |
relative_layout.animate() | |
.setStartDelay(1) | |
.translationXBy(width.toFloat() / 2) | |
.translationYBy(height) | |
.setListener(object : Animator.AnimatorListener { | |
override fun onAnimationRepeat(p0: Animator?) { | |
} | |
override fun onAnimationEnd(p0: Animator?) { | |
val intent = Intent(applicationContext, MainActivity::class.java) | |
finish() | |
startActivity(intent) | |
overridePendingTransition(0, 0) | |
} | |
override fun onAnimationCancel(p0: Animator?) { | |
} | |
override fun onAnimationStart(p0: Animator?) { | |
} | |
}) | |
.setInterpolator(DecelerateInterpolator(1f)) | |
.start() | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment