Merge pull request #524 from esensar/fix/stopwatch-crash

Update stopwatch views only from UI thread
This commit is contained in:
Tibor Kaputa 2023-09-18 09:07:07 +02:00 committed by GitHub
commit 29b65a0f7e
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

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)