From b3db2956d126666900710caeef7f3020702115d3 Mon Sep 17 00:00:00 2001 From: M66B Date: Sun, 3 Mar 2019 09:52:53 +0000 Subject: [PATCH] Refactoring --- .../main/java/eu/faircode/email/WorkerCleanup.java | 13 ++++++------- .../java/eu/faircode/email/WorkerFolderSync.java | 8 ++++---- .../java/eu/faircode/email/WorkerOperations.java | 8 ++++---- 3 files changed, 14 insertions(+), 15 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/WorkerCleanup.java b/app/src/main/java/eu/faircode/email/WorkerCleanup.java index 4d0d6522a8..0ecf41c37b 100644 --- a/app/src/main/java/eu/faircode/email/WorkerCleanup.java +++ b/app/src/main/java/eu/faircode/email/WorkerCleanup.java @@ -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); } } diff --git a/app/src/main/java/eu/faircode/email/WorkerFolderSync.java b/app/src/main/java/eu/faircode/email/WorkerFolderSync.java index 2812da670b..2da2297824 100644 --- a/app/src/main/java/eu/faircode/email/WorkerFolderSync.java +++ b/app/src/main/java/eu/faircode/email/WorkerFolderSync.java @@ -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); } } diff --git a/app/src/main/java/eu/faircode/email/WorkerOperations.java b/app/src/main/java/eu/faircode/email/WorkerOperations.java index 9059f89f87..d8cee65919 100644 --- a/app/src/main/java/eu/faircode/email/WorkerOperations.java +++ b/app/src/main/java/eu/faircode/email/WorkerOperations.java @@ -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); } }