From beee8574fd0cdc79532f80b387d4a7db98902e51 Mon Sep 17 00:00:00 2001 From: M66B Date: Mon, 6 Aug 2018 18:57:36 +0000 Subject: [PATCH] Use intent type to target right process receiver --- .../java/eu/faircode/email/EntityOperation.java | 14 ++++++++++---- .../java/eu/faircode/email/ServiceSynchronize.java | 8 ++++++-- 2 files changed, 16 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/EntityOperation.java b/app/src/main/java/eu/faircode/email/EntityOperation.java index 7cb3ac9c..3ac8f7f6 100644 --- a/app/src/main/java/eu/faircode/email/EntityOperation.java +++ b/app/src/main/java/eu/faircode/email/EntityOperation.java @@ -94,11 +94,17 @@ public class EntityOperation { operation.args = jsonArray.toString(); operation.id = dao.insertOperation(operation); + Intent intent = new Intent(); + if (SEND.equals(name)) + intent.setAction(ServiceSynchronize.ACTION_PROCESS_OUTBOX); + else { + intent.setType("account/" + message.account); + intent.setAction(ServiceSynchronize.ACTION_PROCESS_FOLDER); + } + intent.putExtra("folder", message.folder); + synchronized (queue) { - queue.add(new Intent(SEND.equals(name) - ? ServiceSynchronize.ACTION_PROCESS_OUTBOX - : ServiceSynchronize.ACTION_PROCESS_FOLDER) - .putExtra("folder", message.folder)); + queue.add(intent); } Log.i(Helper.TAG, "Queued op=" + operation.id + "/" + name + diff --git a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java index 94d4557f..74aa8a0f 100644 --- a/app/src/main/java/eu/faircode/email/ServiceSynchronize.java +++ b/app/src/main/java/eu/faircode/email/ServiceSynchronize.java @@ -392,12 +392,16 @@ public class ServiceSynchronize extends LifecycleService { thread.start(); } + IntentFilter f = new IntentFilter(ACTION_PROCESS_FOLDER); + f.addDataType("account/" + account.id); LocalBroadcastManager lbm = LocalBroadcastManager.getInstance(ServiceSynchronize.this); - lbm.registerReceiver(processReceiver, new IntentFilter(ACTION_PROCESS_FOLDER)); + lbm.registerReceiver(processReceiver, f); Log.i(Helper.TAG, "listen process folder"); for (final EntityFolder folder : db.folder().getFolders(account.id)) if (!EntityFolder.TYPE_OUTBOX.equals(folder.type)) - lbm.sendBroadcast(new Intent(ACTION_PROCESS_FOLDER).putExtra("folder", folder.id)); + lbm.sendBroadcast(new Intent(ACTION_PROCESS_FOLDER) + .setType("account/" + account.id) + .putExtra("folder", folder.id)); } catch (Throwable ex) { Log.e(Helper.TAG, account.name + " " + ex + "\n" + Log.getStackTraceString(ex));