fix Nan error
This commit is contained in:
parent
c0f911ad14
commit
bfaa392eb0
|
@ -9,9 +9,12 @@ import java.util.*
|
||||||
val TotalDailyDose.total
|
val TotalDailyDose.total
|
||||||
get() = if (totalAmount > 0) totalAmount else basalAmount + bolusAmount
|
get() = if (totalAmount > 0) totalAmount else basalAmount + bolusAmount
|
||||||
|
|
||||||
|
val TotalDailyDose.basalPct: Double
|
||||||
|
get() = if (total > 0) basalAmount / total * 100 else 0.0
|
||||||
|
|
||||||
fun TotalDailyDose.toText(resourceHelper: ResourceHelper, dateUtil: DateUtil, includeCarbs: Boolean): String =
|
fun TotalDailyDose.toText(resourceHelper: ResourceHelper, dateUtil: DateUtil, includeCarbs: Boolean): String =
|
||||||
if (includeCarbs) resourceHelper.gs(R.string.tddwithcarbsformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalAmount / total * 100, carbs)
|
if (includeCarbs) resourceHelper.gs(R.string.tddwithcarbsformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalPct, carbs)
|
||||||
else resourceHelper.gs(R.string.tddformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalAmount / total * 100)
|
else resourceHelper.gs(R.string.tddformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalPct)
|
||||||
|
|
||||||
fun TotalDailyDose.toText(resourceHelper: ResourceHelper, days: Int, includeCarbs: Boolean): String =
|
fun TotalDailyDose.toText(resourceHelper: ResourceHelper, days: Int, includeCarbs: Boolean): String =
|
||||||
if (includeCarbs) resourceHelper.gs(R.string.tddwithcarbsformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolusAmount, basalAmount, basalAmount / total * 100, carbs)
|
if (includeCarbs) resourceHelper.gs(R.string.tddwithcarbsformat, String.format(Locale.getDefault(), "%d ", days) + resourceHelper.gs(R.string.days), total, bolusAmount, basalAmount, basalAmount / total * 100, carbs)
|
||||||
|
|
Loading…
Reference in a new issue