From 5e08224f43a310248be8a3cedb28f4c20a96fd7c Mon Sep 17 00:00:00 2001 From: tibbi Date: Thu, 29 Dec 2016 22:41:08 +0100 Subject: [PATCH] shorten some switch cases --- .../calendar/activities/EventActivity.kt | 15 +++++--------- .../calendar/activities/MainActivity.kt | 20 ++++++------------- 2 files changed, 11 insertions(+), 24 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt index 3f0a78cce..993cff923 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -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() { diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index 64efae90e..33f2b8d54 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -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() {