From dc42d5631e07c8d1a3d5cd6abc073a04d01e915d Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Ensar=20Saraj=C4=8Di=C4=87?= Date: Thu, 14 Sep 2023 12:42:29 +0200 Subject: [PATCH] Update stopwatch views only from UI thread --- .../simplemobiletools/clock/fragments/StopwatchFragment.kt | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt index 39c8bce2..05ee77f7 100644 --- a/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt +++ b/app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt @@ -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)