mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 09:38:52 -06:00
Make skips equivalent to implicit checks; make their visual representation consistent
This commit is contained in:
@@ -100,14 +100,19 @@ public abstract class CheckmarkList
|
||||
static ArrayList<Interval> buildIntervals(@NonNull Frequency freq,
|
||||
@NonNull Repetition[] reps)
|
||||
{
|
||||
ArrayList<Repetition> filteredReps = new ArrayList<>();
|
||||
for (Repetition r : reps)
|
||||
if (r.getValue() == CHECKED_EXPLICITLY)
|
||||
filteredReps.add(r);
|
||||
|
||||
int num = freq.getNumerator();
|
||||
int den = freq.getDenominator();
|
||||
|
||||
ArrayList<Interval> intervals = new ArrayList<>();
|
||||
for (int i = 0; i < reps.length - num + 1; i++)
|
||||
for (int i = 0; i < filteredReps.size() - num + 1; i++)
|
||||
{
|
||||
Repetition first = reps[i];
|
||||
Repetition last = reps[i + num - 1];
|
||||
Repetition first = filteredReps.get(i);
|
||||
Repetition last = filteredReps.get(i + num - 1);
|
||||
|
||||
long distance = first.getTimestamp().daysUntil(last.getTimestamp());
|
||||
if (distance >= den) continue;
|
||||
|
||||
@@ -176,6 +176,25 @@ public class CheckmarkListTest extends BaseUnitTest
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
|
||||
@Test
|
||||
public void test_buildIntervals_4() throws Exception
|
||||
{
|
||||
Repetition[] reps = new Repetition[]{
|
||||
new Repetition(day(30), CHECKED_EXPLICITLY),
|
||||
new Repetition(day(20), SKIPPED),
|
||||
new Repetition(day(10), CHECKED_EXPLICITLY),
|
||||
};
|
||||
|
||||
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new CheckmarkList.Interval(day(30), day(30), day(28)));
|
||||
expected.add(new CheckmarkList.Interval(day(10), day(10), day(8)));
|
||||
|
||||
ArrayList<CheckmarkList.Interval> actual;
|
||||
actual = CheckmarkList.buildIntervals(new Frequency(1, 3), reps);
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_getAllValues_moveBackwardsInTime()
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user