do the file exporting on a background thread

This commit is contained in:
tibbi
2017-04-03 19:38:41 +02:00
parent 98aedf7bb3
commit d9f7707d3f
2 changed files with 13 additions and 9 deletions

View File

@@ -126,7 +126,7 @@ class MainActivity : SimpleActivity(), NavigationListener {
R.id.go_to_today -> goToToday() R.id.go_to_today -> goToToday()
R.id.filter -> showFilterDialog() R.id.filter -> showFilterDialog()
R.id.import_events -> tryImportEvents() R.id.import_events -> tryImportEvents()
// R.id.export_events -> tryExportEvents() R.id.export_events -> tryExportEvents()
R.id.export_raw -> tryExportRaw() R.id.export_raw -> tryExportRaw()
R.id.settings -> launchSettings() R.id.settings -> launchSettings()
R.id.about -> launchAbout() R.id.about -> launchAbout()
@@ -262,12 +262,16 @@ class MainActivity : SimpleActivity(), NavigationListener {
FilePickerDialog(this, pickFile = false) { FilePickerDialog(this, pickFile = false) {
val path = it val path = it
ExportEventsDialog(this, path) { ExportEventsDialog(this, path) {
val result = IcsExporter().exportEvents(this, path) Thread({
toast(when (result) { val result = IcsExporter().exportEvents(this, path)
IcsExporter.ExportResult.EXPORT_OK -> R.string.events_exported_successfully runOnUiThread {
IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_events_failed toast(when (result) {
else -> R.string.exporting_events_failed 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()
} }
} }
} }

View File

@@ -20,10 +20,10 @@
android:id="@+id/import_events" android:id="@+id/import_events"
android:title="@string/import_events_from_ics" android:title="@string/import_events_from_ics"
app:showAsAction="never"/> app:showAsAction="never"/>
<!--<item <item
android:id="@+id/export_events" android:id="@+id/export_events"
android:title="@string/export_events_to_ics" android:title="@string/export_events_to_ics"
app:showAsAction="never"/>--> app:showAsAction="never"/>
<item <item
android:id="@+id/export_raw" android:id="@+id/export_raw"
android:title="@string/export_raw_database" android:title="@string/export_raw_database"