/** * Removes all traces of the player, so that the object is eligible for garbage collection * * @param player */ public void removePlayer(Player player) { Log.i(TAG, "Removing player: " + player.getName()); boolean wasOnBreak = game.isOnBreak(); // Removing player from the game removes it from the adapter too, as they reference the same // ArrayList<Player> game.removePlayer(player); playersView.setPlayerList(game.getPlayers()); // Notify the adapter to update the view playersAdapter.notifyDataSetChanged(); // Deduce changes to view states from game states if (!game.hasPlayers()) resetGame(); else if (game.isOnBreak() && !wasOnBreak) endRound(); }
public void addPlayer(String name) { game.addPlayer(name); playersView.setPlayerList(game.getPlayers()); playersAdapter.notifyDataSetChanged(); }