mirror of
https://codeberg.org/timelimit/timelimit-android.git
synced 2025-10-04 02:09:19 +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()) {
|
||||
categoriesToCount.forEach { categoryId ->
|
||||
// only handle rules which are related to today
|
||||
val rules = timeLimitRules.get(categoryId).waitForNonNullValue().filter {
|
||||
(it.dayMask.toInt() and (1 shl nowDate.dayOfWeek)) != 0
|
||||
}
|
||||
// only handle rules which are related at today and the current time
|
||||
val rules = RemainingTime.getRulesRelatedToDay(
|
||||
dayOfWeek = nowDate.dayOfWeek,
|
||||
minuteOfDay = minuteOfWeek % MinuteOfDay.LENGTH,
|
||||
rules = timeLimitRules.get(categoryId).waitForNonNullValue()
|
||||
)
|
||||
|
||||
usedTimeUpdateHelper.add(
|
||||
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 {
|
||||
((it.dayMask.toInt() and (1 shl dayOfWeek)) != 0) &&
|
||||
minuteOfDay >= it.startMinuteOfDay && minuteOfDay <= it.endMinuteOfDay
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue