Show negative sign if entered first.
This commit is contained in:
@@ -16,9 +16,6 @@ import kotlinx.android.synthetic.main.content_main.*
|
||||
|
||||
class MainActivity : AppCompatActivity() {
|
||||
|
||||
private var invertA: Boolean = false
|
||||
private var invertB: Boolean = false
|
||||
|
||||
private var updateOnChange: Boolean = true
|
||||
|
||||
private lateinit var history: History
|
||||
@@ -64,7 +61,7 @@ class MainActivity : AppCompatActivity() {
|
||||
Round(text.toString().toInt(), true)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(0, 0)
|
||||
Round(1, 1)
|
||||
}
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
} else {
|
||||
@@ -93,7 +90,7 @@ class MainActivity : AppCompatActivity() {
|
||||
Round(text.toString().toInt(), false)
|
||||
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(0, 0)
|
||||
Round(1, 1)
|
||||
}
|
||||
inputTeamA.setText(currentRound.scoreA.toString())
|
||||
|
||||
@@ -229,22 +226,26 @@ class MainActivity : AppCompatActivity() {
|
||||
giveFocusToAIfNone()
|
||||
|
||||
if (inputTeamA.isFocused) {
|
||||
if (inputTeamA.text.isNotEmpty()) {
|
||||
if (inputTeamA.text.toString().equals("-")) {
|
||||
inputTeamA.text.clear()
|
||||
} else if (inputTeamA.text.isNotEmpty()) {
|
||||
tempInt = inputTeamA.text.toString().toInt() * -1
|
||||
inputTeamA.setText(tempInt.toString())
|
||||
} else {
|
||||
invertB = false
|
||||
invertA = true
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
}
|
||||
|
||||
|
||||
} else if (inputTeamB.isFocused) {
|
||||
if (inputTeamB.text.isNotEmpty()) {
|
||||
if (inputTeamB.text.toString().equals("-")) {
|
||||
inputTeamB.text.clear()
|
||||
} else if (inputTeamB.text.isNotEmpty()) {
|
||||
tempInt = inputTeamB.text.toString().toInt() * -1
|
||||
inputTeamB.setText(tempInt.toString())
|
||||
} else {
|
||||
invertA = false
|
||||
invertB = true
|
||||
updateOnChange = false
|
||||
appendToFocusedInput('-')
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -378,17 +379,8 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
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) {
|
||||
invertB = false
|
||||
inputTeamB.text.append('-')
|
||||
}
|
||||
inputTeamB.text.append(toAppend)
|
||||
}
|
||||
}
|
||||
@@ -409,7 +401,8 @@ class MainActivity : AppCompatActivity() {
|
||||
builder.setTitle(getString(R.string.choose_theme_text))
|
||||
val styles = arrayOf("Light", "Dark", "System default")
|
||||
|
||||
val checkedItem = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2)
|
||||
val checkedItem =
|
||||
this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2)
|
||||
|
||||
val prefs = this.getSharedPreferences("Settings", Context.MODE_PRIVATE).edit()
|
||||
|
||||
|
||||
Reference in New Issue
Block a user