mirror of
https://github.com/SimpleMobileTools/Simple-Calendar.git
synced 2025-02-17 04:10:45 +01:00
reordering some functions
This commit is contained in:
parent
9f0dc9ae29
commit
69efa73902
@ -101,6 +101,25 @@ class EventActivity : SimpleActivity() {
|
|||||||
wasActivityInitialized = true
|
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() {
|
private fun setupEditEvent() {
|
||||||
val realStart = if (mEventOccurrenceTS == 0) mEvent.startTS else mEventOccurrenceTS
|
val realStart = if (mEventOccurrenceTS == 0) mEvent.startTS else mEventOccurrenceTS
|
||||||
val duration = mEvent.endTS - mEvent.startTS
|
val duration = mEvent.endTS - mEvent.startTS
|
||||||
@ -482,25 +501,6 @@ class EventActivity : SimpleActivity() {
|
|||||||
event_end_time.beGoneIf(isChecked)
|
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() {
|
private fun shareEvent() {
|
||||||
shareEvents(arrayListOf(mEvent.id))
|
shareEvents(arrayListOf(mEvent.id))
|
||||||
}
|
}
|
||||||
|
@ -477,13 +477,13 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
|
|
||||||
private fun importEvents() {
|
private fun importEvents() {
|
||||||
FilePickerDialog(this) {
|
FilePickerDialog(this) {
|
||||||
importEventsDialog(it)
|
showImportEventsDialog(it)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun tryImportEventsFromFile(uri: Uri) {
|
private fun tryImportEventsFromFile(uri: Uri) {
|
||||||
when {
|
when {
|
||||||
uri.scheme == "file" -> importEventsDialog(uri.path)
|
uri.scheme == "file" -> showImportEventsDialog(uri.path)
|
||||||
uri.scheme == "content" -> {
|
uri.scheme == "content" -> {
|
||||||
val tempFile = getTempFile()
|
val tempFile = getTempFile()
|
||||||
if (tempFile == null) {
|
if (tempFile == null) {
|
||||||
@ -494,13 +494,13 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
|||||||
val inputStream = contentResolver.openInputStream(uri)
|
val inputStream = contentResolver.openInputStream(uri)
|
||||||
val out = FileOutputStream(tempFile)
|
val out = FileOutputStream(tempFile)
|
||||||
inputStream.copyTo(out)
|
inputStream.copyTo(out)
|
||||||
importEventsDialog(tempFile.absolutePath)
|
showImportEventsDialog(tempFile.absolutePath)
|
||||||
}
|
}
|
||||||
else -> toast(R.string.invalid_file_format)
|
else -> toast(R.string.invalid_file_format)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun importEventsDialog(path: String) {
|
private fun showImportEventsDialog(path: String) {
|
||||||
ImportEventsDialog(this, path) {
|
ImportEventsDialog(this, path) {
|
||||||
if (it) {
|
if (it) {
|
||||||
runOnUiThread {
|
runOnUiThread {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user