fix Nan error
This commit is contained in:
parent
c0f911ad14
commit
bfaa392eb0
1 changed files with 5 additions and 2 deletions
|
@ -9,9 +9,12 @@ import java.util.*
|
|||
val TotalDailyDose.total
|
||||
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 =
|
||||
if (includeCarbs) resourceHelper.gs(R.string.tddwithcarbsformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalAmount / total * 100, carbs)
|
||||
else resourceHelper.gs(R.string.tddformat, dateUtil.dateStringShort(timestamp), total, bolusAmount, basalAmount, basalAmount / total * 100)
|
||||
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, basalPct)
|
||||
|
||||
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)
|
||||
|
|
Loading…
Reference in a new issue