@Override public void onDialogResult(MainDialog caller, Bundle result) { Intent intent; switch (result.getInt("newOrEnd")) { case R.id.newGame: game = new Game(game.getMode(), game.getPlayer(Game.PLAYER1), game.getPlayer(Game.PLAYER2)); updateGraphic(); saveGame(false); break; case R.id.quit: intent = new Intent(GameActivity.this, HomeActivity.class); startActivity(intent); break; default: break; } }
private void saveGame(boolean show) { File file = new File(getFilesDir(), "game_" + game.getMode()); Tools.writeSerializableInFile(this, game, file); if (show) Tools.Toast(this, "Game saved"); }