Small improvement

This commit is contained in:
M66B 2020-01-06 12:26:56 +01:00
parent b342edbd77
commit 2414485689
2 changed files with 3 additions and 21 deletions

View File

@ -38,7 +38,7 @@ public class ReceiverAutoStart extends BroadcastReceiver {
ServiceSynchronize.boot(context); ServiceSynchronize.boot(context);
ServiceSend.boot(context); ServiceSend.boot(context);
WorkerCleanup.queueOnce(context); WorkerCleanup.queue(context);
} }
} }
} }

View File

@ -24,9 +24,7 @@ import android.content.SharedPreferences;
import androidx.annotation.NonNull; import androidx.annotation.NonNull;
import androidx.preference.PreferenceManager; import androidx.preference.PreferenceManager;
import androidx.work.Data;
import androidx.work.ExistingPeriodicWorkPolicy; import androidx.work.ExistingPeriodicWorkPolicy;
import androidx.work.OneTimeWorkRequest;
import androidx.work.PeriodicWorkRequest; import androidx.work.PeriodicWorkRequest;
import androidx.work.WorkManager; import androidx.work.WorkManager;
import androidx.work.Worker; import androidx.work.Worker;
@ -105,6 +103,8 @@ public class WorkerCleanup extends Worker {
for (EntityMessage message : db.message().getSnoozed()) for (EntityMessage message : db.message().getSnoozed())
EntityMessage.snooze(context, message.id, message.ui_snoozed); EntityMessage.snooze(context, message.id, message.ui_snoozed);
ServiceSynchronize.reschedule(context);
// Clear last search // Clear last search
SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context); SharedPreferences prefs = PreferenceManager.getDefaultSharedPreferences(context);
prefs.edit() prefs.edit()
@ -223,24 +223,6 @@ public class WorkerCleanup extends Worker {
} }
} }
static void queueOnce(Context context) {
try {
Log.i("Queuing " + getName() + " once");
Data data = new Data.Builder().putBoolean("manual", true).build();
OneTimeWorkRequest workRequest = new OneTimeWorkRequest.Builder(WorkerCleanup.class)
.setInputData(data)
.build();
WorkManager.getInstance(context).enqueue(workRequest);
Log.i("Queued " + getName() + " once");
} catch (IllegalStateException ex) {
// https://issuetracker.google.com/issues/138465476
Log.w(ex);
}
}
static void cancel(Context context) { static void cancel(Context context) {
try { try {
Log.i("Cancelling " + getName()); Log.i("Cancelling " + getName());