Refactoring

This commit is contained in:
M66B 2019-03-03 09:52:53 +00:00
parent 46fec74282
commit b3db2956d1
3 changed files with 14 additions and 15 deletions

View File

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

View File

@ -85,13 +85,13 @@ public class WorkerFolderSync extends Worker {
}
static void queue(long aid) {
String tag = "fsync:" + aid;
Log.i("Queuing work " + tag);
String tag = WorkerFolderSync.class.getSimpleName() + ":" + aid;
Log.i("Queuing " + tag);
try {
for (WorkInfo info : WorkManager.getInstance().getWorkInfosByTag(tag).get())
if (!info.getState().isFinished()) {
Log.i("Work already queued " + tag);
Log.i("Already queued " + tag);
return;
}
} catch (Throwable ex) {
@ -106,6 +106,6 @@ public class WorkerFolderSync extends Worker {
.build();
WorkManager.getInstance().enqueue(workRequest);
Log.i("Queued work " + tag);
Log.i("Queued " + tag);
}
}

View File

@ -119,13 +119,13 @@ public class WorkerOperations extends Worker {
}
static void queue(long fid) {
String tag = "operations:" + fid;
Log.i("Queuing work " + tag);
String tag = WorkerOperations.class.getSimpleName() + ":" + fid;
Log.i("Queuing " + tag);
try {
for (WorkInfo info : WorkManager.getInstance().getWorkInfosByTag(tag).get())
if (!info.getState().isFinished()) {
Log.i("Work already queued " + tag);
Log.i("Already queued " + tag);
return;
}
} catch (Throwable ex) {
@ -140,6 +140,6 @@ public class WorkerOperations extends Worker {
.build();
WorkManager.getInstance().enqueue(workRequest);
Log.i("Queued work " + tag);
Log.i("Queued " + tag);
}
}