Skip to content

Instantly share code, notes, and snippets.

@EgorSalenko
Created May 1, 2019 20:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save EgorSalenko/230b39d2c840ac0f3010aa599ec98ad7 to your computer and use it in GitHub Desktop.
Save EgorSalenko/230b39d2c840ac0f3010aa599ec98ad7 to your computer and use it in GitHub Desktop.
private fun animationOpenNewTask() {
if (!isNewTaskOpened) {
val x = addTaskButton.x.toInt() + addTaskButton.width / 2
val y = addTaskButton.y.toInt() + addTaskButton.height / 2
val startRadius = 0.0f
val endRadius = (Math.hypot(
overlayFragmentContainer.width.toDouble(),
overlayFragmentContainer.height.toDouble()
)).toFloat()
val anim =
ViewAnimationUtils.createCircularReveal(overlayFragmentContainer, x, y, startRadius, endRadius).apply {
interpolator = FastOutLinearInInterpolator()
duration = 800
addListener(object : AnimatorListenerAdapter {
override fun onAnimationStart(animation: Animator?) {
overlayFragmentContainer.visibility = View.VISIBLE
}
})
}
anim.start()
isNewTaskOpened = true
} else {
val x = addTaskButton.x.toInt() + addTaskButton.width / 2
val y = addTaskButton.y.toInt() + addTaskButton.height / 2
val startRadius = (Math.hypot(
overlayFragmentContainer.width.toDouble(),
overlayFragmentContainer.height.toDouble()
)).toFloat()
val endRadius = 0.0f
val anim =
ViewAnimationUtils.createCircularReveal(overlayFragmentContainer, x, y, startRadius, endRadius).apply {
interpolator = FastOutLinearInInterpolator()
duration = 500
}
anim.addListener(object : AnimatorListenerAdapter {
override fun onAnimationEnd(animation: Animator?) {
overlayFragmentContainer.visibility = View.INVISIBLE
}
})
anim.start()
isNewTaskOpened = false
}
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment