From 007122e4b0d114322be3b21a51e13f7f2fa3299b Mon Sep 17 00:00:00 2001 From: "luca0N\\!" Date: Wed, 3 Mar 2021 01:38:26 -0300 Subject: [PATCH] Fix app crash on boolean questions Fixed a bug which caused an app crash if the user picked the wrong answer on a boolean question. Based on #4. --- .../pluck/fragments/TriviaQuestionFragment.java | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/app/src/main/java/com/luca0n/joguitos/pluck/fragments/TriviaQuestionFragment.java b/app/src/main/java/com/luca0n/joguitos/pluck/fragments/TriviaQuestionFragment.java index eaa02fa..0e53613 100644 --- a/app/src/main/java/com/luca0n/joguitos/pluck/fragments/TriviaQuestionFragment.java +++ b/app/src/main/java/com/luca0n/joguitos/pluck/fragments/TriviaQuestionFragment.java @@ -43,7 +43,7 @@ import com.luca0n.joguitos.pluck.R; import com.luca0n.joguitos.pluck.activities.TriviaGameActivity; import com.luca0n.joguitos.pluck.trivia.TriviaQuestion; import com.luca0n.joguitos.pluck.trivia.TriviaQuestionMultiple; - +import com.luca0n.joguitos.pluck.trivia.TriviaQuestionBoolean; public class TriviaQuestionFragment extends Fragment { @@ -112,9 +112,12 @@ public class TriviaQuestionFragment extends Fragment { } } } else { - buttonAnswerTrue.setOnClickListener(listener); - buttonAnswerFalse.setOnClickListener(listener); - } + buttonAnswerTrue.setOnClickListener(listener); + buttonAnswerFalse.setOnClickListener(listener); + + boolean correctAnswer = ((TriviaQuestionBoolean) question).checkAnswer("true"); + buttonAnswerCorrect = correctAnswer ? buttonAnswerTrue : buttonAnswerFalse; + } } private void disableButtons() {