Combov2: prevent NPE
This commit is contained in:
parent
66c85597f7
commit
65123fe527
1 changed files with 5 additions and 6 deletions
|
@ -292,7 +292,7 @@ class ComboV2Plugin @Inject constructor (
|
|||
|
||||
// Continue initialization in a separate coroutine. This allows us to call
|
||||
// runWithPermissionCheck(), which will keep trying to run the code block
|
||||
// until either the necessary Bluetooth permissios are granted, or the
|
||||
// until either the necessary Bluetooth permissions are granted, or the
|
||||
// coroutine is cancelled (see onStop() below).
|
||||
pumpCoroutineScope.launch {
|
||||
runWithPermissionCheck(
|
||||
|
@ -378,7 +378,7 @@ class ComboV2Plugin @Inject constructor (
|
|||
// Setup coroutine to enable/disable the pair and unpair
|
||||
// preferences depending on the pairing state.
|
||||
preferenceFragment.run {
|
||||
// We use the fragment's lifecyle instead of the fragment view's, since the latter
|
||||
// We use the fragment's lifecycle instead of the fragment view's, since the latter
|
||||
// is initialized in onCreateView(), and we reach this point here _before_ that
|
||||
// method is called. In other words, the fragment view does not exist at this point.
|
||||
// repeatOnLifecycle() is a utility function that runs its block when the lifecycle
|
||||
|
@ -984,7 +984,7 @@ class ComboV2Plugin @Inject constructor (
|
|||
// Store a local reference to the Pump instance. "pump"
|
||||
// is set to null in case of an error, because then,
|
||||
// disconnectInternal() is called (which sets pump to null).
|
||||
// However, we still need to access the last deliverd bolus
|
||||
// However, we still need to access the last delivered bolus
|
||||
// from the pump's lastBolusFlow, even if an error happened.
|
||||
// Solve this by storing this reference and accessing the
|
||||
// lastBolusFlow through it.
|
||||
|
@ -1171,9 +1171,8 @@ class ComboV2Plugin @Inject constructor (
|
|||
runBlocking {
|
||||
try {
|
||||
executeCommand {
|
||||
val setTbrOutcome = pump!!.setTbr(percentage, durationInMinutes, tbrType, force100Percent)
|
||||
|
||||
val tbrComment = when (setTbrOutcome) {
|
||||
val tbrComment = when (pump!!.setTbr(percentage, durationInMinutes, tbrType, force100Percent)) {
|
||||
ComboCtlPump.SetTbrOutcome.SET_NORMAL_TBR ->
|
||||
rh.gs(R.string.combov2_setting_tbr_succeeded)
|
||||
ComboCtlPump.SetTbrOutcome.SET_EMULATED_100_TBR ->
|
||||
|
@ -2281,7 +2280,7 @@ class ComboV2Plugin @Inject constructor (
|
|||
.comment(comment)
|
||||
|
||||
private fun getBluetoothAddress(): ComboCtlBluetoothAddress? =
|
||||
pumpManager!!.getPairedPumpAddresses().firstOrNull()
|
||||
pumpManager?.getPairedPumpAddresses()?.firstOrNull()
|
||||
|
||||
private fun isDisconnected() =
|
||||
when (driverStateFlow.value) {
|
||||
|
|
Loading…
Reference in a new issue