- Add clear entry in menu
- clean string.xml file -
This commit is contained in:
@@ -3,6 +3,7 @@ package me.zobrist.tichucounter
|
||||
import android.os.Bundle
|
||||
import androidx.appcompat.app.AppCompatActivity
|
||||
import android.view.Menu
|
||||
import android.view.MenuItem
|
||||
import androidx.core.widget.doOnTextChanged
|
||||
import kotlinx.android.synthetic.main.content_main.*
|
||||
import kotlinx.coroutines.sync.Mutex
|
||||
@@ -60,8 +61,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
inputTeamB.setText(temp.toString())
|
||||
}
|
||||
|
||||
updateTemp()
|
||||
}
|
||||
|
||||
sub100.setOnClickListener {
|
||||
@@ -85,8 +84,6 @@ class MainActivity : AppCompatActivity() {
|
||||
}
|
||||
inputTeamB.setText(temp.toString())
|
||||
}
|
||||
|
||||
updateTemp()
|
||||
}
|
||||
|
||||
add.setOnClickListener {
|
||||
@@ -107,7 +104,6 @@ class MainActivity : AppCompatActivity() {
|
||||
inputTeamA.setText("")
|
||||
inputTeamB.setText("")
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -117,6 +113,26 @@ class MainActivity : AppCompatActivity() {
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.action_clear -> {
|
||||
clearAll()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
}
|
||||
}
|
||||
|
||||
private fun clearAll() {
|
||||
historyA.text = ""
|
||||
historyB.text = ""
|
||||
inputTeamA.setText("")
|
||||
inputTeamB.setText("")
|
||||
scoreA.text = "50"
|
||||
scoreB.text = ""
|
||||
}
|
||||
|
||||
|
||||
private fun updateNumber(inputText: CharSequence?, offset: Int): String {
|
||||
var toSet: Int = 0
|
||||
|
||||
@@ -131,11 +147,4 @@ class MainActivity : AppCompatActivity() {
|
||||
|
||||
return "$toSet"
|
||||
}
|
||||
|
||||
private fun updateTemp() {
|
||||
nameTeamA.text = tempCounterTeamA.toString()
|
||||
nameTeamB.text = tempCounterTeamB.toString()
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user