mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 09:38:52 -06:00
Replace RepetitionList by Entries
This commit is contained in:
@@ -75,7 +75,7 @@ public class HabitFixtures
|
||||
81, 83, 89, 90, 91, 95, 102, 103, 108, 109, 120};
|
||||
|
||||
for (int mark : marks)
|
||||
habit.getOriginalEntries().setValue(today.minus(mark), YES_MANUAL);
|
||||
habit.getOriginalEntries().add(new Entry(today.minus(mark), YES_MANUAL));
|
||||
|
||||
return habit;
|
||||
}
|
||||
@@ -109,7 +109,7 @@ public class HabitFixtures
|
||||
582, 583, 584, 586, 589};
|
||||
|
||||
for (int mark : marks)
|
||||
habit.getOriginalEntries().setValue(today.minus(mark), YES_MANUAL);
|
||||
habit.getOriginalEntries().add(new Entry(today.minus(mark), YES_MANUAL));
|
||||
|
||||
return habit;
|
||||
}
|
||||
@@ -128,7 +128,7 @@ public class HabitFixtures
|
||||
Timestamp timestamp = DateUtils.getToday();
|
||||
for (int value : LONG_NUMERICAL_HABIT_ENTRIES)
|
||||
{
|
||||
habit.getOriginalEntries().setValue(timestamp, value);
|
||||
habit.getOriginalEntries().add(new Entry(timestamp, value));
|
||||
timestamp = timestamp.minus(1);
|
||||
}
|
||||
|
||||
@@ -146,7 +146,7 @@ public class HabitFixtures
|
||||
Timestamp timestamp = DateUtils.getToday();
|
||||
for (boolean c : LONG_HABIT_ENTRIES)
|
||||
{
|
||||
if (c) habit.getOriginalEntries().setValue(timestamp, YES_MANUAL);
|
||||
if (c) habit.getOriginalEntries().add(new Entry(timestamp, YES_MANUAL));
|
||||
timestamp = timestamp.minus(1);
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,9 @@ public class FrequencyChartTest extends BaseViewTest
|
||||
Habit habit = fixtures.createLongHabit();
|
||||
|
||||
view = new FrequencyChart(targetContext);
|
||||
view.setFrequency(habit.getOriginalEntries().getWeekdayFrequency());
|
||||
view.setFrequency(habit.getOriginalEntries().computeWeekdayFrequency(
|
||||
habit.isNumerical()
|
||||
));
|
||||
view.setColor(PaletteUtilsKt.toFixedAndroidColor(habit.getColor()));
|
||||
measureView(view, dpToPixels(300), dpToPixels(100));
|
||||
}
|
||||
|
||||
@@ -52,7 +52,9 @@ class FrequencyCardPresenter(
|
||||
) {
|
||||
fun present() = FrequencyCardViewModel(
|
||||
color = habit.color,
|
||||
frequency = habit.originalEntries.weekdayFrequency,
|
||||
frequency = habit.originalEntries.computeWeekdayFrequency(
|
||||
isNumerical = habit.isNumerical
|
||||
),
|
||||
firstWeekday = firstWeekday,
|
||||
)
|
||||
}
|
||||
@@ -25,6 +25,7 @@ import android.widget.*
|
||||
import kotlinx.coroutines.*
|
||||
import org.isoron.uhabits.*
|
||||
import org.isoron.uhabits.core.models.*
|
||||
import org.isoron.uhabits.core.models.Entry.Companion.YES_MANUAL
|
||||
import org.isoron.uhabits.core.utils.*
|
||||
import org.isoron.uhabits.databinding.*
|
||||
import org.isoron.uhabits.utils.*
|
||||
@@ -74,12 +75,16 @@ class OverviewCardPresenter(val habit: Habit) {
|
||||
val scoreToday = scores.todayValue.toFloat()
|
||||
val scoreLastMonth = scores.getValue(lastMonth).toFloat()
|
||||
val scoreLastYear = scores.getValue(lastYear).toFloat()
|
||||
val totalCount = habit.originalEntries.getKnown()
|
||||
.filter { it.value == YES_MANUAL }
|
||||
.count()
|
||||
.toLong()
|
||||
return@IO OverviewCardViewModel(
|
||||
color = habit.color,
|
||||
scoreToday = scoreToday,
|
||||
scoreMonthDiff = scoreToday - scoreLastMonth,
|
||||
scoreYearDiff = scoreToday - scoreLastYear,
|
||||
totalCount = habit.originalEntries.totalCount,
|
||||
totalCount = totalCount,
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -44,7 +44,7 @@ class FrequencyWidget(
|
||||
(widgetView.dataView as FrequencyChart).apply {
|
||||
setFirstWeekday(firstWeekday)
|
||||
setColor(habit.color.toThemedAndroidColor(context))
|
||||
setFrequency(habit.originalEntries.weekdayFrequency)
|
||||
setFrequency(habit.originalEntries.computeWeekdayFrequency(habit.isNumerical))
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user