Update stopwatch views only from UI thread

This commit is contained in:
Ensar Sarajčić 2023-09-14 12:42:29 +02:00
parent adc225f838
commit dc42d5631e

View file

@ -199,13 +199,13 @@ class StopwatchFragment : Fragment() {
private val updateListener = object : Stopwatch.UpdateListener {
override fun onUpdate(totalTime: Long, lapTime: Long, useLongerMSFormat: Boolean) {
activity?.run {
activity?.runOnUiThread {
updateDisplayedText(totalTime, lapTime, useLongerMSFormat)
}
}
override fun onStateChanged(state: Stopwatch.State) {
activity?.run {
activity?.runOnUiThread {
updateIcons(state)
binding.stopwatchLap.beVisibleIf(state == Stopwatch.State.RUNNING)
binding.stopwatchReset.beVisibleIf(state != Stopwatch.State.STOPPED)