I am trying to make a CountDownTimer for my Android app, but every time I try to start it using just timer.start(), it starts multiple timers. I don't know why.
My code for this is:
fun DissapearSkip() {
skipTimeButton.visibility = View.VISIBLE
exoSkip.visibility = View.GONE
skipTimeText.text = new.skipType.getType()
skipTimeButton.setOnClickListener {
exoPlayer.seekTo((new.interval.endTime * 1000).toLong())
}
val timer = object : CountDownTimer(5000, 1000) {
override fun onTick(millisUntilFinished: Long) {
println(millisUntilFinished)
if (new == null) {
skipTimeButton.visibility = View.GONE
exoSkip.visibility = View.VISIBLE
dissappeared = false
return
}
}
override fun onFinish() {
val skip = currentTimeStamp
skipTimeButton.visibility = View.GONE
exoSkip.visibility = View.VISIBLE
dissappeared = true
}
}
timer.start()
}
also the new variable is for getting the timestamp type and info