EditCollection: only show error if we are still attached to context.

pull/146/head
Tom Hacohen 4 years ago
parent 841a1f0fd9
commit b5aafc11c5

@ -15,6 +15,7 @@ import com.etebase.client.exceptions.EtebaseException
import com.etesync.syncadapter.CachedCollection import com.etesync.syncadapter.CachedCollection
import com.etesync.syncadapter.Constants import com.etesync.syncadapter.Constants
import com.etesync.syncadapter.R import com.etesync.syncadapter.R
import com.etesync.syncadapter.log.Logger
import com.etesync.syncadapter.resource.LocalCalendar import com.etesync.syncadapter.resource.LocalCalendar
import com.etesync.syncadapter.syncadapter.requestSync import com.etesync.syncadapter.syncadapter.requestSync
import com.etesync.syncadapter.ui.BaseActivity import com.etesync.syncadapter.ui.BaseActivity
@ -167,11 +168,14 @@ class EditCollectionFragment(private val cachedCollection: CachedCollection, pri
activity?.finish() activity?.finish()
} catch (e: EtebaseException) { } catch (e: EtebaseException) {
uiThread { uiThread {
AlertDialog.Builder(requireContext()) Logger.log.warning(e.localizedMessage)
.setIcon(R.drawable.ic_info_dark) context?.let { context ->
.setTitle(R.string.exception) AlertDialog.Builder(context)
.setMessage(e.localizedMessage) .setIcon(R.drawable.ic_info_dark)
.setPositiveButton(android.R.string.yes) { _, _ -> }.show() .setTitle(R.string.exception)
.setMessage(e.localizedMessage)
.setPositiveButton(android.R.string.yes) { _, _ -> }.show()
}
} }
} finally { } finally {
uiThread { uiThread {

Loading…
Cancel
Save