[#23] Limit input to 5 digits.
This commit is contained in:
@@ -0,0 +1,12 @@
|
||||
package me.zobrist.tichucounter.domain
|
||||
|
||||
fun String.digitCount(): Int {
|
||||
var count = 0
|
||||
this.forEach {
|
||||
if (it.isDigit()) {
|
||||
count++
|
||||
}
|
||||
}
|
||||
return count
|
||||
}
|
||||
|
||||
@@ -10,6 +10,7 @@ import dagger.hilt.android.lifecycle.HiltViewModel
|
||||
import kotlinx.coroutines.launch
|
||||
import me.zobrist.tichucounter.data.entity.Round
|
||||
import me.zobrist.tichucounter.domain.Tichu
|
||||
import me.zobrist.tichucounter.domain.digitCount
|
||||
import me.zobrist.tichucounter.domain.getTotalPoints
|
||||
import me.zobrist.tichucounter.repository.GameRepository
|
||||
import javax.inject.Inject
|
||||
@@ -202,9 +203,12 @@ class CounterViewModel @Inject constructor(
|
||||
override fun digitClicked(digit: String) {
|
||||
focusLastInput()
|
||||
|
||||
activeValue += digit
|
||||
updateOtherScore()
|
||||
updateSubmitButton()
|
||||
if(activeValue.digitCount() < 5)
|
||||
{
|
||||
activeValue += digit
|
||||
updateOtherScore()
|
||||
updateSubmitButton()
|
||||
}
|
||||
}
|
||||
|
||||
override fun negateClicked() {
|
||||
|
||||
Reference in New Issue
Block a user