update bluetooth status. fix warnings.

This commit is contained in:
Andrei Vereha 2021-09-21 21:05:29 +02:00
parent 8767065fda
commit 2dee60b4e0
4 changed files with 19 additions and 13 deletions

View file

@ -189,7 +189,7 @@ object ProgramBasalUtil {
return pulsesPerSlot return pulsesPerSlot
} }
fun calculateCurrentSlot(pulsesPerSlot: ShortArray?, currentTime: Date?): CurrentSlot { fun calculateCurrentSlot(pulsesPerSlot: ShortArray?, currentTime: Date): CurrentSlot {
val instance = Calendar.getInstance() val instance = Calendar.getInstance()
instance.time = currentTime instance.time = currentTime
val hourOfDay = instance[Calendar.HOUR_OF_DAY] val hourOfDay = instance[Calendar.HOUR_OF_DAY]
@ -205,7 +205,7 @@ object ProgramBasalUtil {
fun calculateCurrentLongInsulinProgramElement( fun calculateCurrentLongInsulinProgramElement(
elements: List<BasalInsulinProgramElement>, elements: List<BasalInsulinProgramElement>,
currentTime: Date? currentTime: Date
): CurrentBasalInsulinProgramElement { ): CurrentBasalInsulinProgramElement {
val instance = Calendar.getInstance() val instance = Calendar.getInstance()
instance.time = currentTime instance.time = currentTime

View file

@ -13,6 +13,7 @@ import dagger.android.support.DaggerFragment
import info.nightscout.androidaps.Constants import info.nightscout.androidaps.Constants
import info.nightscout.androidaps.activities.ErrorHelperActivity import info.nightscout.androidaps.activities.ErrorHelperActivity
import info.nightscout.androidaps.events.EventPreferenceChange import info.nightscout.androidaps.events.EventPreferenceChange
import info.nightscout.androidaps.events.EventPumpStatusChanged
import info.nightscout.androidaps.interfaces.CommandQueueProvider import info.nightscout.androidaps.interfaces.CommandQueueProvider
import info.nightscout.androidaps.interfaces.PumpSync import info.nightscout.androidaps.interfaces.PumpSync
import info.nightscout.androidaps.plugins.bus.RxBusWrapper import info.nightscout.androidaps.plugins.bus.RxBusWrapper
@ -206,6 +207,16 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
}, },
fabricPrivacy::logException fabricPrivacy::logException
) )
disposables += rxBus
.toObservable(EventPumpStatusChanged::class.java)
.observeOn(aapsSchedulers.main)
.subscribe(
{
updateBluetoothConnectionStatus(it)
},
fabricPrivacy::logException
)
updateUi() updateUi()
} }
@ -231,18 +242,13 @@ class OmnipodDashOverviewFragment : DaggerFragment() {
updateQueueStatus() updateQueueStatus()
} }
private fun updateBluetoothConnectionStatus(event: EventPumpStatusChanged) {
bluetoothStatusBinding.omnipodDashBluetoothStatus.text = event.getStatus(resourceHelper)
}
private fun updateBluetoothStatus() { private fun updateBluetoothStatus() {
bluetoothStatusBinding.omnipodDashBluetoothAddress.text = podStateManager.bluetoothAddress bluetoothStatusBinding.omnipodDashBluetoothAddress.text = podStateManager.bluetoothAddress
?: PLACEHOLDER ?: PLACEHOLDER
bluetoothStatusBinding.omnipodDashBluetoothStatus.text =
when (podStateManager.bluetoothConnectionState) {
OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTED ->
"{fa-bluetooth}"
OmnipodDashPodStateManager.BluetoothConnectionState.DISCONNECTED ->
"{fa-bluetooth-b}"
OmnipodDashPodStateManager.BluetoothConnectionState.CONNECTING ->
"{fa-bluetooth-b spin}"
}
val connectionSuccessPercentage = podStateManager.connectionSuccessRatio() * 100 val connectionSuccessPercentage = podStateManager.connectionSuccessRatio() * 100
val successPercentageString = String.format("%.2f %%", connectionSuccessPercentage) val successPercentageString = String.format("%.2f %%", connectionSuccessPercentage)

View file

@ -40,7 +40,7 @@ class DashInitializePodViewModel @Inject constructor(
} else } else
null null
val disposable = omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy( omnipodManager.activatePodPart1(lowReservoirAlertTrigger).subscribeBy(
onNext = { podEvent -> onNext = { podEvent ->
logger.debug( logger.debug(
LTag.PUMP, LTag.PUMP,

View file

@ -63,7 +63,7 @@ class DashInsertCannulaViewModel @Inject constructor(
else else
null null
val disposable = omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown).subscribeBy( omnipodManager.activatePodPart2(basalProgram, expirationHoursBeforeShutdown).subscribeBy(
onNext = { podEvent -> onNext = { podEvent ->
logger.debug( logger.debug(
LTag.PUMP, LTag.PUMP,