mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-05-31 19:29:14 +02:00
add a helper function for reseting stopwatch
This commit is contained in:
parent
f19b8140cd
commit
af91f217ef
@ -42,17 +42,7 @@ class StopwatchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_reset.setOnClickListener {
|
stopwatch_reset.setOnClickListener {
|
||||||
updateHandler.removeCallbacksAndMessages(null)
|
resetStopwatch()
|
||||||
isRunning = false
|
|
||||||
currentTicks = 0
|
|
||||||
totalTicks = 0
|
|
||||||
currentLap = 0
|
|
||||||
lapTicks = 0
|
|
||||||
laps.clear()
|
|
||||||
stopwatch_reset.beGone()
|
|
||||||
stopwatch_lap.beGone()
|
|
||||||
stopwatch_time.text = 0L.formatStopwatchTime(false)
|
|
||||||
updateIcons()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
stopwatch_lap.setOnClickListener {
|
stopwatch_lap.setOnClickListener {
|
||||||
@ -118,6 +108,23 @@ class StopwatchFragment : Fragment() {
|
|||||||
view.stopwatch_time.text = (totalTicks * UPDATE_INTERVAL).formatStopwatchTime(false)
|
view.stopwatch_time.text = (totalTicks * UPDATE_INTERVAL).formatStopwatchTime(false)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private fun resetStopwatch() {
|
||||||
|
updateHandler.removeCallbacksAndMessages(null)
|
||||||
|
isRunning = false
|
||||||
|
currentTicks = 0
|
||||||
|
totalTicks = 0
|
||||||
|
currentLap = 0
|
||||||
|
lapTicks = 0
|
||||||
|
laps.clear()
|
||||||
|
updateIcons()
|
||||||
|
|
||||||
|
view.apply {
|
||||||
|
stopwatch_reset.beGone()
|
||||||
|
stopwatch_lap.beGone()
|
||||||
|
stopwatch_time.text = 0L.formatStopwatchTime(false)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private val updateRunnable = object : Runnable {
|
private val updateRunnable = object : Runnable {
|
||||||
override fun run() {
|
override fun run() {
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user