From 6381617f2c3c216eabcf6c7fbd97797ee6a940b2 Mon Sep 17 00:00:00 2001 From: Tom Hacohen Date: Wed, 1 May 2019 13:40:05 +0100 Subject: [PATCH] Import: only dismiss import dialog if already showing. This should fix a crash when the os kills the activity before import is done. --- .../syncadapter/ui/importlocal/LocalCalendarImportFragment.kt | 4 +++- .../syncadapter/ui/importlocal/LocalContactImportFragment.kt | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt index 982d42de..4179af1e 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalCalendarImportFragment.kt @@ -189,7 +189,9 @@ class LocalCalendarImportFragment : ListFragment() { } override fun onPostExecute(result: ResultFragment.ImportResult) { - progressDialog.dismiss() + if (progressDialog.isShowing && !activity!!.isDestroyed) { + progressDialog.dismiss() + } (activity as ResultFragment.OnImportCallback).onImportResult(result) } diff --git a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt index 8b16177f..17e5e9b1 100644 --- a/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt +++ b/app/src/main/java/com/etesync/syncadapter/ui/importlocal/LocalContactImportFragment.kt @@ -124,7 +124,9 @@ class LocalContactImportFragment : Fragment() { } override fun onPostExecute(result: ResultFragment.ImportResult) { - progressDialog.dismiss() + if (progressDialog.isShowing && !activity!!.isDestroyed) { + progressDialog.dismiss() + } (activity as ResultFragment.OnImportCallback).onImportResult(result) }