mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 01:08:50 -06:00
Simplify the code
This commit is contained in:
@@ -92,20 +92,12 @@ class ScoreList {
|
||||
}
|
||||
|
||||
var previousValue = 0.0
|
||||
val numericalUnknownDayValue = (targetValue * 2 * 1000) / denominator
|
||||
for (i in values.indices) {
|
||||
val offset = values.size - i - 1
|
||||
if (isNumerical) {
|
||||
if (values[offset] >= 0)
|
||||
rollingSum += values[offset]
|
||||
else if (numericalHabitType == NumericalHabitType.AT_MOST)
|
||||
rollingSum += numericalUnknownDayValue
|
||||
rollingSum += max(0, values[offset])
|
||||
if (offset + denominator < values.size) {
|
||||
if (values[offset + denominator] >= 0) {
|
||||
rollingSum -= values[offset + denominator]
|
||||
} else if (numericalHabitType == NumericalHabitType.AT_MOST) {
|
||||
rollingSum -= numericalUnknownDayValue
|
||||
}
|
||||
rollingSum -= max(0, values[offset + denominator])
|
||||
}
|
||||
|
||||
var percentageCompleted = 0.0
|
||||
|
||||
@@ -115,10 +115,8 @@ class HistoryCardPresenter(
|
||||
}
|
||||
} else {
|
||||
entries.map {
|
||||
if (it.value < 0) habit.targetValue * 2.0 * 1000.0 else it.value / 1000.0
|
||||
}.map {
|
||||
when {
|
||||
it <= habit.targetValue -> HistoryChart.Square.ON
|
||||
max(0, it.value) < 2 * habit.targetValue -> HistoryChart.Square.ON
|
||||
else -> HistoryChart.Square.OFF
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user