From bb3effcda3c1dfcbf4186d74377508c50d2d90b1 Mon Sep 17 00:00:00 2001 From: Philoul Date: Thu, 1 Apr 2021 20:17:11 +0200 Subject: [PATCH] Fix null XXXValueWithUnit and aapsLogger string --- .../androidaps/logging/UserEntryLogger.kt | 25 ++++++++++-------- .../database/entities/XXXValueWithUnit.kt | 26 +++++++++---------- 2 files changed, 27 insertions(+), 24 deletions(-) diff --git a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt index b7cc9954e1..f65506c949 100644 --- a/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt +++ b/core/src/main/java/info/nightscout/androidaps/logging/UserEntryLogger.kt @@ -27,17 +27,18 @@ class UserEntryLogger @Inject constructor( } fun log(action: Action, source: Sources, note: String? ="", vararg listvalues: XXXValueWithUnit?) { + val filteredValues = listvalues.toList().filter { it != null} compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, source = source, note = note ?:"", - values = listvalues.toList() + values = filteredValues )) .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) .subscribeBy( - onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $listvalues") }, - onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $listvalues") } + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $filteredValues") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $filteredValues") } ) } @@ -46,17 +47,18 @@ class UserEntryLogger @Inject constructor( } fun log(action: Action, source: Sources, vararg listvalues: XXXValueWithUnit?) { + val filteredValues = listvalues.toList().filter { it != null} compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, source = source, note = "", - values = listvalues.toList() + values = filteredValues )) .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) .subscribeBy( - onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $listvalues") }, - onComplete = { aapsLogger.debug("USER ENTRY: $action $source $listvalues") } + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $filteredValues") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action $source $filteredValues") } ) } @@ -68,7 +70,7 @@ class UserEntryLogger @Inject constructor( action = action, source = source, note = note ?:"", - values = mutableListOf() + values = listOf() )) .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) @@ -81,18 +83,19 @@ class UserEntryLogger @Inject constructor( @Deprecated("Use XXXValueWithUnits") fun log(action: Action, s: String? = "", values: MutableList) {} - fun log(action: Action, source: Sources, note: String? ="", values: MutableList) { + fun log(action: Action, source: Sources, note: String? ="", listvalues: MutableList) { + val filteredValues = listvalues.toList().filter { it != null} compositeDisposable += repository.runTransaction(UserEntryTransaction( action = action, source = source, note = note ?: "", - values = values + values = filteredValues )) .subscribeOn(aapsSchedulers.io) .observeOn(aapsSchedulers.io) .subscribeBy( - onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $values") }, - onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $values") } + onError = { aapsLogger.debug("ERRORED USER ENTRY: $action $source $note $filteredValues") }, + onComplete = { aapsLogger.debug("USER ENTRY: $action $source $note $filteredValues") } ) } } \ No newline at end of file diff --git a/database/src/main/java/info/nightscout/androidaps/database/entities/XXXValueWithUnit.kt b/database/src/main/java/info/nightscout/androidaps/database/entities/XXXValueWithUnit.kt index f41f322996..24ae077e70 100644 --- a/database/src/main/java/info/nightscout/androidaps/database/entities/XXXValueWithUnit.kt +++ b/database/src/main/java/info/nightscout/androidaps/database/entities/XXXValueWithUnit.kt @@ -10,31 +10,31 @@ sealed class XXXValueWithUnit { data class SimpleInt(val value: Int) : XXXValueWithUnit() // formerly one usage of None - class Mgdl(val value: Double) : XXXValueWithUnit() + data class Mgdl(val value: Double) : XXXValueWithUnit() - class Mmoll(val value: Double) : XXXValueWithUnit() + data class Mmoll(val value: Double) : XXXValueWithUnit() - class Timestamp(val value: Long) : XXXValueWithUnit() + data class Timestamp(val value: Long) : XXXValueWithUnit() - class Insulin(val value: Double) : XXXValueWithUnit() + data class Insulin(val value: Double) : XXXValueWithUnit() - class UnitPerHour(val value: Double) : XXXValueWithUnit() + data class UnitPerHour(val value: Double) : XXXValueWithUnit() - class Gram(val value: Int) : XXXValueWithUnit() + data class Gram(val value: Int) : XXXValueWithUnit() - class Minute(val value: Int) : XXXValueWithUnit() + data class Minute(val value: Int) : XXXValueWithUnit() - class Hour(val value: Int) : XXXValueWithUnit() + data class Hour(val value: Int) : XXXValueWithUnit() - class Percent(val value: Int) : XXXValueWithUnit() + data class Percent(val value: Int) : XXXValueWithUnit() - class TherapyEventType(val value: TherapyEvent.Type) : XXXValueWithUnit() + data class TherapyEventType(val value: TherapyEvent.Type) : XXXValueWithUnit() - class TherapyEventMeterType(val value: TherapyEvent.MeterType) : XXXValueWithUnit() + data class TherapyEventMeterType(val value: TherapyEvent.MeterType) : XXXValueWithUnit() - class TherapyEventTTReason(val value: TemporaryTarget.Reason) : XXXValueWithUnit() + data class TherapyEventTTReason(val value: TemporaryTarget.Reason) : XXXValueWithUnit() - class StringResource(@StringRes val value: Int, val params: List = listOf()) : XXXValueWithUnit() + data class StringResource(@StringRes val value: Int, val params: List = listOf()) : XXXValueWithUnit() companion object {