From f336306606e6d5fc93cf3ed746fdbf79b454dd3a Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 17 Oct 2018 08:20:16 +0000 Subject: [PATCH] Compose in message lists only --- .../eu/faircode/email/FragmentMessages.java | 84 ++++++++++--------- 1 file changed, 43 insertions(+), 41 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index 9e2d27b8..2e85c918 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -529,54 +529,56 @@ public class FragmentMessages extends FragmentEx { loadMessages(); // Compose FAB - Bundle args = new Bundle(); - args.putLong("folder", folder); - args.putLong("thread", thread); - - new SimpleTask() { - @Override - protected Long onLoad(Context context, Bundle args) { - long fid = args.getLong("folder", -1); - long thread = args.getLong("thread", -1); // message ID - - DB db = DB.getInstance(context); + if (viewType != AdapterMessage.ViewType.THREAD) { + Bundle args = new Bundle(); + args.putLong("folder", folder); + args.putLong("thread", thread); + + new SimpleTask() { + @Override + protected Long onLoad(Context context, Bundle args) { + long fid = args.getLong("folder", -1); + long thread = args.getLong("thread", -1); // message ID + + DB db = DB.getInstance(context); + + Long account = null; + if (thread < 0) { + if (folder >= 0) { + EntityFolder folder = db.folder().getFolder(fid); + if (folder != null) + account = folder.account; + } + } else { + EntityMessage threaded = db.message().getMessage(thread); + if (threaded != null) + account = threaded.account; + } - Long account = null; - if (thread < 0) { - if (folder >= 0) { - EntityFolder folder = db.folder().getFolder(fid); - if (folder != null) - account = folder.account; + if (account == null) { + // outbox + EntityFolder primary = db.folder().getPrimaryDrafts(); + if (primary != null) + account = primary.account; } - } else { - EntityMessage threaded = db.message().getMessage(thread); - if (threaded != null) - account = threaded.account; - } - if (account == null) { - // outbox - EntityFolder primary = db.folder().getPrimaryDrafts(); - if (primary != null) - account = primary.account; + return account; } - return account; - } - - @Override - protected void onLoaded(Bundle args, Long account) { - if (account != null) { - fab.setTag(account); - fab.show(); + @Override + protected void onLoaded(Bundle args, Long account) { + if (account != null) { + fab.setTag(account); + fab.show(); + } } - } - @Override - protected void onException(Bundle args, Throwable ex) { - Helper.unexpectedError(getContext(), ex); - } - }.load(this, args); + @Override + protected void onException(Bundle args, Throwable ex) { + Helper.unexpectedError(getContext(), ex); + } + }.load(this, args); + } } @Override