Skip to content

Commit

Permalink
Profile: fix graphs
Browse files Browse the repository at this point in the history
  • Loading branch information
MilosKozak committed Feb 26, 2022
1 parent fe4fbbf commit bbe6248
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 8 deletions.
Expand Up @@ -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))
Expand All @@ -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)
}
Expand Down Expand Up @@ -237,18 +237,15 @@ 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 {
localProfilePlugin.currentProfileIndex = position
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))
Expand Down
Expand Up @@ -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)
Expand Down

0 comments on commit bbe6248

Please sign in to comment.