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
|
// Continue initialization in a separate coroutine. This allows us to call
|
||||||
// runWithPermissionCheck(), which will keep trying to run the code block
|
// 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).
|
// coroutine is cancelled (see onStop() below).
|
||||||
pumpCoroutineScope.launch {
|
pumpCoroutineScope.launch {
|
||||||
runWithPermissionCheck(
|
runWithPermissionCheck(
|
||||||
|
@ -378,7 +378,7 @@ class ComboV2Plugin @Inject constructor (
|
||||||
// Setup coroutine to enable/disable the pair and unpair
|
// Setup coroutine to enable/disable the pair and unpair
|
||||||
// preferences depending on the pairing state.
|
// preferences depending on the pairing state.
|
||||||
preferenceFragment.run {
|
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
|
// 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.
|
// 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
|
// 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"
|
// Store a local reference to the Pump instance. "pump"
|
||||||
// is set to null in case of an error, because then,
|
// is set to null in case of an error, because then,
|
||||||
// disconnectInternal() is called (which sets pump to null).
|
// 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.
|
// from the pump's lastBolusFlow, even if an error happened.
|
||||||
// Solve this by storing this reference and accessing the
|
// Solve this by storing this reference and accessing the
|
||||||
// lastBolusFlow through it.
|
// lastBolusFlow through it.
|
||||||
|
@ -1171,9 +1171,8 @@ class ComboV2Plugin @Inject constructor (
|
||||||
runBlocking {
|
runBlocking {
|
||||||
try {
|
try {
|
||||||
executeCommand {
|
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 ->
|
ComboCtlPump.SetTbrOutcome.SET_NORMAL_TBR ->
|
||||||
rh.gs(R.string.combov2_setting_tbr_succeeded)
|
rh.gs(R.string.combov2_setting_tbr_succeeded)
|
||||||
ComboCtlPump.SetTbrOutcome.SET_EMULATED_100_TBR ->
|
ComboCtlPump.SetTbrOutcome.SET_EMULATED_100_TBR ->
|
||||||
|
@ -2281,7 +2280,7 @@ class ComboV2Plugin @Inject constructor (
|
||||||
.comment(comment)
|
.comment(comment)
|
||||||
|
|
||||||
private fun getBluetoothAddress(): ComboCtlBluetoothAddress? =
|
private fun getBluetoothAddress(): ComboCtlBluetoothAddress? =
|
||||||
pumpManager!!.getPairedPumpAddresses().firstOrNull()
|
pumpManager?.getPairedPumpAddresses()?.firstOrNull()
|
||||||
|
|
||||||
private fun isDisconnected() =
|
private fun isDisconnected() =
|
||||||
when (driverStateFlow.value) {
|
when (driverStateFlow.value) {
|
||||||
|
|
Loading…
Reference in a new issue