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 5e55a51d..c740b8ea 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 @@ -18,6 +18,7 @@ import at.bitfire.ical4android.CalendarStorageException import com.etesync.syncadapter.Constants.KEY_ACCOUNT import com.etesync.syncadapter.Constants.KEY_COLLECTION_INFO import com.etesync.syncadapter.R +import com.etesync.syncadapter.log.Logger import com.etesync.syncadapter.model.CollectionInfo import com.etesync.syncadapter.resource.LocalCalendar import com.etesync.syncadapter.resource.LocalEvent @@ -190,7 +191,13 @@ class LocalCalendarImportFragment : ListFragment() { } override fun onPostExecute(result: ResultFragment.ImportResult) { - if (progressDialog.isShowing && !activity!!.isDestroyed) { + val activity = activity + if (activity == null) { + Logger.log.warning("Activity is null on import.") + return + } + + 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 87876554..cfc6b540 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 @@ -24,6 +24,7 @@ import at.bitfire.vcard4android.ContactsStorageException import com.etesync.syncadapter.Constants.KEY_ACCOUNT import com.etesync.syncadapter.Constants.KEY_COLLECTION_INFO import com.etesync.syncadapter.R +import com.etesync.syncadapter.log.Logger import com.etesync.syncadapter.model.CollectionInfo import com.etesync.syncadapter.resource.LocalAddressBook import com.etesync.syncadapter.resource.LocalContact @@ -124,7 +125,13 @@ class LocalContactImportFragment : Fragment() { } override fun onPostExecute(result: ResultFragment.ImportResult) { - if (progressDialog.isShowing && !activity!!.isDestroyed) { + val activity = activity + if (activity == null) { + Logger.log.warning("Activity is null on import.") + return + } + + if (progressDialog.isShowing && !activity.isDestroyed) { progressDialog.dismiss() } (activity as ResultFragment.OnImportCallback).onImportResult(result)