- fix loading history form savedInstance.
- fix add or sub 100 does not update other score
This commit is contained in:
@@ -19,12 +19,11 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
private var updateOnChange: Boolean = true
|
||||
|
||||
private var history = History()
|
||||
private lateinit var history: History
|
||||
private var currentRound = Round()
|
||||
|
||||
override fun onCreate(savedInstanceState: Bundle?) {
|
||||
super.onCreate(savedInstanceState)
|
||||
history = savedInstanceState?.getParcelable("history")!!
|
||||
setContentView(R.layout.activity_main)
|
||||
setSupportActionBar(findViewById(R.id.toolbar))
|
||||
inputTeamA.setRawInputType(InputType.TYPE_NULL)
|
||||
@@ -33,15 +32,18 @@ class MainActivity : AppCompatActivity() {
|
||||
disableSubmitButton()
|
||||
updateTheme(this.getSharedPreferences("Settings", Context.MODE_PRIVATE).getInt("Theme", 2))
|
||||
|
||||
history = savedInstanceState?.getParcelable("history") ?: History()
|
||||
updateView()
|
||||
|
||||
|
||||
inputTeamA.doOnTextChanged { text, start, count, after ->
|
||||
if (inputTeamA.isFocused) {
|
||||
if (inputTeamA.text.isNotEmpty()){
|
||||
if(updateOnChange){
|
||||
if (inputTeamA.text.isNotEmpty()) {
|
||||
if (updateOnChange) {
|
||||
currentRound = try {
|
||||
Round(text.toString().toInt(), true)
|
||||
|
||||
} catch (e: java.lang.Exception){
|
||||
} catch (e: java.lang.Exception) {
|
||||
Round(0, 0)
|
||||
}
|
||||
inputTeamB.setText(currentRound.scoreB.toString())
|
||||
@@ -98,7 +100,9 @@ class MainActivity : AppCompatActivity() {
|
||||
val temp = try {
|
||||
inputTeamA.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
inputTeamB.setText(0.toString())
|
||||
100
|
||||
|
||||
}
|
||||
updateOnChange = false
|
||||
inputTeamA.setText(temp.toString())
|
||||
@@ -108,7 +112,9 @@ class MainActivity : AppCompatActivity() {
|
||||
val temp = try {
|
||||
inputTeamB.text.toString().toInt() + 100
|
||||
} catch (e: Exception) {
|
||||
inputTeamA.setText(0.toString())
|
||||
100
|
||||
|
||||
}
|
||||
updateOnChange = false
|
||||
inputTeamB.setText(temp.toString())
|
||||
|
||||
Reference in New Issue
Block a user