mirror of
https://codeberg.org/Bazsalanszky/Infinity-For-Lemmy.git
synced 2024-12-25 10:28:22 +01:00
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.
This commit is contained in:
parent
d864ec6d7f
commit
23c76a86cb
@ -76,12 +76,13 @@ public class NotificationPreferenceFragment extends PreferenceFragmentCompat {
|
||||
new PeriodicWorkRequest.Builder(PullNotificationWorker.class,
|
||||
notificationInterval, TimeUnit.HOURS)
|
||||
.setConstraints(constraints)
|
||||
.setInitialDelay(notificationInterval, TimeUnit.HOURS)
|
||||
.build();
|
||||
|
||||
workManager.enqueueUniquePeriodicWork(PullNotificationWorker.WORKER_TAG,
|
||||
ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest);
|
||||
ExistingPeriodicWorkPolicy.REPLACE, pullNotificationRequest);
|
||||
} else {
|
||||
workManager.cancelAllWorkByTag(PullNotificationWorker.WORKER_TAG);
|
||||
workManager.cancelUniqueWork(PullNotificationWorker.WORKER_TAG);
|
||||
}
|
||||
return true;
|
||||
});
|
||||
@ -100,12 +101,13 @@ public class NotificationPreferenceFragment extends PreferenceFragmentCompat {
|
||||
new PeriodicWorkRequest.Builder(PullNotificationWorker.class,
|
||||
notificationInterval, TimeUnit.HOURS)
|
||||
.setConstraints(constraints)
|
||||
.setInitialDelay(notificationInterval, TimeUnit.HOURS)
|
||||
.build();
|
||||
|
||||
workManager.enqueueUniquePeriodicWork(PullNotificationWorker.WORKER_TAG,
|
||||
ExistingPeriodicWorkPolicy.KEEP, pullNotificationRequest);
|
||||
ExistingPeriodicWorkPolicy.REPLACE, pullNotificationRequest);
|
||||
} else {
|
||||
workManager.cancelAllWorkByTag(PullNotificationWorker.WORKER_TAG);
|
||||
workManager.cancelUniqueWork(PullNotificationWorker.WORKER_TAG);
|
||||
}
|
||||
|
||||
return true;
|
||||
|
@ -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();
|
||||
|
Loading…
Reference in New Issue
Block a user