Commit 65de2a50 by likorn

Animation is cancelled after answering

parent ffb2eddd
...@@ -18,6 +18,7 @@ class TaskActivity : AppCompatActivity() { ...@@ -18,6 +18,7 @@ class TaskActivity : AppCompatActivity() {
private lateinit var answerSet: AnswerSet private lateinit var answerSet: AnswerSet
private var millisToSolve: Long = 4000 private var millisToSolve: Long = 4000
private lateinit var timer: CountDownTimer private lateinit var timer: CountDownTimer
private lateinit var colorAnimation: ValueAnimator
override fun onCreate(savedInstanceState: Bundle?) { override fun onCreate(savedInstanceState: Bundle?) {
super.onCreate(savedInstanceState) super.onCreate(savedInstanceState)
...@@ -48,6 +49,7 @@ class TaskActivity : AppCompatActivity() { ...@@ -48,6 +49,7 @@ class TaskActivity : AppCompatActivity() {
private fun processAnswer(correct: Boolean) { private fun processAnswer(correct: Boolean) {
timer.cancel() timer.cancel()
colorAnimation.cancel()
makeButtonsUncheckable() makeButtonsUncheckable()
val responseFragment = ResponseFragment.newInstance().also { val responseFragment = ResponseFragment.newInstance().also {
...@@ -69,7 +71,7 @@ class TaskActivity : AppCompatActivity() { ...@@ -69,7 +71,7 @@ class TaskActivity : AppCompatActivity() {
private fun startProgressBarAnimation() { private fun startProgressBarAnimation() {
val colorFrom = Color.TRANSPARENT val colorFrom = Color.TRANSPARENT
val colorTo = ContextCompat.getColor(this, R.color.transparent_red) val colorTo = ContextCompat.getColor(this, R.color.transparent_red)
val colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo) colorAnimation = ValueAnimator.ofObject(ArgbEvaluator(), colorFrom, colorTo)
colorAnimation.duration = millisToSolve colorAnimation.duration = millisToSolve
colorAnimation.addUpdateListener { animator -> colorAnimation.addUpdateListener { animator ->
layout_gradient.background.setColorFilter(animator.animatedValue as Int, layout_gradient.background.setColorFilter(animator.animatedValue as Int,
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or sign in to comment