Resolving comments

pull/1319/head
Jakub Kalinowski 4 years ago
parent 9ee9427bfd
commit 5d25b236f7

@ -183,16 +183,16 @@ class NumberButtonView(
val textSize: Float
when {
value >= 0 -> {
label = value.toShortString()
typeface = BOLD_TYPEFACE
textSize = dim(R.dimen.smallTextSize)
}
value == Entry.SKIP.toDouble() / 1000 -> {
label = resources.getString(R.string.fa_skipped)
textSize = dim(R.dimen.smallTextSize)
typeface = getFontAwesome()
}
value >= 0 -> {
label = value.toShortString()
typeface = BOLD_TYPEFACE
textSize = dim(R.dimen.smallTextSize)
}
preferences.areQuestionMarksEnabled -> {
label = resources.getString(R.string.fa_question)
typeface = getFontAwesome()

@ -276,7 +276,7 @@ open class EntryList {
* For numerical habits, non-positive entry values are converted to zero. For boolean habits, each
* YES_MANUAL value is converted to 1000 and all other values are converted to zero.
*
* SKIP values are treated converted to zero (if they weren't, each SKIP day would count as 0.003).
* SKIP values are converted to zero (if they weren't, each SKIP day would count as 0.003).
*
* The returned list is sorted by timestamp, with the newest entry coming first and the oldest entry
* coming last. If the original list has gaps in it (for example, weeks or months without any
@ -311,12 +311,11 @@ fun List<Entry>.groupedSum(
}
/**
* Counts the number of days with vaLue SKIP in the given perio
* Counts the number of days with vaLue SKIP in the given period.
*/
fun List<Entry>.countSkippedDays(
truncateField: DateUtils.TruncateField,
firstWeekday: Int = Calendar.SATURDAY,
isNumerical: Boolean,
firstWeekday: Int = Calendar.SATURDAY
): List<Entry> {
return this.map { (timestamp, value) ->
if (value == SKIP) {

@ -53,8 +53,7 @@ class TargetCardPresenter {
).firstOrNull()?.value ?: 0
val skippedDayToday = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.DAY,
isNumerical = habit.isNumerical
truncateField = DateUtils.TruncateField.DAY
).firstOrNull()?.value ?: 0
val valueThisWeek = entries.groupedSum(
@ -65,8 +64,7 @@ class TargetCardPresenter {
val skippedDaysThisWeek = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.WEEK_NUMBER,
firstWeekday = firstWeekday,
isNumerical = habit.isNumerical
firstWeekday = firstWeekday
).firstOrNull()?.value ?: 0
val valueThisMonth = entries.groupedSum(
@ -76,7 +74,6 @@ class TargetCardPresenter {
val skippedDaysThisMonth = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.MONTH,
isNumerical = habit.isNumerical
).firstOrNull()?.value ?: 0
val valueThisQuarter = entries.groupedSum(
@ -85,8 +82,7 @@ class TargetCardPresenter {
).firstOrNull()?.value ?: 0
val skippedDaysThisQuarter = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.QUARTER,
isNumerical = habit.isNumerical
truncateField = DateUtils.TruncateField.QUARTER
).firstOrNull()?.value ?: 0
val valueThisYear = entries.groupedSum(
@ -95,8 +91,7 @@ class TargetCardPresenter {
).firstOrNull()?.value ?: 0
val skippedDaysThisYear = entries.countSkippedDays(
truncateField = DateUtils.TruncateField.YEAR,
isNumerical = habit.isNumerical
truncateField = DateUtils.TruncateField.YEAR
).firstOrNull()?.value ?: 0
val cal = DateUtils.getStartOfTodayCalendarWithOffset()

Loading…
Cancel
Save