Bugfix: Just working with Add100 and Sub100 button does not allow to submit values.

This commit is contained in:
2020-08-30 18:13:14 +02:00
parent 4069fe86a7
commit 587651d697

View File

@@ -63,7 +63,7 @@ class MainActivity : AppCompatActivity() {
} }
} }
if (currentRound.isValidRound()) { if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
enableSubmitButton() enableSubmitButton()
} else { } else {
disableSubmitButton() disableSubmitButton()
@@ -94,7 +94,7 @@ class MainActivity : AppCompatActivity() {
} }
} }
if (currentRound.isValidRound()) { if (currentRound.isValidRound() && inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
enableSubmitButton() enableSubmitButton()
} else { } else {
disableSubmitButton() disableSubmitButton()
@@ -104,50 +104,58 @@ class MainActivity : AppCompatActivity() {
buttonAdd100.setOnClickListener { buttonAdd100.setOnClickListener {
if (inputTeamA.isFocused) { if (inputTeamA.isFocused) {
val temp = try { currentRound.scoreA = try {
inputTeamA.text.toString().toInt() + 100 inputTeamA.text.toString().toInt() + 100
} catch (e: Exception) { } catch (e: Exception) {
inputTeamB.setText(0.toString()) currentRound.scoreB = 0
inputTeamB.setText(currentRound.scoreB.toString())
100 100
} }
updateOnChange = false updateOnChange = false
inputTeamA.setText(temp.toString()) inputTeamA.setText(currentRound.scoreA.toString())
} }
if (inputTeamB.isFocused) { if (inputTeamB.isFocused) {
val temp = try { currentRound.scoreB = try {
inputTeamB.text.toString().toInt() + 100 inputTeamB.text.toString().toInt() + 100
} catch (e: Exception) { } catch (e: Exception) {
inputTeamA.setText(0.toString()) currentRound.scoreA = 0
inputTeamA.setText(currentRound.scoreA.toString())
100 100
} }
updateOnChange = false updateOnChange = false
inputTeamB.setText(temp.toString()) inputTeamB.setText(currentRound.scoreB.toString())
} }
} }
buttonSub100.setOnClickListener { buttonSub100.setOnClickListener {
if (inputTeamA.isFocused) { if (inputTeamA.isFocused) {
val temp = try { currentRound.scoreA = try {
inputTeamA.text.toString().toInt() - 100 inputTeamA.text.toString().toInt() - 100
} catch (e: Exception) { } catch (e: Exception) {
currentRound.scoreB = 0
inputTeamB.setText(currentRound.scoreB.toString())
-100 -100
} }
updateOnChange = false updateOnChange = false
inputTeamA.setText(temp.toString()) inputTeamA.setText(currentRound.scoreA.toString())
} }
if (inputTeamB.isFocused) { if (inputTeamB.isFocused) {
val temp = try { currentRound.scoreB = try {
inputTeamB.text.toString().toInt() - 100 inputTeamB.text.toString().toInt() - 100
} catch (e: Exception) { } catch (e: Exception) {
currentRound.scoreA = 0
inputTeamA.setText(currentRound.scoreA.toString())
-100 -100
} }
updateOnChange = false updateOnChange = false
inputTeamB.setText(temp.toString()) inputTeamB.setText(currentRound.scoreB.toString())
} }
} }
@@ -262,6 +270,7 @@ class MainActivity : AppCompatActivity() {
inputTeamA.text.clear() inputTeamA.text.clear()
inputTeamB.text.clear() inputTeamB.text.clear()
disableSubmitButton()
scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN) scrollViewHistory.fullScroll(ScrollView.FOCUS_DOWN)