From 4f5a2de20e41c92dc4f3d05e6a568c8d82a7ea0d Mon Sep 17 00:00:00 2001 From: tibbi Date: Mon, 12 Nov 2018 20:23:01 +0100 Subject: [PATCH] handle event sharing on a background thread --- .../calendar/pro/extensions/Activity.kt | 24 ++++++++++--------- 1 file changed, 13 insertions(+), 11 deletions(-) diff --git a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt index 71658b44a..009e39eac 100644 --- a/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt +++ b/app/src/main/kotlin/com/simplemobiletools/calendar/pro/extensions/Activity.kt @@ -16,18 +16,20 @@ import java.util.TreeSet import kotlin.collections.ArrayList fun BaseSimpleActivity.shareEvents(ids: List) { - val file = getTempFile() - if (file == null) { - toast(R.string.unknown_error_occurred) - return - } - - val events = dbHelper.getEventsWithIds(ids) - IcsExporter().exportEvents(this, file, events, false) { - if (it == IcsExporter.ExportResult.EXPORT_OK) { - sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID) + Thread { + val file = getTempFile() + if (file == null) { + toast(R.string.unknown_error_occurred) + return@Thread } - } + + val events = dbHelper.getEventsWithIds(ids) + IcsExporter().exportEvents(this, file, events, false) { + if (it == IcsExporter.ExportResult.EXPORT_OK) { + sharePathIntent(file.absolutePath, BuildConfig.APPLICATION_ID) + } + } + }.start() } fun BaseSimpleActivity.getTempFile(): File? {