optimize reading autosense data

This commit is contained in:
Milos Kozak 2022-12-16 11:37:32 +01:00
parent bf3d15f9be
commit f1499d1886

View file

@ -1091,15 +1091,16 @@ class OverviewFragment : DaggerFragment(), View.OnClickListener, OnLongClickList
private fun updateSensitivity() {
_binding ?: return
if (constraintChecker.isAutosensModeEnabled().value() || !(config.NSCLIENT && overviewData.lastAutosensData(iobCobCalculator) == null)) {
val lastAutosensData = overviewData.lastAutosensData(iobCobCalculator)
if (constraintChecker.isAutosensModeEnabled().value() || !(config.NSCLIENT && lastAutosensData == null)) {
binding.infoLayout.sensitivityIcon.setImageResource(info.nightscout.core.main.R.drawable.ic_swap_vert_black_48dp_green)
} else {
binding.infoLayout.sensitivityIcon.setImageResource(info.nightscout.core.main.R.drawable.ic_x_swap_vert)
}
binding.infoLayout.sensitivity.text =
overviewData.lastAutosensData(iobCobCalculator)?.let { autosensData ->
String.format(Locale.ENGLISH, "%.0f%%", autosensData.autosensResult.ratio * 100)
lastAutosensData?.let {
String.format(Locale.ENGLISH, "%.0f%%", it.autosensResult.ratio * 100)
} ?: ""
// Show variable sensitivity
val profile = profileFunction.getProfile()