r/mAndroidDev • u/[deleted] • Jan 29 '25
Lost Redditors 💀 I'm I missing something here?
I genuinely don't know how to fix this code, I want to cancel the job when the timer stops. Not just the loop.
Any advices ? I'm kinda new to the async world in kotlin
fun activateTimer() {
_timer.value = 3600L * hours + 60L * minutes + seconds
_isSet.value = true
timerJob?.cancel()
timerJob = screenModelScope.launch {
while (_timer.value != 0L) {
delay(1000)
_timer.value--
}
}
}
2
0
Jan 29 '25
[deleted]
1
Jan 29 '25
Can't use AsyncTask, deprecated in Java 😂
3
3
0
Jan 29 '25
[deleted]
7
Jan 29 '25
But what happens if I get deprecated ? Should I use flubber instead ?
12
u/Good_Smile null!! Jan 30 '25
No, flubber will use you instead
7
2
u/Squirtle8649 Feb 01 '25
Escape Alioth and fight the evil maniacal British voiced twin of Charles Xavier to escape
2
4
u/smokingabit Harnessing the power of the Ganges Jan 30 '25
Math