Skip to content

Instantly share code, notes, and snippets.

@amanjeetsingh150
Created January 4, 2018 20:48
Show Gist options
  • Save amanjeetsingh150/ba034d072f034692bb076846b989435e to your computer and use it in GitHub Desktop.
Save amanjeetsingh150/ba034d072f034692bb076846b989435e to your computer and use it in GitHub Desktop.
OnAnimationEnd of SpringAnimation
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