Skip to content

Commit

Permalink
Add initial delay of twenty seconds to sync worker enqueue
Browse files Browse the repository at this point in the history
  • Loading branch information
theck13 committed Dec 30, 2020
1 parent 22d02da commit d0c9c30
Showing 1 changed file with 2 additions and 0 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ public class Simplenote extends Application implements HeartbeatListener {
public static final int INTENT_PREFERENCES = 1;
public static final int ONE_MINUTE_MILLIS = 60 * 1000; // 60 seconds
public static final int TEN_SECONDS_MILLIS = 10 * 1000; // 10 seconds
public static final int TWENTY_SECONDS_MILLIS = 20 * 1000; // 20 seconds

private static final String AUTH_PROVIDER = "simplenote.com";
private static final String TAG_SYNC = "sync";
Expand Down Expand Up @@ -219,6 +220,7 @@ public void run() {
)
.setConstraints(new Constraints.Builder().setRequiredNetworkType(NetworkType.CONNECTED).build())
.setBackoffCriteria(BackoffPolicy.LINEAR, ONE_MINUTE_MILLIS, TimeUnit.MILLISECONDS)
.setInitialDelay(TWENTY_SECONDS_MILLIS, TimeUnit.MILLISECONDS)
.addTag(TAG_SYNC)
.build();
WorkManager.getInstance(getApplicationContext()).enqueueUniquePeriodicWork(
Expand Down

0 comments on commit d0c9c30

Please sign in to comment.