shorten some switch cases

This commit is contained in:
tibbi 2016-12-29 22:41:08 +01:00
parent 27ec78ad18
commit 5e08224f43
2 changed files with 11 additions and 24 deletions

View File

@ -210,17 +210,12 @@ class EventActivity : SimpleActivity(), DBHelper.EventUpdateListener {
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { when (item.itemId) {
R.id.cab_delete -> { R.id.cab_delete -> deleteEvent()
deleteEvent() R.id.save -> saveEvent()
true else -> return super.onOptionsItemSelected(item)
}
R.id.save -> {
saveEvent()
true
}
else -> super.onOptionsItemSelected(item)
} }
return true
} }
private fun deleteEvent() { private fun deleteEvent() {

View File

@ -58,21 +58,13 @@ class MainActivity : SimpleActivity(), EventListFragment.DeleteListener {
} }
override fun onOptionsItemSelected(item: MenuItem): Boolean { override fun onOptionsItemSelected(item: MenuItem): Boolean {
return when (item.itemId) { when (item.itemId) {
R.id.change_view -> { R.id.change_view -> showViewDialog()
showViewDialog() R.id.settings -> startActivity(Intent(applicationContext, SettingsActivity::class.java))
true R.id.about -> startActivity(Intent(applicationContext, AboutActivity::class.java))
} else -> return super.onOptionsItemSelected(item)
R.id.settings -> {
startActivity(Intent(applicationContext, SettingsActivity::class.java))
true
}
R.id.about -> {
startActivity(Intent(applicationContext, AboutActivity::class.java))
true
}
else -> super.onOptionsItemSelected(item)
} }
return true
} }
override fun onBackPressed() { override fun onBackPressed() {