mirror of
https://github.com/SimpleMobileTools/Simple-Clock.git
synced 2025-02-02 03:26:48 +01:00
use Apply at some state bundles
This commit is contained in:
parent
51513e625d
commit
a7a148e57c
@ -140,20 +140,22 @@ class StopwatchFragment : Fragment() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun onSaveInstanceState(outState: Bundle) {
|
override fun onSaveInstanceState(outState: Bundle) {
|
||||||
outState.putBoolean(WAS_RUNNING, isRunning)
|
outState.apply {
|
||||||
outState.putInt(TOTAL_TICKS, totalTicks)
|
putBoolean(WAS_RUNNING, isRunning)
|
||||||
outState.putInt(CURRENT_TICKS, currentTicks)
|
putInt(TOTAL_TICKS, totalTicks)
|
||||||
outState.putInt(LAP_TICKS, lapTicks)
|
putInt(CURRENT_TICKS, currentTicks)
|
||||||
super.onSaveInstanceState(outState)
|
putInt(LAP_TICKS, lapTicks)
|
||||||
|
super.onSaveInstanceState(this)
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onViewStateRestored(savedInstanceState: Bundle?) {
|
override fun onViewStateRestored(savedInstanceState: Bundle?) {
|
||||||
super.onViewStateRestored(savedInstanceState)
|
super.onViewStateRestored(savedInstanceState)
|
||||||
if (savedInstanceState != null) {
|
savedInstanceState?.apply {
|
||||||
isRunning = savedInstanceState.getBoolean(WAS_RUNNING, false)
|
isRunning = getBoolean(WAS_RUNNING, false)
|
||||||
totalTicks = savedInstanceState.getInt(TOTAL_TICKS, 0)
|
totalTicks = getInt(TOTAL_TICKS, 0)
|
||||||
currentTicks = savedInstanceState.getInt(CURRENT_TICKS, 0)
|
currentTicks = getInt(CURRENT_TICKS, 0)
|
||||||
lapTicks = savedInstanceState.getInt(LAP_TICKS, 0)
|
lapTicks = getInt(LAP_TICKS, 0)
|
||||||
if (isRunning) {
|
if (isRunning) {
|
||||||
uptimeAtStart = SystemClock.uptimeMillis() - currentTicks * UPDATE_INTERVAL
|
uptimeAtStart = SystemClock.uptimeMillis() - currentTicks * UPDATE_INTERVAL
|
||||||
updateStopwatchState(false)
|
updateStopwatchState(false)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user