Remove EntryList

This commit is contained in:
2020-12-26 11:54:05 -06:00
parent 2e19fee83c
commit 78f31a65d4
33 changed files with 220 additions and 624 deletions

View File

@@ -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()

View File

@@ -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,

View File

@@ -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,

View File

@@ -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)

View File

@@ -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()

View File

@@ -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)
}

View File

@@ -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()
}