Optimize background Workers, remove redundant JobServices

1. Adapt the location callback in WeatherWorker to coroutines
2. Merge EventListenerJob into UpdateCalendarWorker
3. Remove BatteryListenerJob, as it's impossible to use Jobs to detect battery status
This commit is contained in:
azuo
2021-10-07 16:03:07 +08:00
parent 388653f62b
commit d8e204c5d9
13 changed files with 123 additions and 168 deletions

View File

@ -42,12 +42,12 @@ class WeatherReceiver : BroadcastReceiver() {
5 -> 60L * 24
else -> 60
}
WeatherWorker.enqueue(context, interval, TimeUnit.MINUTES)
WeatherWorker.enqueuePeriodic(context, interval, TimeUnit.MINUTES)
}
}
fun removeUpdates(context: Context) {
WeatherWorker.cancel(context)
WeatherWorker.cancelPeriodic(context)
}
}
}