From 1f82b7d8b87762c93e320afc54193f49122e88d3 Mon Sep 17 00:00:00 2001 From: Aditya Arora Date: Fri, 26 May 2017 04:48:05 +0530 Subject: [PATCH] Fixed issue of getting blank cell on double click --- .../com/acme/tictactoe/viewmodel/TicTacToeViewModel.java | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/acme/tictactoe/viewmodel/TicTacToeViewModel.java b/app/src/main/java/com/acme/tictactoe/viewmodel/TicTacToeViewModel.java index d37b334..aa1ff5e 100644 --- a/app/src/main/java/com/acme/tictactoe/viewmodel/TicTacToeViewModel.java +++ b/app/src/main/java/com/acme/tictactoe/viewmodel/TicTacToeViewModel.java @@ -44,9 +44,12 @@ public void onResetSelected() { } public void onClickedCellAt(int row, int col) { - Player playerThatMoved = model.mark(row, col); - cells.put("" + row + col, playerThatMoved == null ? null : playerThatMoved.toString()); - winner.set(model.getWinner() == null ? null : model.getWinner().toString()); + if (!cells.containsKey("" + row + col)) { + Player playerThatMoved = model.mark(row, col); + cells.put("" + row + col, playerThatMoved == null ? null : playerThatMoved.toString()); + winner.set(model.getWinner() == null ? null : model.getWinner().toString()); + } + } }