Fix undo
This commit is contained in:
parent
c78e159dc6
commit
861196e118
@ -93,15 +93,6 @@ class MatchActivity : AppCompatActivity() {
|
|||||||
updateUI()
|
updateUI()
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun onBackPressed() {
|
|
||||||
if (matchModel?.pointId == 0)
|
|
||||||
super.onBackPressed()
|
|
||||||
else {
|
|
||||||
matchModel?.undo()
|
|
||||||
updateUI()
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
fun updateUI() {
|
fun updateUI() {
|
||||||
matchModel?.apply {
|
matchModel?.apply {
|
||||||
textScore?.text = getString(
|
textScore?.text = getString(
|
||||||
@ -204,4 +195,13 @@ class MatchActivity : AppCompatActivity() {
|
|||||||
hashMapOf(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID to "TTS")
|
hashMapOf(TextToSpeech.Engine.KEY_PARAM_UTTERANCE_ID to "TTS")
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun onBackPressed() {
|
||||||
|
if (matchModel?.pointId == 0)
|
||||||
|
super.onBackPressed()
|
||||||
|
else {
|
||||||
|
matchModel?.undo()
|
||||||
|
updateUI()
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,7 +12,7 @@ class MatchModel : ViewModel() {
|
|||||||
var relaunchSide: Int = 1
|
var relaunchSide: Int = 1
|
||||||
var ttsEnabled: Boolean = false
|
var ttsEnabled: Boolean = false
|
||||||
var sttEnabled: Boolean = false
|
var sttEnabled: Boolean = false
|
||||||
var pointId: Int = 0
|
var pointId: Int = -1
|
||||||
var history: MutableList<Point> = ArrayList()
|
var history: MutableList<Point> = ArrayList()
|
||||||
|
|
||||||
fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) {
|
fun startMatch(player1Name: String, player2Name:String, starterId: Int, enableTTS: Boolean, enableSTT: Boolean) {
|
||||||
@ -53,7 +53,7 @@ class MatchModel : ViewModel() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun undo() {
|
fun undo() {
|
||||||
history[pointId--].let {
|
history[--pointId].let {
|
||||||
players.zip(it.score).forEach{(player, score) -> player.score = score}
|
players.zip(it.score).forEach{(player, score) -> player.score = score}
|
||||||
serviceSide = it.serviceSide
|
serviceSide = it.serviceSide
|
||||||
relaunchSide = when(serviceSide) {
|
relaunchSide = when(serviceSide) {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user