small NPE fix
This commit is contained in:
@@ -59,12 +59,13 @@ public class KeyserverSyncManager {
|
|||||||
private static void updateKeyserverSyncSchedule(Context context, boolean forceReschedule) {
|
private static void updateKeyserverSyncSchedule(Context context, boolean forceReschedule) {
|
||||||
Preferences prefs = Preferences.getPreferences(context);
|
Preferences prefs = Preferences.getPreferences(context);
|
||||||
// for some reason, the task is not actually scheduled sometimes unless we use the synchronous interface.
|
// for some reason, the task is not actually scheduled sometimes unless we use the synchronous interface.
|
||||||
SynchronousWorkManager workManager = WorkManager.getInstance().synchronous();
|
WorkManager workManager = WorkManager.getInstance();
|
||||||
if (workManager == null) {
|
if (workManager == null) {
|
||||||
Timber.e("WorkManager unavailable!");
|
Timber.e("WorkManager unavailable!");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
workManager.cancelAllWorkByTagSync(PERIODIC_WORK_TAG);
|
SynchronousWorkManager synchronousWorkManager = workManager.synchronous();
|
||||||
|
synchronousWorkManager.cancelAllWorkByTagSync(PERIODIC_WORK_TAG);
|
||||||
|
|
||||||
if (!prefs.isKeyserverSyncEnabled()) {
|
if (!prefs.isKeyserverSyncEnabled()) {
|
||||||
return;
|
return;
|
||||||
@@ -82,7 +83,7 @@ public class KeyserverSyncManager {
|
|||||||
.setConstraints(constraints.build())
|
.setConstraints(constraints.build())
|
||||||
.addTag(PERIODIC_WORK_TAG)
|
.addTag(PERIODIC_WORK_TAG)
|
||||||
.build();
|
.build();
|
||||||
workManager.enqueueSync(workRequest);
|
synchronousWorkManager.enqueueSync(workRequest);
|
||||||
|
|
||||||
prefs.setKeyserverSyncScheduled(true);
|
prefs.setKeyserverSyncScheduled(true);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user