From 23c76a86cb0ccb71776c13bd619155d35797a26e Mon Sep 17 00:00:00 2001 From: Alex Ning Date: Thu, 22 Aug 2019 17:30:42 +0800 Subject: Correctly cancel periodic work request by id not by tag. Add an initial delay which is the same time as the interval when start PullNotificationWorker in NotificationPreferenceFragment. --- .../java/ml/docilealligator/infinityforreddit/MainActivity.java | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) (limited to 'app/src/main/java/ml') diff --git a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java index 300cd4c1..8be70369 100644 --- a/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java +++ b/app/src/main/java/ml/docilealligator/infinityforreddit/MainActivity.java @@ -319,7 +319,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe workManager.enqueueUniquePeriodicWork(PullNotificationWorker.WORKER_TAG, ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest); } else { - workManager.cancelAllWorkByTag(PullNotificationWorker.WORKER_TAG); + workManager.cancelUniqueWork(PullNotificationWorker.WORKER_TAG); } bindView(); @@ -345,7 +345,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe workManager.enqueueUniquePeriodicWork(PullNotificationWorker.WORKER_TAG, ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest); } else { - workManager.cancelAllWorkByTag(PullNotificationWorker.WORKER_TAG); + workManager.cancelUniqueWork(PullNotificationWorker.WORKER_TAG); } bindView(); @@ -375,7 +375,7 @@ public class MainActivity extends AppCompatActivity implements SortTypeBottomShe workManager.enqueueUniquePeriodicWork(PullNotificationWorker.WORKER_TAG, ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest); } else { - workManager.cancelAllWorkByTag(PullNotificationWorker.WORKER_TAG); + workManager.cancelUniqueWork(PullNotificationWorker.WORKER_TAG); } bindView(); -- cgit v1.2.3