mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-04 18:29:27 +02:00
Fix counting time for inactive slots
This commit is contained in:
parent
a0a1c20e10
commit
a638b35dd2
2 changed files with 7 additions and 5 deletions
|
@ -502,10 +502,12 @@ class BackgroundTaskLogic(val appLogic: AppLogic) {
|
||||||
|
|
||||||
if (categoriesToCount.isNotEmpty()) {
|
if (categoriesToCount.isNotEmpty()) {
|
||||||
categoriesToCount.forEach { categoryId ->
|
categoriesToCount.forEach { categoryId ->
|
||||||
// only handle rules which are related to today
|
// only handle rules which are related at today and the current time
|
||||||
val rules = timeLimitRules.get(categoryId).waitForNonNullValue().filter {
|
val rules = RemainingTime.getRulesRelatedToDay(
|
||||||
(it.dayMask.toInt() and (1 shl nowDate.dayOfWeek)) != 0
|
dayOfWeek = nowDate.dayOfWeek,
|
||||||
}
|
minuteOfDay = minuteOfWeek % MinuteOfDay.LENGTH,
|
||||||
|
rules = timeLimitRules.get(categoryId).waitForNonNullValue()
|
||||||
|
)
|
||||||
|
|
||||||
usedTimeUpdateHelper.add(
|
usedTimeUpdateHelper.add(
|
||||||
categoryId = categoryId,
|
categoryId = categoryId,
|
||||||
|
|
|
@ -44,7 +44,7 @@ data class RemainingTime(val includingExtraTime: Long, val default: Long) {
|
||||||
)
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
private fun getRulesRelatedToDay(dayOfWeek: Int, minuteOfDay: Int, rules: List<TimeLimitRule>): List<TimeLimitRule> {
|
fun getRulesRelatedToDay(dayOfWeek: Int, minuteOfDay: Int, rules: List<TimeLimitRule>): List<TimeLimitRule> {
|
||||||
return rules.filter {
|
return rules.filter {
|
||||||
((it.dayMask.toInt() and (1 shl dayOfWeek)) != 0) &&
|
((it.dayMask.toInt() and (1 shl dayOfWeek)) != 0) &&
|
||||||
minuteOfDay >= it.startMinuteOfDay && minuteOfDay <= it.endMinuteOfDay
|
minuteOfDay >= it.startMinuteOfDay && minuteOfDay <= it.endMinuteOfDay
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue