From bbe6248f81068742d7b27c924790c159b35438a5 Mon Sep 17 00:00:00 2001 From: Milos Kozak Date: Sat, 26 Feb 2022 21:02:06 +0100 Subject: [PATCH] Profile: fix graphs --- .../plugins/profile/local/LocalProfileFragment.kt | 11 ++++------- .../plugins/profile/local/LocalProfilePlugin.kt | 2 +- 2 files changed, 5 insertions(+), 8 deletions(-) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt index 021dc09932..3a81af67d3 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfileFragment.kt @@ -61,7 +61,7 @@ class LocalProfileFragment : DaggerFragment() { private val save = Runnable { doEdit() basalView?.updateLabel(rh.gs(R.string.basal_label) + ": " + sumLabel()) - localProfilePlugin.profile?.getSpecificProfile(binding.profileList.text.toString())?.let { + localProfilePlugin.getEditedProfile()?.let { binding.basalGraph.show(ProfileSealed.Pure(it)) binding.icGraph.show(ProfileSealed.Pure(it)) binding.isfGraph.show(ProfileSealed.Pure(it)) @@ -81,7 +81,7 @@ class LocalProfileFragment : DaggerFragment() { } private fun sumLabel(): String { - val profile = localProfilePlugin.getEditProfile() + val profile = localProfilePlugin.getEditedProfile() val sum = profile?.let { ProfileSealed.Pure(profile).baseBasalSum() } ?: 0.0 return " ∑" + DecimalFormatter.to2Decimal(sum) + rh.gs(R.string.insulin_unit_shortname) } @@ -237,10 +237,7 @@ class LocalProfileFragment : DaggerFragment() { localProfilePlugin.currentProfileIndex = position localProfilePlugin.isEdited = false build() - }, { - val selection = localProfilePlugin.currentProfileIndex - if (selection in 0 until (binding.profileList.adapter?.count ?: -1)) binding.profileList.setSelection(selection) - } + }, null ) } } else { @@ -248,7 +245,7 @@ class LocalProfileFragment : DaggerFragment() { build() } } - localProfilePlugin.profile?.getSpecificProfile(binding.profileList.text.toString())?.let { + localProfilePlugin.getEditedProfile()?.let { binding.basalGraph.show(ProfileSealed.Pure(it)) binding.icGraph.show(ProfileSealed.Pure(it)) binding.isfGraph.show(ProfileSealed.Pure(it)) diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt index cce7fc55d0..f131a22122 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/profile/local/LocalProfilePlugin.kt @@ -170,7 +170,7 @@ class LocalProfilePlugin @Inject constructor( } @Synchronized - fun getEditProfile(): PureProfile? { + fun getEditedProfile(): PureProfile? { val profile = JSONObject() with(profiles[currentProfileIndex]) { profile.put("dia", dia)