shorten some switch cases
This commit is contained in:
parent
27ec78ad18
commit
5e08224f43
2 changed files with 11 additions and 24 deletions
|
@ -210,17 +210,12 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
|
|||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.cab_delete -> {
|
||||
deleteEvent()
|
||||
true
|
||||
}
|
||||
R.id.save -> {
|
||||
saveEvent()
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
when (item.itemId) {
|
||||
R.id.cab_delete -> deleteEvent()
|
||||
R.id.save -> saveEvent()
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
private fun deleteEvent() {
|
||||
|
|
|
@ -58,21 +58,13 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
|
|||
}
|
||||
|
||||
override fun onOptionsItemSelected(item: MenuItem): Boolean {
|
||||
return when (item.itemId) {
|
||||
R.id.change_view -> {
|
||||
showViewDialog()
|
||||
true
|
||||
}
|
||||
R.id.settings -> {
|
||||
startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
true
|
||||
}
|
||||
R.id.about -> {
|
||||
startActivity(Intent(applicationContext, AboutActivity::class.java))
|
||||
true
|
||||
}
|
||||
else -> super.onOptionsItemSelected(item)
|
||||
when (item.itemId) {
|
||||
R.id.change_view -> showViewDialog()
|
||||
R.id.settings -> startActivity(Intent(applicationContext, SettingsActivity::class.java))
|
||||
R.id.about -> startActivity(Intent(applicationContext, AboutActivity::class.java))
|
||||
else -> return super.onOptionsItemSelected(item)
|
||||
}
|
||||
return true
|
||||
}
|
||||
|
||||
override fun onBackPressed() {
|
||||
|
|
Loading…
Reference in a new issue