Skip to content
This repository has been archived by the owner on Jul 25, 2022. It is now read-only.

Commit

Permalink
Merge pull request #2 from dhebbeker/bugfix/toast-queue
Browse files Browse the repository at this point in the history
Show "Game Over" text notification before finishing game.
  • Loading branch information
dhebbeker authored Mar 17, 2018
2 parents 252bcb8 + 165d450 commit d214fc2
Showing 1 changed file with 6 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ public class MainActivity extends AppCompatActivity implements GameBoardInterfac
private final SymbolButton[] symbols = new SymbolButton[4];
private final Game game = new Game(this, symbols);
private View startGameButton;
private Toast notification = null;

@Override
protected void onCreate(final Bundle savedInstanceState)
Expand Down Expand Up @@ -102,7 +103,11 @@ public void run()
@Override
public void notifyUser(final String userMessage)
{
Toast notification = Toast.makeText(this, userMessage, Toast.LENGTH_LONG);
if (notification != null) // check if a notification has been created before
{
notification.cancel(); // cancel potential previous notification
}
notification = Toast.makeText(this, userMessage, Toast.LENGTH_LONG);
notification.show();
}

Expand Down

0 comments on commit d214fc2

Please sign in to comment.