Skip to content

Commit dc42d56

Browse files
committed
Update stopwatch views only from UI thread
1 parent adc225f commit dc42d56

File tree

1 file changed

+2
-2
lines changed

1 file changed

+2
-2
lines changed

app/src/main/kotlin/com/simplemobiletools/clock/fragments/StopwatchFragment.kt

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,13 +199,13 @@ class StopwatchFragment : Fragment() {
199199

200200
private val updateListener = object : Stopwatch.UpdateListener {
201201
override fun onUpdate(totalTime: Long, lapTime: Long, useLongerMSFormat: Boolean) {
202-
activity?.run {
202+
activity?.runOnUiThread {
203203
updateDisplayedText(totalTime, lapTime, useLongerMSFormat)
204204
}
205205
}
206206

207207
override fun onStateChanged(state: Stopwatch.State) {
208-
activity?.run {
208+
activity?.runOnUiThread {
209209
updateIcons(state)
210210
binding.stopwatchLap.beVisibleIf(state == Stopwatch.State.RUNNING)
211211
binding.stopwatchReset.beVisibleIf(state != Stopwatch.State.STOPPED)

0 commit comments

Comments
 (0)