Gitlab@Informatics

Skip to content
Snippets Groups Projects
Commit 7ea81712 authored by 62160052's avatar 62160052
Browse files

Dialogs

parent a35c97e6
No related branches found
No related tags found
No related merge requests found
......@@ -25,6 +25,7 @@ import androidx.fragment.app.Fragment
import androidx.fragment.app.viewModels
import com.example.android.unscramble.R
import com.example.android.unscramble.databinding.GameFragmentBinding
import com.google.android.material.dialog.MaterialAlertDialogBuilder
/**
* Fragment where the game is played, contains the game logic.
......@@ -111,6 +112,20 @@ class GameFragment : Fragment() {
activity?.finish()
}
private fun showFinalScoreDialog() {
MaterialAlertDialogBuilder(requireContext())
.setTitle(getString(R.string.congratulations))
.setMessage(getString(R.string.you_scored, viewModel.score))
.setCancelable(false)
.setNegativeButton(getString(R.string.exit)) { _, _ ->
exitGame()
}
.setPositiveButton(getString(R.string.play_again)) { _, _ ->
restartGame()
}
.show()
}
/*
* Sets and resets the text field error status.
*/
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment