fix units conversion

This commit is contained in:
Milos Kozak 2021-11-08 15:05:27 +01:00
parent 22fced61fe
commit 225797f430

View file

@ -131,12 +131,12 @@ class UserEntryPresentationHelper @Inject constructor(
is ValueWithUnit.Mgdl -> { is ValueWithUnit.Mgdl -> {
if (profileFunction.getUnits() == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(valueWithUnit.value) + translator.translate(valueWithUnit) if (profileFunction.getUnits() == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(valueWithUnit.value) + translator.translate(valueWithUnit)
else DecimalFormatter.to1Decimal(valueWithUnit.value / Constants.MMOLL_TO_MGDL) + translator.translate(valueWithUnit) else DecimalFormatter.to1Decimal(valueWithUnit.value * Constants.MGDL_TO_MMOLL) + translator.translate(valueWithUnit)
} }
is ValueWithUnit.Mmoll -> { is ValueWithUnit.Mmoll -> {
if (profileFunction.getUnits() == GlucoseUnit.MGDL) DecimalFormatter.to0Decimal(valueWithUnit.value) + translator.translate(valueWithUnit) if (profileFunction.getUnits() == GlucoseUnit.MMOL) DecimalFormatter.to1Decimal(valueWithUnit.value) + translator.translate(valueWithUnit)
else DecimalFormatter.to1Decimal(valueWithUnit.value * Constants.MMOLL_TO_MGDL) + translator.translate(valueWithUnit) else DecimalFormatter.to0Decimal(valueWithUnit.value * Constants.MMOLL_TO_MGDL) + translator.translate(valueWithUnit)
} }
ValueWithUnit.UNKNOWN -> "" ValueWithUnit.UNKNOWN -> ""