Reformat Code
This commit is contained in:
@@ -54,18 +54,18 @@ class MainActivity : AppCompatActivity() {
|
||||
Round(0, 0)
|
||||
}
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
}else{
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
}else{
|
||||
} else {
|
||||
inputTeamA.text.clear()
|
||||
inputTeamB.text.clear()
|
||||
}
|
||||
}
|
||||
|
||||
if(currentRound.isValidRound()){
|
||||
if (currentRound.isValidRound()) {
|
||||
enableSubmitButton()
|
||||
}else{
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
@@ -74,29 +74,29 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
inputTeamB.doOnTextChanged { text, start, count, after ->
|
||||
if (inputTeamB.isFocused) {
|
||||
if (inputTeamB.text.isNotEmpty()){
|
||||
if(updateOnChange){
|
||||
if (inputTeamB.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), false)
|
||||
|
||||
} catch (e: java.lang.Exception){
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(0, 0)
|
||||
}
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
|
||||
}else{
|
||||
} else {
|
||||
updateOnChange = true
|
||||
}
|
||||
|
||||
}else{
|
||||
} else {
|
||||
inputTeamA.text.clear()
|
||||
inputTeamB.text.clear()
|
||||
}
|
||||
}
|
||||
|
||||
if(currentRound.isValidRound()){
|
||||
if (currentRound.isValidRound()) {
|
||||
enableSubmitButton()
|
||||
}else{
|
||||
} else {
|
||||
disableSubmitButton()
|
||||
}
|
||||
}
|
||||
@@ -206,21 +206,21 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if(inputTeamA.isFocused ){
|
||||
if (inputTeamA.text.isNotEmpty()){
|
||||
if (inputTeamA.isFocused) {
|
||||
if (inputTeamA.text.isNotEmpty()) {
|
||||
tempInt = inputTeamA.text.toString().toInt() * -1
|
||||
inputTeamA.setText(tempInt.toString())
|
||||
}else{
|
||||
} else {
|
||||
invertB = false
|
||||
invertA = true
|
||||
}
|
||||
|
||||
|
||||
}else if(inputTeamB.isFocused) {
|
||||
if(inputTeamB.text.isNotEmpty()){
|
||||
} else if (inputTeamB.isFocused) {
|
||||
if (inputTeamB.text.isNotEmpty()) {
|
||||
tempInt = inputTeamB.text.toString().toInt() * -1
|
||||
inputTeamB.setText(tempInt.toString())
|
||||
} else{
|
||||
} else {
|
||||
invertA = false
|
||||
invertB = true
|
||||
}
|
||||
@@ -249,7 +249,12 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
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()
|
||||
@@ -283,7 +288,19 @@ class MainActivity : AppCompatActivity() {
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_clear -> {
|
||||
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
|
||||
}
|
||||
R.id.action_undo -> {
|
||||
@@ -335,17 +352,16 @@ class MainActivity : AppCompatActivity() {
|
||||
history.clearAll()
|
||||
}
|
||||
|
||||
private fun appendToFocusedInput(toAppend: Char){
|
||||
if(inputTeamA.isFocused){
|
||||
if(invertA){
|
||||
private fun appendToFocusedInput(toAppend: Char) {
|
||||
if (inputTeamA.isFocused) {
|
||||
if (invertA) {
|
||||
invertA = false
|
||||
inputTeamA.text.append('-')
|
||||
}
|
||||
|
||||
inputTeamA.text.append(toAppend)
|
||||
}else if(inputTeamB.isFocused)
|
||||
{
|
||||
if(invertB){
|
||||
} else if (inputTeamB.isFocused) {
|
||||
if (invertB) {
|
||||
invertB = false
|
||||
inputTeamB.text.append('-')
|
||||
}
|
||||
@@ -360,7 +376,7 @@ class MainActivity : AppCompatActivity() {
|
||||
submit.isEnabled = true
|
||||
}
|
||||
|
||||
private fun disableSubmitButton(){
|
||||
private fun disableSubmitButton() {
|
||||
submit.imageAlpha = 60 // 0 being transparent and 255 being opaque
|
||||
submit.isEnabled = false
|
||||
}
|
||||
@@ -369,7 +385,7 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
val builder = AlertDialog.Builder(this)
|
||||
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)
|
||||
|
||||
|
||||
@@ -2,7 +2,7 @@ package me.zobrist.tichucounter
|
||||
|
||||
import java.io.Serializable
|
||||
|
||||
class Round(): Serializable {
|
||||
class Round() : Serializable {
|
||||
var scoreA: Int = 0
|
||||
var scoreB: Int = 0
|
||||
|
||||
|
||||
Reference in New Issue
Block a user