From 16f8759a08ee4203820288d9a972c38d3e2a5a7d Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 27 Dec 2018 15:08:13 +0000 Subject: [PATCH] Clear handling operations --- .../eu/faircode/email/ServiceSynchronize.java | 21 +++++++------------ 1 file changed, 8 insertions(+), 13 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index d6b69ebb42..b038882222 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -1138,15 +1138,17 @@ public class ServiceSynchronize extends LifecycleService { // Observe operations Handler handler = new Handler(getMainLooper()) { + private List handling = new ArrayList<>(); private LiveData> liveOperations; @Override public void handleMessage(android.os.Message msg) { Log.i(account.name + "/" + folder.name + " observe=" + msg.what); try { - if (msg.what == 0) + if (msg.what == 0) { liveOperations.removeObserver(observer); - else { + handling.clear(); + } else { liveOperations = db.operation().liveOperations(folder.id); liveOperations.observe(ServiceSynchronize.this, observer); } @@ -1156,7 +1158,6 @@ public class ServiceSynchronize extends LifecycleService { } private Observer> observer = new Observer>() { - private List handling = new ArrayList<>(); private final ExecutorService folderExecutor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); private final PowerManager.WakeLock wlFolder = pm.newWakeLock( PowerManager.PARTIAL_WAKE_LOCK, BuildConfig.APPLICATION_ID + ":folder." + folder.id); @@ -1229,13 +1230,6 @@ public class ServiceSynchronize extends LifecycleService { }); } } - - @Override - public boolean equals(@Nullable Object obj) { - boolean eq = super.equals(obj); - Log.i(account.name + "/" + folder.name + " equal=" + eq + " observer=" + observer + " other=" + obj); - return eq; - } }; }; @@ -2635,21 +2629,22 @@ public class ServiceSynchronize extends LifecycleService { db.folder().setFolderError(outbox.id, null); handler = new Handler(getMainLooper()) { + private List handling = new ArrayList<>(); private LiveData> liveOperations; @Override public void handleMessage(android.os.Message msg) { Log.i(outbox.name + " observe=" + msg.what); - if (msg.what == 0) + if (msg.what == 0) { liveOperations.removeObserver(observer); - else { + handling.clear(); + } else { liveOperations = db.operation().liveOperations(outbox.id); liveOperations.observe(ServiceSynchronize.this, observer); } } private Observer> observer = new Observer>() { - private List handling = new ArrayList<>(); private ExecutorService executor = Executors.newSingleThreadExecutor(Helper.backgroundThreadFactory); PowerManager pm = (PowerManager) getSystemService(Context.POWER_SERVICE); PowerManager.WakeLock wl = pm.newWakeLock(