mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-06 09:08:52 -06:00
Rename CheckmarkList to EntryList
This commit is contained in:
@@ -46,7 +46,7 @@ public class BarChartTest extends BaseViewTest
|
||||
Habit habit = fixtures.createLongNumericalHabit();
|
||||
view = new BarChart(targetContext);
|
||||
Timestamp today = DateUtils.getToday();
|
||||
CheckmarkList entries = habit.getComputedEntries();
|
||||
EntryList entries = habit.getComputedEntries();
|
||||
view.setEntries(entries.getByInterval(today.minus(20), today));
|
||||
view.setColor(PaletteUtilsKt.toThemedAndroidColor(habit.getColor(), targetContext));
|
||||
view.setTarget(200.0);
|
||||
|
||||
@@ -41,7 +41,7 @@ public class CheckmarkWidgetTest extends BaseViewTest
|
||||
|
||||
private Habit habit;
|
||||
|
||||
private CheckmarkList entries;
|
||||
private EntryList entries;
|
||||
|
||||
private FrameLayout view;
|
||||
|
||||
|
||||
@@ -126,7 +126,7 @@ public class HabitsCSVExporter
|
||||
generateDirs.add(habitDirName);
|
||||
|
||||
writeScores(habitDirName, h.getScores());
|
||||
writeCheckmarks(habitDirName, h.getComputedEntries());
|
||||
writeEntries(habitDirName, h.getComputedEntries());
|
||||
}
|
||||
|
||||
writeMultipleHabits();
|
||||
@@ -142,13 +142,13 @@ public class HabitsCSVExporter
|
||||
out.close();
|
||||
}
|
||||
|
||||
private void writeCheckmarks(String habitDirName, CheckmarkList checkmarks)
|
||||
private void writeEntries(String habitDirName, EntryList entries)
|
||||
throws IOException
|
||||
{
|
||||
String filename = habitDirName + "Checkmarks.csv";
|
||||
FileWriter out = new FileWriter(exportDirName + filename);
|
||||
generateFilenames.add(filename);
|
||||
checkmarks.writeCSV(out);
|
||||
entries.writeCSV(out);
|
||||
out.close();
|
||||
}
|
||||
|
||||
|
||||
@@ -37,13 +37,13 @@ import static org.isoron.uhabits.core.utils.StringUtils.defaultToStringStyle;
|
||||
* The collection of {@link Entry}s belonging to a habit.
|
||||
*/
|
||||
@ThreadSafe
|
||||
public abstract class CheckmarkList
|
||||
public abstract class EntryList
|
||||
{
|
||||
protected final Habit habit;
|
||||
|
||||
public final ModelObservable observable;
|
||||
|
||||
public CheckmarkList(Habit habit)
|
||||
public EntryList(Habit habit)
|
||||
{
|
||||
this.habit = habit;
|
||||
this.observable = new ModelObservable();
|
||||
@@ -64,7 +64,7 @@ public class Habit
|
||||
private RepetitionList repetitions;
|
||||
|
||||
@NonNull
|
||||
private CheckmarkList checkmarks;
|
||||
private EntryList computedEntries;
|
||||
|
||||
private ModelObservable observable = new ModelObservable();
|
||||
|
||||
@@ -78,7 +78,7 @@ public class Habit
|
||||
Habit(@NonNull ModelFactory factory)
|
||||
{
|
||||
this.data = new HabitData();
|
||||
checkmarks = factory.buildCheckmarkList(this);
|
||||
computedEntries = factory.buildEntryList(this);
|
||||
streaks = factory.buildStreakList(this);
|
||||
scores = factory.buildScoreList(this);
|
||||
repetitions = factory.buildRepetitionList(this);
|
||||
@@ -87,7 +87,7 @@ public class Habit
|
||||
Habit(@NonNull ModelFactory factory, @NonNull HabitData data)
|
||||
{
|
||||
this.data = new HabitData(data);
|
||||
checkmarks = factory.buildCheckmarkList(this);
|
||||
computedEntries = factory.buildEntryList(this);
|
||||
streaks = factory.buildStreakList(this);
|
||||
scores = factory.buildScoreList(this);
|
||||
repetitions = factory.buildRepetitionList(this);
|
||||
@@ -115,9 +115,9 @@ public class Habit
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public synchronized CheckmarkList getComputedEntries()
|
||||
public synchronized EntryList getComputedEntries()
|
||||
{
|
||||
return checkmarks;
|
||||
return computedEntries;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
|
||||
@@ -28,7 +28,7 @@ import org.isoron.uhabits.core.models.sqlite.records.*;
|
||||
*/
|
||||
public interface ModelFactory
|
||||
{
|
||||
CheckmarkList buildCheckmarkList(Habit habit);
|
||||
EntryList buildEntryList(Habit habit);
|
||||
|
||||
default Habit buildHabit()
|
||||
{
|
||||
|
||||
@@ -26,13 +26,13 @@ import org.isoron.uhabits.core.models.*;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* In-memory implementation of {@link CheckmarkList}.
|
||||
* In-memory implementation of {@link EntryList}.
|
||||
*/
|
||||
public class MemoryCheckmarkList extends CheckmarkList
|
||||
public class MemoryEntryList extends EntryList
|
||||
{
|
||||
ArrayList<Entry> list;
|
||||
|
||||
public MemoryCheckmarkList(Habit habit)
|
||||
public MemoryEntryList(Habit habit)
|
||||
{
|
||||
super(habit);
|
||||
list = new ArrayList<>();
|
||||
@@ -26,9 +26,9 @@ import org.isoron.uhabits.core.models.sqlite.records.*;
|
||||
public class MemoryModelFactory implements ModelFactory
|
||||
{
|
||||
@Override
|
||||
public CheckmarkList buildCheckmarkList(Habit habit)
|
||||
public EntryList buildEntryList(Habit habit)
|
||||
{
|
||||
return new MemoryCheckmarkList(habit);
|
||||
return new MemoryEntryList(habit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -42,9 +42,9 @@ public class SQLModelFactory implements ModelFactory
|
||||
}
|
||||
|
||||
@Override
|
||||
public CheckmarkList buildCheckmarkList(Habit habit)
|
||||
public EntryList buildEntryList(Habit habit)
|
||||
{
|
||||
return new MemoryCheckmarkList(habit);
|
||||
return new MemoryEntryList(habit);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -82,7 +82,7 @@ public class ListHabitsBehavior
|
||||
|
||||
public void onEdit(@NonNull Habit habit, Timestamp timestamp)
|
||||
{
|
||||
CheckmarkList entries = habit.getComputedEntries();
|
||||
EntryList entries = habit.getComputedEntries();
|
||||
double oldValue = entries.getValues(timestamp, timestamp)[0];
|
||||
|
||||
screen.showNumberPicker(oldValue / 1000, habit.getUnit(), newValue ->
|
||||
|
||||
@@ -74,10 +74,10 @@ public class EntryListTest extends BaseUnitTest
|
||||
new Entry(day(1), YES_MANUAL),
|
||||
};
|
||||
|
||||
ArrayList<CheckmarkList.Interval> intervals = new ArrayList<>();
|
||||
intervals.add(new CheckmarkList.Interval(day(10), day(8), day(8)));
|
||||
intervals.add(new CheckmarkList.Interval(day(6), day(5), day(4)));
|
||||
intervals.add(new CheckmarkList.Interval(day(2), day(2), day(1)));
|
||||
ArrayList<EntryList.Interval> intervals = new ArrayList<>();
|
||||
intervals.add(new EntryList.Interval(day(10), day(8), day(8)));
|
||||
intervals.add(new EntryList.Interval(day(6), day(5), day(4)));
|
||||
intervals.add(new EntryList.Interval(day(2), day(2), day(1)));
|
||||
|
||||
List<Entry> expected = new ArrayList<>();
|
||||
expected.add(new Entry(day(0), UNKNOWN));
|
||||
@@ -93,7 +93,7 @@ public class EntryListTest extends BaseUnitTest
|
||||
expected.add(new Entry(day(10), YES_MANUAL));
|
||||
|
||||
List<Entry> actual =
|
||||
CheckmarkList.buildEntriesFromInterval(entries, intervals);
|
||||
EntryList.buildEntriesFromInterval(entries, intervals);
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
@@ -104,14 +104,14 @@ public class EntryListTest extends BaseUnitTest
|
||||
new Entry(day(0), YES_MANUAL),
|
||||
};
|
||||
|
||||
ArrayList<CheckmarkList.Interval> intervals = new ArrayList<>();
|
||||
intervals.add(new CheckmarkList.Interval(day(0), day(0), day(-10)));
|
||||
ArrayList<EntryList.Interval> intervals = new ArrayList<>();
|
||||
intervals.add(new EntryList.Interval(day(0), day(0), day(-10)));
|
||||
|
||||
List<Entry> expected = new ArrayList<>();
|
||||
expected.add(new Entry(day(0), YES_MANUAL));
|
||||
|
||||
List<Entry> actual =
|
||||
CheckmarkList.buildEntriesFromInterval(entries, intervals);
|
||||
EntryList.buildEntriesFromInterval(entries, intervals);
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
@@ -124,13 +124,13 @@ public class EntryListTest extends BaseUnitTest
|
||||
new Entry(day(8), YES_MANUAL),
|
||||
};
|
||||
|
||||
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new CheckmarkList.Interval(day(23), day(23), day(17)));
|
||||
expected.add(new CheckmarkList.Interval(day(18), day(18), day(12)));
|
||||
expected.add(new CheckmarkList.Interval(day(8), day(8), day(2)));
|
||||
ArrayList<EntryList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new EntryList.Interval(day(23), day(23), day(17)));
|
||||
expected.add(new EntryList.Interval(day(18), day(18), day(12)));
|
||||
expected.add(new EntryList.Interval(day(8), day(8), day(2)));
|
||||
|
||||
ArrayList<CheckmarkList.Interval> actual;
|
||||
actual = CheckmarkList.buildIntervals(Frequency.WEEKLY, entries);
|
||||
ArrayList<EntryList.Interval> actual;
|
||||
actual = EntryList.buildIntervals(Frequency.WEEKLY, entries);
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
@@ -143,13 +143,13 @@ public class EntryListTest extends BaseUnitTest
|
||||
new Entry(day(8), YES_MANUAL),
|
||||
};
|
||||
|
||||
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new CheckmarkList.Interval(day(23), day(23), day(23)));
|
||||
expected.add(new CheckmarkList.Interval(day(18), day(18), day(18)));
|
||||
expected.add(new CheckmarkList.Interval(day(8), day(8), day(8)));
|
||||
ArrayList<EntryList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new EntryList.Interval(day(23), day(23), day(23)));
|
||||
expected.add(new EntryList.Interval(day(18), day(18), day(18)));
|
||||
expected.add(new EntryList.Interval(day(8), day(8), day(8)));
|
||||
|
||||
ArrayList<CheckmarkList.Interval> actual;
|
||||
actual = CheckmarkList.buildIntervals(Frequency.DAILY, entries);
|
||||
ArrayList<EntryList.Interval> actual;
|
||||
actual = EntryList.buildIntervals(Frequency.DAILY, entries);
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
@@ -164,14 +164,14 @@ public class EntryListTest extends BaseUnitTest
|
||||
new Entry(day(8), YES_MANUAL),
|
||||
};
|
||||
|
||||
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new CheckmarkList.Interval(day(23), day(22), day(17)));
|
||||
expected.add(new CheckmarkList.Interval(day(22), day(18), day(16)));
|
||||
expected.add(new CheckmarkList.Interval(day(18), day(15), day(12)));
|
||||
ArrayList<EntryList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new EntryList.Interval(day(23), day(22), day(17)));
|
||||
expected.add(new EntryList.Interval(day(22), day(18), day(16)));
|
||||
expected.add(new EntryList.Interval(day(18), day(15), day(12)));
|
||||
|
||||
ArrayList<CheckmarkList.Interval> actual;
|
||||
ArrayList<EntryList.Interval> actual;
|
||||
actual =
|
||||
CheckmarkList.buildIntervals(Frequency.TWO_TIMES_PER_WEEK, entries);
|
||||
EntryList.buildIntervals(Frequency.TWO_TIMES_PER_WEEK, entries);
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
@@ -185,12 +185,12 @@ public class EntryListTest extends BaseUnitTest
|
||||
new Entry(day(10), YES_MANUAL),
|
||||
};
|
||||
|
||||
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<EntryList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new EntryList.Interval(day(30), day(30), day(28)));
|
||||
expected.add(new EntryList.Interval(day(10), day(10), day(8)));
|
||||
|
||||
ArrayList<CheckmarkList.Interval> actual;
|
||||
actual = CheckmarkList.buildIntervals(new Frequency(1, 3), entries);
|
||||
ArrayList<EntryList.Interval> actual;
|
||||
actual = EntryList.buildIntervals(new Frequency(1, 3), entries);
|
||||
assertThat(actual, equalTo(expected));
|
||||
}
|
||||
|
||||
@@ -273,7 +273,7 @@ public class EntryListTest extends BaseUnitTest
|
||||
@Test
|
||||
public void test_getByInterval_withNumericalHabits() throws Exception
|
||||
{
|
||||
CheckmarkList entries = numericalHabit.getComputedEntries();
|
||||
EntryList entries = numericalHabit.getComputedEntries();
|
||||
|
||||
List<Entry> expected =
|
||||
Arrays.asList(new Entry(day(1), 200), new Entry(day(2), 0),
|
||||
@@ -287,7 +287,7 @@ public class EntryListTest extends BaseUnitTest
|
||||
@Test
|
||||
public void test_getTodayValue()
|
||||
{
|
||||
CheckmarkList entries = nonDailyHabit.getComputedEntries();
|
||||
EntryList entries = nonDailyHabit.getComputedEntries();
|
||||
|
||||
travelInTime(-1);
|
||||
assertThat(entries.getTodayValue(), equalTo(NO));
|
||||
@@ -335,34 +335,34 @@ public class EntryListTest extends BaseUnitTest
|
||||
@Test
|
||||
public void test_snapIntervalsTogether_1() throws Exception
|
||||
{
|
||||
ArrayList<CheckmarkList.Interval> original = new ArrayList<>();
|
||||
original.add(new CheckmarkList.Interval(day(27), day(27), day(21)));
|
||||
original.add(new CheckmarkList.Interval(day(20), day(20), day(14)));
|
||||
original.add(new CheckmarkList.Interval(day(12), day(12), day(6)));
|
||||
original.add(new CheckmarkList.Interval(day(8), day(8), day(2)));
|
||||
ArrayList<EntryList.Interval> original = new ArrayList<>();
|
||||
original.add(new EntryList.Interval(day(27), day(27), day(21)));
|
||||
original.add(new EntryList.Interval(day(20), day(20), day(14)));
|
||||
original.add(new EntryList.Interval(day(12), day(12), day(6)));
|
||||
original.add(new EntryList.Interval(day(8), day(8), day(2)));
|
||||
|
||||
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new CheckmarkList.Interval(day(29), day(27), day(23)));
|
||||
expected.add(new CheckmarkList.Interval(day(22), day(20), day(16)));
|
||||
expected.add(new CheckmarkList.Interval(day(15), day(12), day(9)));
|
||||
expected.add(new CheckmarkList.Interval(day(8), day(8), day(2)));
|
||||
ArrayList<EntryList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new EntryList.Interval(day(29), day(27), day(23)));
|
||||
expected.add(new EntryList.Interval(day(22), day(20), day(16)));
|
||||
expected.add(new EntryList.Interval(day(15), day(12), day(9)));
|
||||
expected.add(new EntryList.Interval(day(8), day(8), day(2)));
|
||||
|
||||
CheckmarkList.snapIntervalsTogether(original);
|
||||
EntryList.snapIntervalsTogether(original);
|
||||
assertThat(original, equalTo(expected));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void test_snapIntervalsTogether_2() throws Exception
|
||||
{
|
||||
ArrayList<CheckmarkList.Interval> original = new ArrayList<>();
|
||||
original.add(new CheckmarkList.Interval(day(11), day(8), day(5)));
|
||||
original.add(new CheckmarkList.Interval(day(6), day(4), day(0)));
|
||||
ArrayList<EntryList.Interval> original = new ArrayList<>();
|
||||
original.add(new EntryList.Interval(day(11), day(8), day(5)));
|
||||
original.add(new EntryList.Interval(day(6), day(4), day(0)));
|
||||
|
||||
ArrayList<CheckmarkList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new CheckmarkList.Interval(day(13), day(8), day(7)));
|
||||
expected.add(new CheckmarkList.Interval(day(6), day(4), day(0)));
|
||||
ArrayList<EntryList.Interval> expected = new ArrayList<>();
|
||||
expected.add(new EntryList.Interval(day(13), day(8), day(7)));
|
||||
expected.add(new EntryList.Interval(day(6), day(4), day(0)));
|
||||
|
||||
CheckmarkList.snapIntervalsTogether(original);
|
||||
EntryList.snapIntervalsTogether(original);
|
||||
assertThat(original, equalTo(expected));
|
||||
}
|
||||
|
||||
@@ -397,14 +397,14 @@ public class EntryListTest extends BaseUnitTest
|
||||
{
|
||||
EqualsVerifier.forClass(Entry.class).verify();
|
||||
EqualsVerifier.forClass(Timestamp.class).verify();
|
||||
EqualsVerifier.forClass(CheckmarkList.Interval.class).verify();
|
||||
EqualsVerifier.forClass(EntryList.Interval.class).verify();
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testGroupBy() throws Exception
|
||||
{
|
||||
Habit habit = fixtures.createLongNumericalHabit(timestamp(2014, JUNE, 1));
|
||||
CheckmarkList entries = habit.getComputedEntries();
|
||||
EntryList entries = habit.getComputedEntries();
|
||||
|
||||
List<Entry> byMonth = entries.groupBy(MONTH, Calendar.SATURDAY);
|
||||
assertThat(byMonth.size(), equalTo(25)); // from 2013-01-01 to 2015-01-01
|
||||
@@ -430,7 +430,7 @@ public class EntryListTest extends BaseUnitTest
|
||||
public void testGetTodayValue() throws Exception
|
||||
{
|
||||
Habit habit = fixtures.createLongNumericalHabit(timestamp(2014, JUNE, 1));
|
||||
CheckmarkList checkmarks = habit.getComputedEntries();
|
||||
EntryList checkmarks = habit.getComputedEntries();
|
||||
|
||||
DateUtils.setFixedLocalTime(unixTime(2050, MAY, 1));
|
||||
assertThat(checkmarks.getTodayValue(), equalTo(0));
|
||||
|
||||
Reference in New Issue
Block a user