diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt index 651fe0c4ac..d891a89dda 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesFragment.kt @@ -161,7 +161,7 @@ class ObjectivesFragment : DaggerFragment() { holder.accomplished.visibility = View.GONE holder.unFinish.visibility = View.GONE holder.unStart.visibility = View.GONE - if (position == 0 || objectivesPlugin.objectives[position - 1].isAccomplished) + if (position == 0 || objectivesPlugin.allPriorAccomplished(position)) holder.start.visibility = View.VISIBLE else holder.start.visibility = View.GONE diff --git a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt index a5eb85a582..209a74f44a 100644 --- a/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt +++ b/app/src/main/java/info/nightscout/androidaps/plugins/constraints/objectives/ObjectivesPlugin.kt @@ -144,6 +144,14 @@ class ObjectivesPlugin @Inject constructor( } } + fun allPriorAccomplished(position: Int) : Boolean { + var accomplished = true + for (i in 0 until position) { + accomplished = accomplished && objectives[i].isAccomplished + } + return accomplished + } + /** * Constraints interface */