From 69efa739026b87b65c4851e848e71b21647a59cc Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 15 Jan 2018 23:27:34 +0100 Subject: [PATCH] reordering some functions --- .../calendar/activities/EventActivity.kt | 38 +++++++++---------- .../calendar/activities/MainActivity.kt | 8 ++-- 2 files changed, 23 insertions(+), 23 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 1be33b601..4090758c0 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/EventActivity.kt @@ -101,6 +101,25 @@ class EventActivity : SimpleActivity() { wasActivityInitialized = true } + override fun onCreateOptionsMenu(menu: Menu): Boolean { + menuInflater.inflate(R.menu.menu_event, menu) + if (wasActivityInitialized) { + menu.findItem(R.id.delete).isVisible = mEvent.id != 0 + menu.findItem(R.id.share).isVisible = mEvent.id != 0 + } + return true + } + + override fun onOptionsItemSelected(item: MenuItem): Boolean { + when (item.itemId) { + R.id.save -> saveEvent() + R.id.delete -> deleteEvent() + R.id.share -> shareEvent() + else -> return super.onOptionsItemSelected(item) + } + return true + } + private fun setupEditEvent() { val realStart = if (mEventOccurrenceTS == 0) mEvent.startTS else mEventOccurrenceTS val duration = mEvent.endTS - mEvent.startTS @@ -482,25 +501,6 @@ class EventActivity : SimpleActivity() { event_end_time.beGoneIf(isChecked) } - override fun onCreateOptionsMenu(menu: Menu): Boolean { - menuInflater.inflate(R.menu.menu_event, menu) - if (wasActivityInitialized) { - menu.findItem(R.id.delete).isVisible = mEvent.id != 0 - menu.findItem(R.id.share).isVisible = mEvent.id != 0 - } - return true - } - - override fun onOptionsItemSelected(item: MenuItem): Boolean { - when (item.itemId) { - R.id.save -> saveEvent() - R.id.delete -> deleteEvent() - R.id.share -> shareEvent() - else -> return super.onOptionsItemSelected(item) - } - return true - } - private fun shareEvent() { shareEvents(arrayListOf(mEvent.id)) } 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 943445d12..a17f46093 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -477,13 +477,13 @@ class MainActivity : SimpleActivity(), NavigationListener { private fun importEvents() { FilePickerDialog(this) { - importEventsDialog(it) + showImportEventsDialog(it) } } private fun tryImportEventsFromFile(uri: Uri) { when { - uri.scheme == "file" -> importEventsDialog(uri.path) + uri.scheme == "file" -> showImportEventsDialog(uri.path) uri.scheme == "content" -> { val tempFile = getTempFile() if (tempFile == null) { @@ -494,13 +494,13 @@ class MainActivity : SimpleActivity(), NavigationListener { val inputStream = contentResolver.openInputStream(uri) val out = FileOutputStream(tempFile) inputStream.copyTo(out) - importEventsDialog(tempFile.absolutePath) + showImportEventsDialog(tempFile.absolutePath) } else -> toast(R.string.invalid_file_format) } } - private fun importEventsDialog(path: String) { + private fun showImportEventsDialog(path: String) { ImportEventsDialog(this, path) { if (it) { runOnUiThread {