allow start of objective when all previous are finished

This commit is contained in:
Milos Kozak 2020-04-21 10:52:40 +02:00
parent 3d68b28179
commit 8cc51abae9
2 changed files with 9 additions and 1 deletions

View file

@ -161,7 +161,7 @@ class ObjectivesFragment : DaggerFragment() {
holder.accomplished.visibility = View.GONE holder.accomplished.visibility = View.GONE
holder.unFinish.visibility = View.GONE holder.unFinish.visibility = View.GONE
holder.unStart.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 holder.start.visibility = View.VISIBLE
else else
holder.start.visibility = View.GONE holder.start.visibility = View.GONE

View file

@ -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 * Constraints interface
*/ */