Example #1
0
  private void initializeQuestionTextViews(Question currentQuestion) {
    //
    mCurrentQuestion = currentQuestion;

    if (mReverseNumbersInQuestions) {
      textViewQuestion.setText(
          mStringParser.reverseNumbersInStringHebrew(
              mCurrentGame.getCurrentQuestion().getQuestion()));

      textViewTimesPlayedTitle.setText(
          mStringParser.reverseNumbersInStringHebrew(
              getString(R.string.textViewTimesPlayedTitleText)
                  + mCurrentGame.getCurrentQuestion().getQuestionTimesPlayed()));
    } else {
      textViewQuestion.setText(mCurrentGame.getCurrentQuestion().getQuestion());
      textViewTimesPlayedTitle.setText(
          getString(R.string.textViewTimesPlayedTitleText)
              + " "
              + mCurrentGame.getCurrentQuestion().getQuestionTimesPlayed());
    }
    // setting question difficulty
    textViewQuestionLevel.setText(mCurrentGame.getCurrentLevelAsString());

    textViewHowManyTimesQuestionsBeenAsked.setText(
        mCurrentGame.getHowManyTimesQuestionsBeenAsked());

    // randomize answer places (indices)
    mCurrentQuestion.randomizeAnswerPlaces(m_Random);

    buttonAnswer1.setText(mCurrentQuestion.getAnswer1());
    buttonAnswer2.setText(mCurrentQuestion.getAnswer2());
    buttonAnswer3.setText(mCurrentQuestion.getAnswer3());
    buttonAnswer4.setText(mCurrentQuestion.getAnswer4());
  }
Example #2
0
  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);
  }