reordering some functions
This commit is contained in:
parent
9f0dc9ae29
commit
69efa73902
|
@ -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))
|
||||
}
|
||||
|
|
|
@ -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 {
|
||||
|
|
Loading…
Reference in New Issue