Give focus to input A if none is selected.
This commit is contained in:
@@ -145,48 +145,59 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
button0.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('0')
|
||||
}
|
||||
|
||||
button1.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('1')
|
||||
}
|
||||
|
||||
button2.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('2')
|
||||
}
|
||||
|
||||
button3.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('3')
|
||||
}
|
||||
|
||||
button4.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('4')
|
||||
}
|
||||
|
||||
button5.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('5')
|
||||
}
|
||||
|
||||
button6.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('6')
|
||||
}
|
||||
|
||||
button7.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('7')
|
||||
}
|
||||
|
||||
button8.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('8')
|
||||
}
|
||||
|
||||
button9.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
appendToFocusedInput('9')
|
||||
}
|
||||
|
||||
buttonInv.setOnClickListener {
|
||||
val tempInt: Int
|
||||
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if(inputTeamA.isFocused ){
|
||||
if (inputTeamA.text.isNotEmpty()){
|
||||
@@ -209,15 +220,17 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
buttonBack.setOnClickListener{
|
||||
if(inputTeamA.isFocused ){
|
||||
if(inputTeamA.text.isNotEmpty()){
|
||||
buttonBack.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.isFocused) {
|
||||
if (inputTeamA.text.isNotEmpty()) {
|
||||
val string = inputTeamA.text.toString()
|
||||
inputTeamA.setText(string.substring(0, string.length -1))
|
||||
inputTeamA.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
|
||||
}else if(inputTeamB.isFocused) {
|
||||
if(inputTeamB.text.isNotEmpty()) {
|
||||
} else if (inputTeamB.isFocused) {
|
||||
if (inputTeamB.text.isNotEmpty()) {
|
||||
val string = inputTeamB.text.toString()
|
||||
inputTeamB.setText(string.substring(0, string.length - 1))
|
||||
}
|
||||
@@ -225,6 +238,7 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
|
||||
submit.setOnClickListener {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||
|
||||
@@ -260,7 +274,7 @@ class MainActivity : AppCompatActivity() {
|
||||
clearAll()
|
||||
true
|
||||
}
|
||||
R.id.action_undo -> {
|
||||
R.id.action_undo -> {
|
||||
undoLastRound()
|
||||
true
|
||||
}
|
||||
@@ -272,7 +286,13 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
}
|
||||
|
||||
private fun undoLastRound(){
|
||||
private fun giveFocusToAIfNone() {
|
||||
if (!inputTeamA.isFocused && !inputTeamB.isFocused) {
|
||||
inputTeamA.requestFocus()
|
||||
}
|
||||
}
|
||||
|
||||
private fun undoLastRound() {
|
||||
|
||||
history.revertLastRound()
|
||||
updateView()
|
||||
|
||||
Reference in New Issue
Block a user