private void checkAnswer(int i, Button o_Button) { // mCurrentGame.questionClockStop(); // this is implemented in order to prevent double click disableAnswerButtons(); // checking if time is up if (i == -1) { startSoundFromSoundPool(mSoundAnswerWrong, 0); mCurrentGame.checkIsAnswerCorrect(i); } else if (i == -2) { // if pass question pressed } else { if (mCurrentGame.checkIsAnswerCorrect(i)) { setButtonGreen(o_Button); startSoundFromSoundPool(mSoundAnswerCorrect, 0); mTriviaDb.incUserCorrectCounter(mCurrentQuestion.getQuestionId()); toastLastScore(); setGameScoreText(mCurrentGame.getGameScoreAsString()); } else { startSoundFromSoundPool(mSoundAnswerWrong, 0); setButtonRed(o_Button); mTriviaDb.incUserWrongCounter(mCurrentQuestion.getQuestionId()); // checking if the user answer wrong and we need to show the // correct answer if (mShowCorrectAnswer) { setButtonGreen(mCurrentQuestion.getCorrectAnswerIndex()); } } } textViewLivesLeftValue.setText(mCurrentGame.getCurrentLivesAsString()); new StartNewQuestionAsync().execute(1000); }
private void showGameOver() { // send score if (getGamesClient().isConnected()) { getGamesClient() .submitScore(getString(R.string.game_levels_leadersboard), mCurrentGame.getGameScore()); } mCurrentGame.questionClockStop(); AlertDialog.Builder gameOverDialog = new AlertDialog.Builder(this); gameOverDialog.setTitle(getString(R.string.game_over)); gameOverDialog.setCancelable(false); gameOverDialog.setPositiveButton( getString(R.string.exit), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // finish(); } }); gameOverDialog.setNegativeButton( getString(R.string.new_game), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // parseGameSetupAndStart(); } }); if (!isFinishing()) { gameOverDialog.show(); } }
private void showStartLevel() { // verifying clock is stopped mCurrentGame.questionClockStop(); AlertDialog.Builder levelFinished = new AlertDialog.Builder(this); levelFinished.setTitle("שלב" + " " + mCurrentGame.getNextLevelAsString()); levelFinished.setCancelable(false); levelFinished.setPositiveButton( getString(R.string.start), new DialogInterface.OnClickListener() { @Override public void onClick(DialogInterface dialog, int which) { // mCurrentGame.startNewRound(); } }); if (!isFinishing()) { levelFinished.show(); } }