prevent NPE:

This commit is contained in:
Milos Kozak 2020-07-02 23:50:38 +02:00
parent e9670dd20a
commit c2ae713cc4

View file

@ -600,42 +600,42 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
overview_apsmode?.visibility = View.VISIBLE overview_apsmode?.visibility = View.VISIBLE
when { when {
loopPlugin.isEnabled() && loopPlugin.isSuperBolus -> { loopPlugin.isEnabled() && loopPlugin.isSuperBolus -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_superbolus) overview_apsmode?.setImageResource(R.drawable.ic_loop_superbolus)
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
} }
loopPlugin.isDisconnected -> { loopPlugin.isDisconnected -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_disconnected) overview_apsmode?.setImageResource(R.drawable.ic_loop_disconnected)
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
} }
loopPlugin.isEnabled() && loopPlugin.isSuspended -> { loopPlugin.isEnabled() && loopPlugin.isSuspended -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_paused) overview_apsmode?.setImageResource(R.drawable.ic_loop_paused)
overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper) overview_apsmode_text?.text = DateUtil.age(loopPlugin.minutesToEndOfSuspend() * 60000L, true, resourceHelper)
} }
pump.isSuspended -> { pump.isSuspended -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_paused) overview_apsmode?.setImageResource(R.drawable.ic_loop_paused)
overview_apsmode_text?.text = "" overview_apsmode_text?.text = ""
} }
loopPlugin.isEnabled() && closedLoopEnabled.value() && loopPlugin.isLGS -> { loopPlugin.isEnabled() && closedLoopEnabled.value() && loopPlugin.isLGS -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_lgs) overview_apsmode?.setImageResource(R.drawable.ic_loop_lgs)
overview_apsmode_text?.text = "" overview_apsmode_text?.text = ""
} }
loopPlugin.isEnabled() && closedLoopEnabled.value() -> { loopPlugin.isEnabled() && closedLoopEnabled.value() -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_closed) overview_apsmode?.setImageResource(R.drawable.ic_loop_closed)
overview_apsmode_text?.text = "" overview_apsmode_text?.text = ""
} }
loopPlugin.isEnabled() && !closedLoopEnabled.value() -> { loopPlugin.isEnabled() && !closedLoopEnabled.value() -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_open) overview_apsmode?.setImageResource(R.drawable.ic_loop_open)
overview_apsmode_text?.text = "" overview_apsmode_text?.text = ""
} }
else -> { else -> {
overview_apsmode.setImageResource(R.drawable.ic_loop_disabled) overview_apsmode?.setImageResource(R.drawable.ic_loop_disabled)
overview_apsmode_text?.text = "" overview_apsmode_text?.text = ""
} }
} }