Fixing issue with progress values

feature/top10
Laurent 7 years ago
parent 623d6ae38f
commit 86687a59a9
  1. 21
      app/src/main/java/net/pokeranalytics/android/calculus/Report.kt

@ -243,22 +243,31 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
if (this.shouldManageMultiGroupProgressValues) { if (this.shouldManageMultiGroupProgressValues) {
this.group.comparedComputedResults?.let { previousResult -> fun computeProgressValues(computedResults: ComputedResults) {
this.allStats().forEach { computedStat -> this.allStats().forEach { computedStat ->
val stat = computedStat.stat val stat = computedStat.stat
previousResult.computedStat(stat)?.let { previousComputedStat -> computedResults.computedStat(stat)?.let { previousComputedStat ->
when (stat) { when (stat) {
Stat.NET_RESULT, Stat.HOURLY_DURATION, Stat.BB_NET_RESULT, Stat.BB_SESSION_COUNT, Stat.NET_RESULT, Stat.HOURLY_DURATION, Stat.BB_NET_RESULT, Stat.BB_SESSION_COUNT,
Stat.WINNING_SESSION_COUNT, Stat.TOTAL_BUYIN, Stat.HANDS_PLAYED, Stat.NUMBER_OF_GAMES, Stat.NUMBER_OF_SETS -> { Stat.WINNING_SESSION_COUNT, Stat.TOTAL_BUYIN, Stat.HANDS_PLAYED, Stat.NUMBER_OF_GAMES, Stat.NUMBER_OF_SETS -> {
val previousValue = previousComputedStat.progressValue ?: previousComputedStat.value val previousValue = previousComputedStat.progressValue ?: 0.0
computedStat.progressValue = previousValue + computedStat.value computedStat.progressValue = previousValue + computedStat.value
} }
else -> {} else -> {
}
} }
} ?: run { } ?: run {
computedStat.progressValue = computedStat.value computedStat.progressValue = computedStat.value
} }
} }
}
this.group.comparedComputedResults?.let { previousResult ->
computeProgressValues(previousResult)
} ?: run {
computeProgressValues(this)
} }
val netResult = this.computedStat(Stat.NET_RESULT)?.progressValue val netResult = this.computedStat(Stat.NET_RESULT)?.progressValue
@ -377,7 +386,7 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
return DataSetFactory.lineDataSetInstance(entries, stat.name, context) return DataSetFactory.lineDataSetInstance(entries, stat.name, context)
} }
fun barEntries(stat: Stat, context: Context): BarDataSet { private fun barEntries(stat: Stat, context: Context): BarDataSet {
val entries = mutableListOf<BarEntry>() val entries = mutableListOf<BarEntry>()
this._evolutionValues[stat]?.let { points -> this._evolutionValues[stat]?.let { points ->
@ -388,7 +397,7 @@ class ComputedResults(group: ComputableGroup, shouldManageMultiGroupProgressValu
return DataSetFactory.barDataSetInstance(entries, stat.name, context) return DataSetFactory.barDataSetInstance(entries, stat.name, context)
} }
fun distributionEntries(stat: Stat, context: Context): BarDataSet { private fun distributionEntries(stat: Stat, context: Context): BarDataSet {
val colors = mutableListOf<Int>() val colors = mutableListOf<Int>()
val entries = mutableListOf<BarEntry>() val entries = mutableListOf<BarEntry>()

Loading…
Cancel
Save