Refactoring

pull/152/head
M66B 6 years ago
parent 46fec74282
commit b3db2956d1

@ -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);
} }
} }

@ -85,13 +85,13 @@ public class WorkerFolderSync extends Worker {
} }
static void queue(long aid) { static void queue(long aid) {
String tag = "fsync:" + aid; String tag = WorkerFolderSync.class.getSimpleName() + ":" + aid;
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) {
@ -106,6 +106,6 @@ public class WorkerFolderSync extends Worker {
.build(); .build();
WorkManager.getInstance().enqueue(workRequest); WorkManager.getInstance().enqueue(workRequest);
Log.i("Queued work " + tag); Log.i("Queued " + tag);
} }
} }

@ -119,13 +119,13 @@ public class WorkerOperations extends Worker {
} }
static void queue(long fid) { static void queue(long fid) {
String tag = "operations:" + fid; String tag = WorkerOperations.class.getSimpleName() + ":" + fid;
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) {
@ -140,6 +140,6 @@ public class WorkerOperations extends Worker {
.build(); .build();
WorkManager.getInstance().enqueue(workRequest); WorkManager.getInstance().enqueue(workRequest);
Log.i("Queued work " + tag); Log.i("Queued " + tag);
} }
} }

Loading…
Cancel
Save