Getting correct value of "gameSolved" key (Found when working on Issue #37)

Observation:
  savedInstanceState.getInt("gameSolved") ALWAYS returned 0 (default).
  The key "gameSolved" is set with putBoolean, which is correct. A ClassCastException was thrown in getInt and the catch block returned the default 0-value.

Issues before change:
  Multiple statements that are supposed to be executed based on gameSolved (like disabling the special keys and the sudoku grid), were skipped.
  Because of that, after finishing a game, if someone changed the screen orientation, the keys and the grid became active again and the grid could be modified.

Changes done:
  1. Changed it to getBoolean("gameSolved")
  2. Removed the " == 1" part because that is redundant for a boolean.
This commit is contained in:
rdatta95 2020-11-04 21:32:04 +05:30
parent 98bacc4dc3
commit 8f92a067f3

View file

@ -306,7 +306,7 @@ public class GameActivity extends BaseActivity implements NavigationView.OnNavig
finish(); finish();
overridePendingTransition(0, 0); overridePendingTransition(0, 0);
} }
gameSolved = savedInstanceState.getInt("gameSolved") == 1; gameSolved = savedInstanceState.getBoolean("gameSolved");
} }