From 0042a1e5801eb76d619418b987e44b1d9f4300ec Mon Sep 17 00:00:00 2001 From: M66B Date: Fri, 17 May 2019 22:12:12 +0200 Subject: [PATCH] Set initial delay for periodic workers --- app/src/main/java/eu/faircode/email/WorkerCleanup.java | 1 + app/src/main/java/eu/faircode/email/WorkerPoll.java | 1 + app/src/main/java/eu/faircode/email/WorkerWatchdog.java | 1 + 3 files changed, 3 insertions(+) diff --git a/app/src/main/java/eu/faircode/email/WorkerCleanup.java b/app/src/main/java/eu/faircode/email/WorkerCleanup.java index 6d3e1489e6..f59ba7dcf2 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -163,6 +163,7 @@ public class WorkerCleanup extends Worker { PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(WorkerCleanup.class, CLEANUP_INTERVAL, TimeUnit.HOURS) + .setInitialDelay(CLEANUP_INTERVAL, TimeUnit.HOURS) .setConstraints(constraints.build()) .build(); WorkManager.getInstance(context) diff --git a/app/src/main/java/eu/faircode/email/WorkerPoll.java b/app/src/main/java/eu/faircode/email/WorkerPoll.java index f86ba2678d..63bb2f3506 100644 --- a/app/src/main/java/eu/faircode/email/WorkerPoll.java +++ b/app/src/main/java/eu/faircode/email/WorkerPoll.java @@ -54,6 +54,7 @@ public class WorkerPoll extends Worker { Log.i("Queuing " + getName() + " every " + pollInterval + " minutes"); PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(WorkerPoll.class, pollInterval, TimeUnit.MINUTES) + .setInitialDelay(pollInterval, TimeUnit.MINUTES) .build(); WorkManager.getInstance(context) .enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.REPLACE, workRequest); diff --git a/app/src/main/java/eu/faircode/email/WorkerWatchdog.java b/app/src/main/java/eu/faircode/email/WorkerWatchdog.java index 5d39209b4e..42cbf9196e 100644 --- a/app/src/main/java/eu/faircode/email/WorkerWatchdog.java +++ b/app/src/main/java/eu/faircode/email/WorkerWatchdog.java @@ -56,6 +56,7 @@ public class WorkerWatchdog extends Worker { PeriodicWorkRequest workRequest = new PeriodicWorkRequest.Builder(WorkerWatchdog.class, WATCHDOG_INTERVAL, TimeUnit.MINUTES) + .setInitialDelay(WATCHDOG_INTERVAL, TimeUnit.MINUTES) .build(); WorkManager.getInstance(context) .enqueueUniquePeriodicWork(getName(), ExistingPeriodicWorkPolicy.KEEP, workRequest);