|
|
@ -127,13 +127,13 @@ public class WorkerCleanup extends Worker {
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void queue() {
|
|
|
|
static void queue() {
|
|
|
|
String tag = "cleanup";
|
|
|
|
String tag = WorkerCleanup.class.getSimpleName();
|
|
|
|
Log.i("Queuing work " + tag);
|
|
|
|
Log.i("Queuing " + tag);
|
|
|
|
|
|
|
|
|
|
|
|
try {
|
|
|
|
try {
|
|
|
|
for (WorkInfo info : WorkManager.getInstance().getWorkInfosByTag(tag).get())
|
|
|
|
for (WorkInfo info : WorkManager.getInstance().getWorkInfosByTag(tag).get())
|
|
|
|
if (!info.getState().isFinished()) {
|
|
|
|
if (!info.getState().isFinished()) {
|
|
|
|
Log.i("Work already queued " + tag);
|
|
|
|
Log.i("Already queued " + tag);
|
|
|
|
return;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
} catch (Throwable ex) {
|
|
|
|
} catch (Throwable ex) {
|
|
|
@ -151,13 +151,12 @@ public class WorkerCleanup extends Worker {
|
|
|
|
.build();
|
|
|
|
.build();
|
|
|
|
WorkManager.getInstance().enqueue(workRequest);
|
|
|
|
WorkManager.getInstance().enqueue(workRequest);
|
|
|
|
|
|
|
|
|
|
|
|
Log.i("Queued work " + tag);
|
|
|
|
Log.i("Queued " + tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static void cancel() {
|
|
|
|
static void cancel() {
|
|
|
|
String tag = "cleanup";
|
|
|
|
String tag = WorkerCleanup.class.getSimpleName();
|
|
|
|
Log.i("Cancelling work " + tag);
|
|
|
|
Log.i("Cancelling " + tag);
|
|
|
|
|
|
|
|
|
|
|
|
WorkManager.getInstance().cancelAllWorkByTag(tag);
|
|
|
|
WorkManager.getInstance().cancelAllWorkByTag(tag);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
|
|
|