reordering some functions

This commit is contained in:
tibbi 2018-01-15 23:27:34 +01:00
parent 9f0dc9ae29
commit 69efa73902
2 changed files with 23 additions and 23 deletions

View File

@ -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))
}

View File

@ -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 {