removing some explicit calls to runOnUiThread at toasts
This commit is contained in:
parent
1db93656a3
commit
c78da7f9fb
3 changed files with 21 additions and 31 deletions
|
@ -222,13 +222,11 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleParseResult(result: IcsImporter.ImportResult) {
|
private fun handleParseResult(result: IcsImporter.ImportResult) {
|
||||||
runOnUiThread {
|
toast(when (result) {
|
||||||
toast(when (result) {
|
IcsImporter.ImportResult.IMPORT_OK -> R.string.holidays_imported_successfully
|
||||||
IcsImporter.ImportResult.IMPORT_OK -> R.string.holidays_imported_successfully
|
IcsImporter.ImportResult.IMPORT_PARTIAL -> R.string.importing_some_holidays_failed
|
||||||
IcsImporter.ImportResult.IMPORT_PARTIAL -> R.string.importing_some_holidays_failed
|
else -> R.string.importing_holidays_failed
|
||||||
else -> R.string.importing_holidays_failed
|
}, Toast.LENGTH_LONG)
|
||||||
}, Toast.LENGTH_LONG)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun updateView(view: Int) {
|
private fun updateView(view: Int) {
|
||||||
|
@ -326,21 +324,15 @@ class MainActivity : SimpleActivity(), NavigationListener {
|
||||||
Thread({
|
Thread({
|
||||||
val events = dbHelper.getEventsToExport(exportPastEvents).filter { eventTypes.contains(it.eventType.toString()) }
|
val events = dbHelper.getEventsToExport(exportPastEvents).filter { eventTypes.contains(it.eventType.toString()) }
|
||||||
if (events.isEmpty()) {
|
if (events.isEmpty()) {
|
||||||
runOnUiThread {
|
toast(R.string.no_events_for_exporting)
|
||||||
toast(R.string.no_events_for_exporting)
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
runOnUiThread {
|
toast(R.string.exporting)
|
||||||
toast(R.string.exporting)
|
|
||||||
}
|
|
||||||
IcsExporter().exportEvents(this, file, events as ArrayList<Event>) {
|
IcsExporter().exportEvents(this, file, events as ArrayList<Event>) {
|
||||||
runOnUiThread {
|
toast(when (it) {
|
||||||
toast(when (it) {
|
IcsExporter.ExportResult.EXPORT_OK -> R.string.events_exported_successfully
|
||||||
IcsExporter.ExportResult.EXPORT_OK -> R.string.events_exported_successfully
|
IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_events_failed
|
||||||
IcsExporter.ExportResult.EXPORT_PARTIAL -> R.string.exporting_some_events_failed
|
else -> R.string.exporting_events_failed
|
||||||
else -> R.string.exporting_events_failed
|
})
|
||||||
})
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}).start()
|
}).start()
|
||||||
|
|
|
@ -42,11 +42,11 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val cal
|
||||||
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
getButton(AlertDialog.BUTTON_POSITIVE).setOnClickListener({
|
||||||
val filename = view.export_events_filename.value
|
val filename = view.export_events_filename.value
|
||||||
if (filename.isEmpty()) {
|
if (filename.isEmpty()) {
|
||||||
context.toast(R.string.empty_name)
|
activity.toast(R.string.empty_name)
|
||||||
} else if (filename.isAValidFilename()) {
|
} else if (filename.isAValidFilename()) {
|
||||||
val file = File(path, "$filename.ics")
|
val file = File(path, "$filename.ics")
|
||||||
if (file.exists()) {
|
if (file.exists()) {
|
||||||
context.toast(R.string.name_taken)
|
activity.toast(R.string.name_taken)
|
||||||
return@setOnClickListener
|
return@setOnClickListener
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -54,7 +54,7 @@ class ExportEventsDialog(val activity: SimpleActivity, val path: String, val cal
|
||||||
callback(view.export_events_checkbox.isChecked, file, eventTypes)
|
callback(view.export_events_checkbox.isChecked, file, eventTypes)
|
||||||
dismiss()
|
dismiss()
|
||||||
} else {
|
} else {
|
||||||
context.toast(R.string.invalid_name)
|
activity.toast(R.string.invalid_name)
|
||||||
}
|
}
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
|
@ -51,13 +51,11 @@ class ImportEventsDialog(val activity: Activity, val path: String, val callback:
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun handleParseResult(result: IcsImporter.ImportResult) {
|
private fun handleParseResult(result: IcsImporter.ImportResult) {
|
||||||
activity.runOnUiThread {
|
activity.toast(when (result) {
|
||||||
activity.toast(when (result) {
|
IMPORT_OK -> R.string.events_imported_successfully
|
||||||
IMPORT_OK -> R.string.events_imported_successfully
|
IMPORT_PARTIAL -> R.string.importing_some_events_failed
|
||||||
IMPORT_PARTIAL -> R.string.importing_some_events_failed
|
else -> R.string.importing_events_failed
|
||||||
else -> R.string.importing_events_failed
|
})
|
||||||
})
|
callback.invoke(result != IMPORT_FAIL)
|
||||||
callback.invoke(result != IMPORT_FAIL)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue