Reformat Code
This commit is contained in:
@@ -54,18 +54,18 @@ class MainActivity : AppCompatActivity() {
|
|||||||
Round(0, 0)
|
Round(0, 0)
|
||||||
}
|
}
|
||||||
inputTeamB.setText(currentRound.scoreB.toString())
|
inputTeamB.setText(currentRound.scoreB.toString())
|
||||||
}else{
|
} else {
|
||||||
updateOnChange = true
|
updateOnChange = true
|
||||||
}
|
}
|
||||||
}else{
|
} else {
|
||||||
inputTeamA.text.clear()
|
inputTeamA.text.clear()
|
||||||
inputTeamB.text.clear()
|
inputTeamB.text.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentRound.isValidRound()){
|
if (currentRound.isValidRound()) {
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
}else{
|
} else {
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -74,29 +74,29 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
inputTeamB.doOnTextChanged { text, start, count, after ->
|
inputTeamB.doOnTextChanged { text, start, count, after ->
|
||||||
if (inputTeamB.isFocused) {
|
if (inputTeamB.isFocused) {
|
||||||
if (inputTeamB.text.isNotEmpty()){
|
if (inputTeamB.text.isNotEmpty()) {
|
||||||
if(updateOnChange){
|
if (updateOnChange) {
|
||||||
currentRound = try {
|
currentRound = try {
|
||||||
Round(text.toString().toInt(), false)
|
Round(text.toString().toInt(), false)
|
||||||
|
|
||||||
} catch (e: java.lang.Exception){
|
} catch (e: java.lang.Exception) {
|
||||||
Round(0, 0)
|
Round(0, 0)
|
||||||
}
|
}
|
||||||
inputTeamA.setText(currentRound.scoreA.toString())
|
inputTeamA.setText(currentRound.scoreA.toString())
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
updateOnChange = true
|
updateOnChange = true
|
||||||
}
|
}
|
||||||
|
|
||||||
}else{
|
} else {
|
||||||
inputTeamA.text.clear()
|
inputTeamA.text.clear()
|
||||||
inputTeamB.text.clear()
|
inputTeamB.text.clear()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if(currentRound.isValidRound()){
|
if (currentRound.isValidRound()) {
|
||||||
enableSubmitButton()
|
enableSubmitButton()
|
||||||
}else{
|
} else {
|
||||||
disableSubmitButton()
|
disableSubmitButton()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -206,21 +206,21 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
giveFocusToAIfNone()
|
giveFocusToAIfNone()
|
||||||
|
|
||||||
if(inputTeamA.isFocused ){
|
if (inputTeamA.isFocused) {
|
||||||
if (inputTeamA.text.isNotEmpty()){
|
if (inputTeamA.text.isNotEmpty()) {
|
||||||
tempInt = inputTeamA.text.toString().toInt() * -1
|
tempInt = inputTeamA.text.toString().toInt() * -1
|
||||||
inputTeamA.setText(tempInt.toString())
|
inputTeamA.setText(tempInt.toString())
|
||||||
}else{
|
} else {
|
||||||
invertB = false
|
invertB = false
|
||||||
invertA = true
|
invertA = true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}else if(inputTeamB.isFocused) {
|
} else if (inputTeamB.isFocused) {
|
||||||
if(inputTeamB.text.isNotEmpty()){
|
if (inputTeamB.text.isNotEmpty()) {
|
||||||
tempInt = inputTeamB.text.toString().toInt() * -1
|
tempInt = inputTeamB.text.toString().toInt() * -1
|
||||||
inputTeamB.setText(tempInt.toString())
|
inputTeamB.setText(tempInt.toString())
|
||||||
} else{
|
} else {
|
||||||
invertA = false
|
invertA = false
|
||||||
invertB = true
|
invertB = true
|
||||||
}
|
}
|
||||||
@@ -249,7 +249,12 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
if (inputTeamA.text.isNotEmpty() && inputTeamB.text.isNotEmpty()) {
|
||||||
|
|
||||||
history.logRound(Round(inputTeamA.text.toString().toInt(), inputTeamB.text.toString().toInt()))
|
history.logRound(
|
||||||
|
Round(
|
||||||
|
inputTeamA.text.toString().toInt(),
|
||||||
|
inputTeamB.text.toString().toInt()
|
||||||
|
)
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
updateView()
|
updateView()
|
||||||
@@ -283,7 +288,19 @@ class MainActivity : AppCompatActivity() {
|
|||||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||||
return when (item.itemId) {
|
return when (item.itemId) {
|
||||||
R.id.action_clear -> {
|
R.id.action_clear -> {
|
||||||
clearAll()
|
val builder = AlertDialog.Builder(this)
|
||||||
|
builder.setMessage(getString(R.string.confirmClear))
|
||||||
|
.setTitle(R.string.clear)
|
||||||
|
.setCancelable(false)
|
||||||
|
.setPositiveButton(getString(R.string.yes)) { dialog, id ->
|
||||||
|
dialog.dismiss()
|
||||||
|
clearAll()
|
||||||
|
}
|
||||||
|
.setNegativeButton(getString(R.string.no)) { dialog, id ->
|
||||||
|
dialog.cancel()
|
||||||
|
}
|
||||||
|
|
||||||
|
builder.create().show()
|
||||||
true
|
true
|
||||||
}
|
}
|
||||||
R.id.action_undo -> {
|
R.id.action_undo -> {
|
||||||
@@ -335,17 +352,16 @@ class MainActivity : AppCompatActivity() {
|
|||||||
history.clearAll()
|
history.clearAll()
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun appendToFocusedInput(toAppend: Char){
|
private fun appendToFocusedInput(toAppend: Char) {
|
||||||
if(inputTeamA.isFocused){
|
if (inputTeamA.isFocused) {
|
||||||
if(invertA){
|
if (invertA) {
|
||||||
invertA = false
|
invertA = false
|
||||||
inputTeamA.text.append('-')
|
inputTeamA.text.append('-')
|
||||||
}
|
}
|
||||||
|
|
||||||
inputTeamA.text.append(toAppend)
|
inputTeamA.text.append(toAppend)
|
||||||
}else if(inputTeamB.isFocused)
|
} else if (inputTeamB.isFocused) {
|
||||||
{
|
if (invertB) {
|
||||||
if(invertB){
|
|
||||||
invertB = false
|
invertB = false
|
||||||
inputTeamB.text.append('-')
|
inputTeamB.text.append('-')
|
||||||
}
|
}
|
||||||
@@ -360,7 +376,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
submit.isEnabled = true
|
submit.isEnabled = true
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun disableSubmitButton(){
|
private fun disableSubmitButton() {
|
||||||
submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
||||||
submit.isEnabled = false
|
submit.isEnabled = false
|
||||||
}
|
}
|
||||||
@@ -369,7 +385,7 @@ class MainActivity : AppCompatActivity() {
|
|||||||
|
|
||||||
val builder = AlertDialog.Builder(this)
|
val builder = AlertDialog.Builder(this)
|
||||||
builder.setTitle(getString(R.string.choose_theme_text))
|
builder.setTitle(getString(R.string.choose_theme_text))
|
||||||
val styles = arrayOf("Light","Dark","System default")
|
val styles = arrayOf("Light", "Dark", "System default")
|
||||||
|
|
||||||
val checkedItem = this.getSharedPreferences("", Context.MODE_PRIVATE).getInt("Theme", 2)
|
val checkedItem = this.getSharedPreferences("", Context.MODE_PRIVATE).getInt("Theme", 2)
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package me.zobrist.tichucounter
|
|||||||
|
|
||||||
import java.io.Serializable
|
import java.io.Serializable
|
||||||
|
|
||||||
class Round(): Serializable {
|
class Round() : Serializable {
|
||||||
var scoreA: Int = 0
|
var scoreA: Int = 0
|
||||||
var scoreB: Int = 0
|
var scoreB: Int = 0
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user