handle SAF dialog when exporting to sd card
This commit is contained in:
parent
a7d65e5132
commit
5dff7a7140
|
@ -279,26 +279,28 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
||||||
private fun exportEvents() {
|
private fun exportEvents() {
|
||||||
FilePickerDialog(this, pickFile = false) {
|
FilePickerDialog(this, pickFile = false) {
|
||||||
val path = it
|
val path = it
|
||||||
ExportEventsDialog(this, path) {
|
handleSAFDialog(File(path)) {
|
||||||
Thread({
|
ExportEventsDialog(this, path) {
|
||||||
val events = dbHelper.getEventsToExport(it)
|
Thread({
|
||||||
if (events.isEmpty()) {
|
val events = dbHelper.getEventsToExport(it)
|
||||||
runOnUiThread {
|
if (events.isEmpty()) {
|
||||||
toast(R.string.no_events_for_exporting)
|
runOnUiThread {
|
||||||
|
toast(R.string.no_events_for_exporting)
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
val filename = "events_${System.currentTimeMillis() / 1000}.ics"
|
||||||
|
val file = File(path, filename)
|
||||||
|
val result = IcsExporter().exportEvents(this, file, events)
|
||||||
|
runOnUiThread {
|
||||||
|
toast(when (result) {
|
||||||
|
IcsExporter.ExportResult.EXPORT_OK -> R.string.events_exported_successfully
|
||||||
|
IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_events_failed
|
||||||
|
else -> R.string.exporting_events_failed
|
||||||
|
})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
} else {
|
}).start()
|
||||||
val filename = "events_${System.currentTimeMillis() / 1000}.ics"
|
}
|
||||||
val file = File(path, filename)
|
|
||||||
val result = IcsExporter().exportEvents(this, file, events)
|
|
||||||
runOnUiThread {
|
|
||||||
toast(when (result) {
|
|
||||||
IcsExporter.ExportResult.EXPORT_OK -> R.string.events_exported_successfully
|
|
||||||
IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_events_failed
|
|
||||||
else -> R.string.exporting_events_failed
|
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}).start()
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue