Xdrip: prevent NPE

This commit is contained in:
Milos Kozak 2023-03-22 22:09:43 +01:00
parent 75d34955b7
commit 8ce12d61c0

View file

@ -362,10 +362,8 @@ class XdripPlugin @Inject constructor(
private fun sendEntries(dataPairs: List<DataSyncSelector.DataPair>, progress: String) { private fun sendEntries(dataPairs: List<DataSyncSelector.DataPair>, progress: String) {
val array = JSONArray() val array = JSONArray()
for (dataPair in dataPairs) { for (dataPair in dataPairs)
val data = (dataPair as DataSyncSelector.PairGlucoseValue).value.toXdripJson() (dataPair as DataSyncSelector.PairGlucoseValue?)?.value?.toXdripJson()?.also { gv -> array.put(gv) }
array.put(data)
}
rxBus.send(EventXdripNewLog("SENDING", "Sent ${array.length()} BGs ($progress)")) rxBus.send(EventXdripNewLog("SENDING", "Sent ${array.length()} BGs ($progress)"))
broadcast( broadcast(
Intent(Intents.ACTION_NEW_SGV) Intent(Intents.ACTION_NEW_SGV)