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