From 2104b55122770cc106fa4853185e9ce2b43948e2 Mon Sep 17 00:00:00 2001 From: tibbi Date: Sat, 15 Apr 2017 20:49:24 +0200 Subject: [PATCH] show a message if theres no events found for exporting --- .../calendar/activities/MainActivity.kt | 20 ++++++++++++------- 1 file changed, 13 insertions(+), 7 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt index a5270d915..0061cece9 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/activities/MainActivity.kt @@ -264,13 +264,19 @@ class MainActivity : SimpleActivity(), NavigationListener { ExportEventsDialog(this, path) { Thread({ val events = dbHelper.getEventsToExport(it) - val result = IcsExporter().exportEvents(this, path, 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 - }) + if (events.isEmpty()) { + runOnUiThread { + toast(R.string.no_events_for_exporting) + } + } else { + val result = IcsExporter().exportEvents(this, path, 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() }