add a helper function for reseting stopwatch
This commit is contained in:
parent
f19b8140cd
commit
af91f217ef
1 changed files with 18 additions and 11 deletions
|
@ -42,17 +42,7 @@ class StopwatchFragment : Fragment() {
|
|||
}
|
||||
|
||||
stopwatch_reset.setOnClickListener {
|
||||
updateHandler.removeCallbacksAndMessages(null)
|
||||
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()
|
||||
resetStopwatch()
|
||||
}
|
||||
|
||||
stopwatch_lap.setOnClickListener {
|
||||
|
@ -118,6 +108,23 @@ class StopwatchFragment : Fragment() {
|
|||
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 {
|
||||
override fun run() {
|
||||
if (isRunning) {
|
||||
|
|
Loading…
Reference in a new issue