Correct and improve calendar events updating algorithm.

1. UpdateCalendarService will fetch all events from now to the next fetch time + Preferences.showUntil, so that EventRepository holds all events need to be shown before the next fetch;
2. Every event is updated 1 minute after the corresponding time span, to make the actual time difference consistent with the displayed getRelativeTimeSpanString;
3. Update events only when necessary, eliminate redundant alarms; cancel all update alarms when showEvents is turned off.
This commit is contained in:
azuo
2021-09-03 18:20:01 +08:00
parent 260e36b305
commit 3ab42fd163
7 changed files with 102 additions and 133 deletions

View File

@ -35,8 +35,6 @@ class WeatherReceiver : BroadcastReceiver() {
companion object {
private const val MINUTE = 60 * 1000L
fun setUpdates(context: Context) {
removeUpdates(context)
if (Preferences.showWeather) {
val interval = MINUTE * when (Preferences.weatherRefreshPeriod) {
0 -> 30