Experimenting

pull/1319/head
Jakub Kalinowski 4 years ago
parent fc1478645b
commit 2523c8e15f

@ -26,7 +26,7 @@ data class Entry(
/** /**
* Value indicating that the habit is not applicable for this timestamp. * Value indicating that the habit is not applicable for this timestamp.
*/ */
const val SKIP = 3 const val SKIP = -3
/** /**
* Value indicating that the user has performed the habit at this timestamp. * Value indicating that the user has performed the habit at this timestamp.

@ -60,19 +60,34 @@ class HistoryCardPresenter(
val timestamp = Timestamp.fromLocalDate(date) val timestamp = Timestamp.fromLocalDate(date)
screen.showFeedback() screen.showFeedback()
if (habit.isNumerical) { if (habit.isNumerical) {
val entries = habit.computedEntries // val entries = habit.computedEntries
val oldValue = entries.get(timestamp).value // val oldValue = entries.get(timestamp).value
screen.showNumberPicker(oldValue / 1000.0, habit.unit) { newValue: Double -> // screen.showNumberPicker(oldValue / 1000.0, habit.unit) { newValue: Double ->
val thousands = (newValue * 1000).roundToInt() // val thousands = (newValue * 1000).roundToInt()
// commandRunner.run(
// CreateRepetitionCommand(
// habitList,
// habit,
// timestamp,
// thousands,
// ),
// )
// }
val currentValue = habit.computedEntries.get(timestamp).value
val nextValue = Entry.nextToggleValue(
value = currentValue,
isSkipEnabled = preferences.isSkipEnabled,
areQuestionMarksEnabled = preferences.areQuestionMarksEnabled
)
commandRunner.run( commandRunner.run(
CreateRepetitionCommand( CreateRepetitionCommand(
habitList, habitList,
habit, habit,
timestamp, timestamp,
thousands, nextValue,
), ),
) )
}
} else { } else {
val currentValue = habit.computedEntries.get(timestamp).value val currentValue = habit.computedEntries.get(timestamp).value
val nextValue = Entry.nextToggleValue( val nextValue = Entry.nextToggleValue(
@ -105,12 +120,25 @@ class HistoryCardPresenter(
val oldest = habit.computedEntries.getKnown().lastOrNull()?.timestamp ?: today val oldest = habit.computedEntries.getKnown().lastOrNull()?.timestamp ?: today
val entries = habit.computedEntries.getByInterval(oldest, today) val entries = habit.computedEntries.getByInterval(oldest, today)
val series = if (habit.isNumerical) { val series = if (habit.isNumerical) {
// entries.map {
// Entry(it.timestamp, max(0, it.value))
// }.map {
// when (it.value) {
// 0 -> HistoryChart.Square.OFF
// else -> HistoryChart.Square.ON
// }
// }
entries.map { entries.map {
Entry(it.timestamp, max(0, it.value)) when {
}.map { it.value == SKIP -> {
when (it.value) { HistoryChart.Square.HATCHED
0 -> HistoryChart.Square.OFF }
else -> HistoryChart.Square.ON it.value > 0 -> {
HistoryChart.Square.ON
}
else -> {
HistoryChart.Square.OFF
}
} }
} }
} else { } else {

Loading…
Cancel
Save