Prevent crash in OmnipodOverviewFragment when context is null

This commit is contained in:
Bart Sopers 2021-01-02 22:30:27 +01:00
parent 8f2e60d7bc
commit 1942f606b9

View file

@ -102,10 +102,12 @@ class OmnipodOverviewFragment : DaggerFragment() {
omnipod_overview_button_pod_management.setOnClickListener { omnipod_overview_button_pod_management.setOnClickListener {
if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) { if (omnipodPumpPlugin.rileyLinkService?.verifyConfiguration() == true) {
activity?.let { activity -> activity?.let { activity ->
protectionCheck.queryProtection( context?.let { context ->
activity, ProtectionCheck.Protection.PREFERENCES, protectionCheck.queryProtection(
UIRunnable(Runnable { startActivity(Intent(context, PodManagementActivity::class.java)) }) activity, ProtectionCheck.Protection.PREFERENCES,
) UIRunnable { startActivity(Intent(context, PodManagementActivity::class.java)) }
)
}
} }
} else { } else {
displayNotConfiguredDialog() displayNotConfiguredDialog()
@ -514,10 +516,10 @@ class OmnipodOverviewFragment : DaggerFragment() {
private fun displayNotConfiguredDialog() { private fun displayNotConfiguredDialog() {
context?.let { context?.let {
UIRunnable(Runnable { UIRunnable {
OKDialog.show(it, resourceHelper.gs(R.string.omnipod_warning), OKDialog.show(it, resourceHelper.gs(R.string.omnipod_warning),
resourceHelper.gs(R.string.omnipod_error_operation_not_possible_no_configuration), null) resourceHelper.gs(R.string.omnipod_error_operation_not_possible_no_configuration), null)
}).run() }.run()
} }
} }
@ -534,9 +536,9 @@ class OmnipodOverviewFragment : DaggerFragment() {
private fun displayOkDialog(title: String, message: String) { private fun displayOkDialog(title: String, message: String) {
context?.let { context?.let {
UIRunnable(Runnable { UIRunnable {
OKDialog.show(it, title, message, null) OKDialog.show(it, title, message, null)
}).run() }.run()
} }
} }