From f1499d1886ae1e9b3dfc17c93ae3836703429f0e Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Fri, 16 Dec 2022 11:37:32 +0100 Subject: [PATCH] optimize reading autosense data --- .../plugins/general/overview/OverviewFragment.kt | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewFragment.kt b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewFragment.kt index 59a7cee91e..b62121342c 100644 --- a/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewFragment.kt +++ b/plugins/main/src/main/java/info/nightscout/plugins/general/overview/OverviewFragment.kt @@ -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()