RileyLinkServiceData resolve nullability

This commit is contained in:
Milos Kozak 2022-07-01 00:07:38 +02:00
parent 77e112471f
commit 23bdb57ed3
4 changed files with 15 additions and 20 deletions

View file

@ -340,19 +340,15 @@ class MedtronicFragment : DaggerFragment() {
medtronicPumpPlugin.rileyLinkService?.verifyConfiguration()
binding.errors.text = medtronicPumpStatus.errorInfo
val showRileyLinkBatteryLevel: Boolean = rileyLinkServiceData.showBatteryLevel
if (showRileyLinkBatteryLevel) {
if (rileyLinkServiceData.showBatteryLevel) {
binding.rlBatteryView.visibility = View.VISIBLE
binding.rlBatteryLabel.visibility = View.VISIBLE
binding.rlBatteryState.visibility = View.VISIBLE
binding.rlBatteryLayout.visibility = View.VISIBLE
binding.rlBatterySemicolon.visibility = View.VISIBLE
if (rileyLinkServiceData.batteryLevel == null) {
binding.rlBatteryState.text = " ?"
} else {
binding.rlBatteryState.text = "{fa-battery-" + rileyLinkServiceData.batteryLevel / 25 + "} " + rileyLinkServiceData.batteryLevel + "%"
}
binding.rlBatteryState.text =
if (rileyLinkServiceData.batteryLevel == null) " ?"
else "{fa-battery-${rileyLinkServiceData.batteryLevel!! / 25}} ${rileyLinkServiceData.batteryLevel}%"
} else {
binding.rlBatteryView.visibility = View.GONE
binding.rlBatteryLabel.visibility = View.GONE

View file

@ -110,7 +110,7 @@ class RileyLinkBroadcastReceiver : DaggerBroadcastReceiver() {
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy version (BLE113): $bleVersion")
rileyLinkService?.rileyLinkServiceData?.versionBLE113 = bleVersion
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): " + rlVersion.name)
aapsLogger.debug(LTag.PUMPBTCOMM, "RfSpy Radio version (CC110): ${rlVersion?.name}")
rileyLinkServiceData.firmwareVersion = rlVersion
val task: ServiceTask = InitializePumpManagerTask(injector, context)
serviceTaskExecutor.startTask(task)

View file

@ -31,27 +31,27 @@ public class RileyLinkServiceData {
@Inject RxBus rxBus;
boolean tuneUpDone = false;
public RileyLinkError rileyLinkError;
@Nullable public RileyLinkError rileyLinkError;
public RileyLinkServiceState rileyLinkServiceState = RileyLinkServiceState.NotStarted;
private long lastServiceStateChange = 0L;
public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
@Nullable public RileyLinkFirmwareVersion firmwareVersion; // here we have "compatibility level" version
@Nullable public RileyLinkTargetFrequency rileyLinkTargetFrequency;
@Nullable public String rileyLinkAddress;
@Nullable public String rileyLinkName;
public Integer batteryLevel;
@Nullable public Integer batteryLevel;
public boolean showBatteryLevel = false;
long lastTuneUpTime = 0L;
public Double lastGoodFrequency;
@Nullable public Double lastGoodFrequency;
// bt version
public String versionBLE113;
@Nullable public String versionBLE113;
// radio version
public String versionCC110;
@Nullable public String versionCC110;
// orangeLink
public boolean isOrange;
public String versionOrangeFirmware;
public String versionOrangeHardware;
public boolean isOrange = false;
@Nullable public String versionOrangeFirmware;
@Nullable public String versionOrangeHardware;
public RileyLinkTargetDevice targetDevice;

View file

@ -34,8 +34,7 @@ class InitializePumpManagerTask(injector: HasAndroidInjector, private val contex
lastGoodFrequency = sp.getDouble(RileyLinkConst.Prefs.LastGoodDeviceFrequency, 0.0)
lastGoodFrequency = (lastGoodFrequency * 1000.0).roundToLong() / 1000.0
rileyLinkServiceData.lastGoodFrequency = lastGoodFrequency
} else lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency
} else lastGoodFrequency = rileyLinkServiceData.lastGoodFrequency ?: 0.0
val rileyLinkCommunicationManager = pumpDevice?.rileyLinkService?.deviceCommunicationManager
if (activePlugin.activePump.manufacturer() === ManufacturerType.Medtronic) {