Check schedule on scheduling next poll

This commit is contained in:
M66B 2020-01-14 09:02:37 +01:00
parent 4d52549b7c
commit 96cd456a3d
2 changed files with 8 additions and 4 deletions

View File

@ -1604,7 +1604,7 @@ public class ServiceSynchronize extends ServiceBase implements SharedPreferences
ServiceUI.schedule(context, enabled);
}
private static long[] getSchedule(Context context) {
static long[] getSchedule(Context context) {
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
if (!prefs.getBoolean("schedule", false))
return null;

View File

@ -459,10 +459,14 @@ public class ServiceUI extends IntentService {
db.endTransaction();
}
if (reschedule)
schedule(this, true);
ServiceSynchronize.eval(this, "poll");
if (reschedule) {
long now = new Date().getTime();
long[] schedule = ServiceSynchronize.getSchedule(this);
boolean enabled = (schedule == null || (now >= schedule[0] && now < schedule[1]));
schedule(this, enabled);
}
}
private void onBanner() {