mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-06-01 19:59:23 +02:00
Update stopwatch views only from UI thread
This commit is contained in:
parent
adc225f838
commit
dc42d5631e
@ -199,13 +199,13 @@ class StopwatchFragment : Fragment() {
|
|||||||
|
|
||||||
private val updateListener = object : Stopwatch.UpdateListener {
|
private val updateListener = object : Stopwatch.UpdateListener {
|
||||||
override fun onUpdate(totalTime: Long, lapTime: Long, useLongerMSFormat: Boolean) {
|
override fun onUpdate(totalTime: Long, lapTime: Long, useLongerMSFormat: Boolean) {
|
||||||
activity?.run {
|
activity?.runOnUiThread {
|
||||||
updateDisplayedText(totalTime, lapTime, useLongerMSFormat)
|
updateDisplayedText(totalTime, lapTime, useLongerMSFormat)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onStateChanged(state: Stopwatch.State) {
|
override fun onStateChanged(state: Stopwatch.State) {
|
||||||
activity?.run {
|
activity?.runOnUiThread {
|
||||||
updateIcons(state)
|
updateIcons(state)
|
||||||
binding.stopwatchLap.beVisibleIf(state == Stopwatch.State.RUNNING)
|
binding.stopwatchLap.beVisibleIf(state == Stopwatch.State.RUNNING)
|
||||||
binding.stopwatchReset.beVisibleIf(state != Stopwatch.State.STOPPED)
|
binding.stopwatchReset.beVisibleIf(state != Stopwatch.State.STOPPED)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user