This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4936497-your-first-kotlin-android-app/lessons/35
This is a companion discussion topic for the original entry at https://www.raywenderlich.com/4936497-your-first-kotlin-android-app/lessons/35
It appears that if there鈥檚 an existing savedInstanceState
, the restoreGame
method will always start a countdown timer and always turn gameStarted
to true. I realize if the time remaining is zero, the onFinished
will be immediately called but this seems like a waste of computation, when we can easily deduce by timeLeftOnTimer whether we should instantiate a countdown timer or not.
@rbondoc Can you please help with this when you get a chance? Thank you - much appreciated! :]
It鈥檚 not just a performance issue, as we are always saving the state in the onSaveInstanceState
method, we are having a state even when we are not supposed to. When we are not in the game (before the first game or after one game is finished but another one is not started yet) and rotate the device, then a state is saved and restored. Thus a game is started even though we were not in the game.