mirror of
https://github.com/iSoron/uhabits.git
synced 2025-12-07 01:28:52 -06:00
Remove EntryList
This commit is contained in:
@@ -77,6 +77,7 @@ public class HabitFixtures
|
||||
for (int mark : marks)
|
||||
habit.getOriginalEntries().add(new Entry(today.minus(mark), YES_MANUAL));
|
||||
|
||||
habit.recompute();
|
||||
return habit;
|
||||
}
|
||||
|
||||
@@ -111,6 +112,7 @@ public class HabitFixtures
|
||||
for (int mark : marks)
|
||||
habit.getOriginalEntries().add(new Entry(today.minus(mark), YES_MANUAL));
|
||||
|
||||
habit.recompute();
|
||||
return habit;
|
||||
}
|
||||
|
||||
@@ -132,6 +134,7 @@ public class HabitFixtures
|
||||
timestamp = timestamp.minus(1);
|
||||
}
|
||||
|
||||
habit.recompute();
|
||||
return habit;
|
||||
}
|
||||
|
||||
@@ -150,6 +153,7 @@ public class HabitFixtures
|
||||
timestamp = timestamp.minus(1);
|
||||
}
|
||||
|
||||
habit.recompute();
|
||||
return habit;
|
||||
}
|
||||
|
||||
|
||||
@@ -46,7 +46,7 @@ public class BarChartTest extends BaseViewTest
|
||||
Habit habit = fixtures.createLongNumericalHabit();
|
||||
view = new BarChart(targetContext);
|
||||
Timestamp today = DateUtils.getToday();
|
||||
EntryList entries = habit.getComputedEntries();
|
||||
Entries entries = habit.getComputedEntries();
|
||||
view.setEntries(entries.getByInterval(today.minus(20), today));
|
||||
view.setColor(PaletteUtilsKt.toThemedAndroidColor(habit.getColor(), targetContext));
|
||||
view.setTarget(200.0);
|
||||
|
||||
@@ -43,7 +43,7 @@ class HabitCardViewTest : BaseViewTest() {
|
||||
habit2 = fixtures.createLongNumericalHabit()
|
||||
view = component.getHabitCardViewFactory().create().apply {
|
||||
habit = habit1
|
||||
values = habit1.computedEntries.allValues
|
||||
values = habit1.computedEntries.getAllValues()
|
||||
score = habit1.scores.todayValue
|
||||
isSelected = false
|
||||
buttonCount = 5
|
||||
@@ -70,7 +70,7 @@ class HabitCardViewTest : BaseViewTest() {
|
||||
fun testRender_numerical() {
|
||||
view.apply {
|
||||
habit = habit2
|
||||
values = habit2.computedEntries.allValues
|
||||
values = habit2.computedEntries.getAllValues()
|
||||
}
|
||||
assertRenders(view, "$PATH/render_numerical.png")
|
||||
}
|
||||
|
||||
@@ -45,17 +45,6 @@ public class PerformanceTest extends BaseAndroidTest
|
||||
habit = fixtures.createLongHabit();
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test(timeout = 5000)
|
||||
public void testRepeatedGetTodayValue()
|
||||
{
|
||||
for (int i = 0; i < 100000; i++)
|
||||
{
|
||||
habit.getScores().getTodayValue();
|
||||
habit.getComputedEntries().getTodayValue();
|
||||
}
|
||||
}
|
||||
|
||||
@Ignore
|
||||
@Test(timeout = 5000)
|
||||
public void benchmarkCreateHabitCommand()
|
||||
|
||||
@@ -26,6 +26,7 @@ import androidx.test.filters.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
import org.isoron.uhabits.core.utils.*;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
|
||||
@@ -41,10 +42,12 @@ public class CheckmarkWidgetTest extends BaseViewTest
|
||||
|
||||
private Habit habit;
|
||||
|
||||
private EntryList entries;
|
||||
private Entries entries;
|
||||
|
||||
private FrameLayout view;
|
||||
|
||||
private Timestamp today = DateUtils.getTodayWithOffset();
|
||||
|
||||
@Override
|
||||
public void setUp()
|
||||
{
|
||||
@@ -58,7 +61,7 @@ public class CheckmarkWidgetTest extends BaseViewTest
|
||||
CheckmarkWidget widget = new CheckmarkWidget(targetContext, 0, habit);
|
||||
view = convertToView(widget, 150, 200);
|
||||
|
||||
assertThat(entries.getTodayValue(), equalTo(YES_MANUAL));
|
||||
assertThat(entries.get(today).getValue(), equalTo(YES_MANUAL));
|
||||
}
|
||||
|
||||
@Test
|
||||
@@ -71,11 +74,11 @@ public class CheckmarkWidgetTest extends BaseViewTest
|
||||
// possible to capture intents sent to BroadcastReceivers.
|
||||
button.performClick();
|
||||
sleep(1000);
|
||||
assertThat(entries.getTodayValue(), equalTo(SKIP));
|
||||
assertThat(entries.get(today).getValue(), equalTo(SKIP));
|
||||
|
||||
button.performClick();
|
||||
sleep(1000);
|
||||
assertThat(entries.getTodayValue(), equalTo(NO));
|
||||
assertThat(entries.get(today).getValue(), equalTo(NO));
|
||||
}
|
||||
|
||||
@Test
|
||||
|
||||
@@ -24,6 +24,7 @@ import androidx.test.filters.*;
|
||||
|
||||
import org.isoron.uhabits.*;
|
||||
import org.isoron.uhabits.core.models.*;
|
||||
import org.isoron.uhabits.core.utils.*;
|
||||
import org.isoron.uhabits.utils.*;
|
||||
import org.junit.*;
|
||||
import org.junit.runner.*;
|
||||
@@ -50,9 +51,10 @@ public class CheckmarkWidgetViewTest extends BaseViewTest
|
||||
double score = habit.getScores().getTodayValue();
|
||||
float percentage = (float) score;
|
||||
|
||||
Timestamp today = DateUtils.getTodayWithOffset();
|
||||
view.setActiveColor(PaletteUtils.getAndroidTestColor(0));
|
||||
view.setEntryState(habit.getComputedEntries().getTodayValue());
|
||||
view.setEntryValue(habit.getComputedEntries().getTodayValue());
|
||||
view.setEntryState(habit.getComputedEntries().get(today).getValue());
|
||||
view.setEntryValue(habit.getComputedEntries().get(today).getValue());
|
||||
view.setPercentage(percentage);
|
||||
view.setName(habit.getName());
|
||||
view.refresh();
|
||||
|
||||
@@ -66,6 +66,9 @@ class HabitsApplication : Application() {
|
||||
|
||||
DateUtils.setStartDayOffset(3, 0)
|
||||
|
||||
val habitList = component.habitList
|
||||
for (h in habitList) h.recompute()
|
||||
|
||||
widgetUpdater = component.widgetUpdater
|
||||
widgetUpdater.startListening()
|
||||
widgetUpdater.scheduleStartDayWidgetUpdate()
|
||||
|
||||
@@ -96,9 +96,13 @@ class BarCardPresenter(
|
||||
boolBucketSizes[boolSpinnerPosition]
|
||||
}
|
||||
val entries = if (bucketSize == 1) {
|
||||
habit.computedEntries.all
|
||||
habit.computedEntries.getKnown()
|
||||
} else {
|
||||
habit.computedEntries.groupBy(getTruncateField(bucketSize), firstWeekday)
|
||||
habit.computedEntries.groupBy(
|
||||
field = getTruncateField(bucketSize),
|
||||
firstWeekday = firstWeekday,
|
||||
isNumerical = habit.isNumerical,
|
||||
).map { Entry(it.timestamp, it.value * 1000) }
|
||||
}
|
||||
return BarCardViewModel(
|
||||
entries = entries,
|
||||
|
||||
@@ -66,7 +66,7 @@ class HistoryCardPresenter(
|
||||
val isSkipEnabled: Boolean,
|
||||
) {
|
||||
fun present() = HistoryCardViewModel(
|
||||
entries = habit.computedEntries.allValues,
|
||||
entries = habit.computedEntries.getAllValues(),
|
||||
color = habit.color,
|
||||
firstWeekday = firstWeekday,
|
||||
isNumerical = habit.isNumerical,
|
||||
|
||||
@@ -57,12 +57,13 @@ class TargetCardPresenter(
|
||||
val resources: Resources,
|
||||
) {
|
||||
suspend fun present(): TargetCardViewModel = Dispatchers.IO {
|
||||
val today = DateUtils.getTodayWithOffset()
|
||||
val entries = habit.computedEntries
|
||||
val valueToday = entries.todayValue / 1e3
|
||||
val valueThisWeek = entries.getThisWeekValue(firstWeekday) / 1e3
|
||||
val valueThisMonth = entries.thisMonthValue / 1e3
|
||||
val valueThisQuarter = entries.thisQuarterValue / 1e3
|
||||
val valueThisYear = entries.thisYearValue / 1e3
|
||||
val valueToday = entries.get(today).value / 1e3
|
||||
val valueThisWeek = entries.getThisWeekValue(firstWeekday, habit.isNumerical) / 1e3
|
||||
val valueThisMonth = entries.getThisMonthValue(habit.isNumerical) / 1e3
|
||||
val valueThisQuarter = entries.getThisQuarterValue(habit.isNumerical) / 1e3
|
||||
val valueThisYear = entries.getThisYearValue(habit.isNumerical) / 1e3
|
||||
|
||||
val cal = DateUtils.getStartOfTodayCalendarWithOffset()
|
||||
val daysInMonth = cal.getActualMaximum(Calendar.DAY_OF_MONTH)
|
||||
|
||||
@@ -23,6 +23,7 @@ import android.app.*
|
||||
import android.content.*
|
||||
import android.view.*
|
||||
import org.isoron.uhabits.core.models.*
|
||||
import org.isoron.uhabits.core.utils.*
|
||||
import org.isoron.uhabits.utils.*
|
||||
import org.isoron.uhabits.widgets.views.*
|
||||
|
||||
@@ -42,16 +43,16 @@ open class CheckmarkWidget(
|
||||
|
||||
override fun refreshData(v: View) {
|
||||
(v as CheckmarkWidgetView).apply {
|
||||
val today = DateUtils.getTodayWithOffset()
|
||||
setBackgroundAlpha(preferedBackgroundAlpha)
|
||||
|
||||
setActiveColor(habit.color.toThemedAndroidColor(context))
|
||||
setName(habit.name)
|
||||
setEntryValue(habit.computedEntries.todayValue)
|
||||
setEntryValue(habit.computedEntries.get(today).value)
|
||||
if (habit.isNumerical) {
|
||||
setNumerical(true)
|
||||
setEntryState(getNumericalEntryState())
|
||||
} else {
|
||||
setEntryState(habit.computedEntries.todayValue)
|
||||
setEntryState(habit.computedEntries.get(today).value)
|
||||
}
|
||||
setPercentage(habit.scores.todayValue.toFloat())
|
||||
refresh()
|
||||
|
||||
@@ -46,7 +46,7 @@ class HistoryWidget(
|
||||
setFirstWeekday(firstWeekday)
|
||||
setSkipEnabled(prefs.isSkipEnabled)
|
||||
setColor(habit.color.toThemedAndroidColor(context))
|
||||
setEntries(habit.computedEntries.allValues)
|
||||
setEntries(habit.computedEntries.getAllValues())
|
||||
setNumerical(habit.isNumerical)
|
||||
setTarget(habit.targetValue / habit.frequency.denominator)
|
||||
}
|
||||
|
||||
@@ -29,6 +29,7 @@ import org.isoron.uhabits.activities.*
|
||||
import org.isoron.uhabits.activities.common.dialogs.*
|
||||
import org.isoron.uhabits.core.ui.screens.habits.list.*
|
||||
import org.isoron.uhabits.core.ui.widgets.*
|
||||
import org.isoron.uhabits.core.utils.*
|
||||
import org.isoron.uhabits.intents.*
|
||||
import org.isoron.uhabits.utils.*
|
||||
import org.isoron.uhabits.widgets.*
|
||||
@@ -71,7 +72,9 @@ class NumericalCheckmarkWidgetActivity : Activity(), ListHabitsBehavior.NumberPi
|
||||
val app = this.applicationContext as HabitsApplication
|
||||
AndroidThemeSwitcher(this, app.component.preferences).apply()
|
||||
val numberPickerFactory = NumberPickerFactory(context)
|
||||
numberPickerFactory.create(data.habit.computedEntries.today!!.value.toDouble() / 1000,
|
||||
val today = DateUtils.getTodayWithOffset()
|
||||
val entry = data.habit.computedEntries.get(today)
|
||||
numberPickerFactory.create(entry.value / 1000.0,
|
||||
data.habit.unit,
|
||||
this).show()
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user