Commit 6333d227 authored by Niklas Fix's avatar Niklas Fix 🎓

fix #37

parent 75f52e78
......@@ -272,7 +272,6 @@ class DuelListFragment :
intent.putExtra(KEY_DUEL, duel)
intent.putExtra(KEY_POOL, pool)
startActivity(intent)
activity?.finish()
}
override fun onDuelClick(duel: Duel, status: String) {
......
......@@ -3,6 +3,8 @@ package de.akamu.tudarmstadt.features.questions
import android.app.AlertDialog
import android.content.DialogInterface
import android.content.Intent
import android.content.Intent.FLAG_ACTIVITY_CLEAR_TASK
import android.content.Intent.FLAG_ACTIVITY_NEW_TASK
import android.os.Bundle
import android.text.Editable
import android.text.TextWatcher
......@@ -133,6 +135,7 @@ class QuestionActivity :
val answerFragment = loadAnswerFragment(answer)
ft.replace(R.id.fragment_questionactivity_bottomcontainer, answerFragment)
ft.addToBackStack(null)
ft.commit()
}
......@@ -222,6 +225,7 @@ class QuestionActivity :
// i.putExtra(KEY_DUEL, mDuel)
// As long as this is not implemented, directly navigate back to the dashboard
val i = Intent(this, MainActivity::class.java)
i.addFlags(FLAG_ACTIVITY_NEW_TASK or FLAG_ACTIVITY_CLEAR_TASK)
startActivity(i)
finish()
}
......@@ -307,8 +311,12 @@ class QuestionActivity :
}
override fun onBackPressed() {
Toast.makeText(this, this.getString(R.string.back_during_question), Toast.LENGTH_LONG)
.show()
if (presenter.duelHasStarted) {
Toast.makeText(this, this.getString(R.string.back_during_question), Toast.LENGTH_LONG)
.show()
} else {
super.onBackPressed()
}
}
/*
......
......@@ -44,6 +44,8 @@ interface QuestionContract {
interface Presenter : BasePresenter{
/** Indicates whether the user answered correctly or not **/
var userAnswers: ArrayList<Boolean>
/** Indicates whether the duel has started **/
var duelHasStarted: Boolean
/** Load the current round from the server **/
fun loadRound(roundID: Int)
/** Decide how to move on **/
......
......@@ -21,6 +21,7 @@ class QuestionPresenter(
override var userAnswers: ArrayList<Boolean> = arrayListOf()
override var duelHasStarted: Boolean = false
lateinit var mRound: Round
var questionNumber: Int = 0
......@@ -35,6 +36,7 @@ class QuestionPresenter(
override fun loadRound(roundID: Int) {
interactor.loadRound(roundID, object : DuelDataSource.LoadRoundCallback {
override fun onLoadRoundSuccess(round: Round) {
duelHasStarted = true
mRound = round
view?.hideLoadingAnimation()
view?.showQuestionLayout()
......@@ -43,6 +45,7 @@ class QuestionPresenter(
}
override fun onLoadRoundFailed(reason: String) {
duelHasStarted = false
view?.hideLoadingAnimation()
view?.showLoadRoundFailed(reason)
}
......@@ -154,6 +157,8 @@ class QuestionPresenter(
override fun onSubmitUserAnswerFailed(reason: String) {
view?.showSubmitUserAnswerFailed(reason)
// Note: We need the following because otherwise the user is stuck in the current screen
view?.showContinueOptions()
}
})
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment