From db04d69bba3fa0cbc2846bf76a2777a9b664bcc7 Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 16 Feb 2021 17:58:32 +0100 Subject: [PATCH] Optimization --- .../eu/faircode/email/AdapterMessage.java | 61 +++++++------------ 1 file changed, 22 insertions(+), 39 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index ac6ce6e620..a515380859 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -1612,36 +1612,7 @@ public class AdapterMessage extends RecyclerView.Adapter>() { - @Override - protected List onExecute(Context context, Bundle args) throws Throwable { - long id = args.getLong("id"); - - DB db = DB.getInstance(context); - return db.attachment().getAttachments(id); - } - - @Override - protected void onExecuted(Bundle args, List attachments) { - if (attachments == null) - attachments = new ArrayList<>(); - - bindAttachments(message, attachments, false); - setupTools(message, scroll, true); - } - - @Override - protected void onException(Bundle args, Throwable ex) { - Log.unexpectedError(parentFragment.getParentFragmentManager(), ex); - } - }.execute(context, owner, args, "message:attachments"); - } + setupTools(message, scroll, true); } private void setupTools(final TupleMessageEx message, final boolean scroll, final boolean bind) { @@ -1649,20 +1620,25 @@ public class AdapterMessage extends RecyclerView.Adapter>() { + new SimpleTask() { @Override - protected List onExecute(Context context, Bundle args) { + protected ToolData onExecute(Context context, Bundle args) { + long id = args.getLong("id"); long aid = args.getLong("account"); + ToolData data = new ToolData(); + DB db = DB.getInstance(context); EntityAccount account = db.account().getAccount(aid); - args.putBoolean("gmail", account != null && account.isGmail()); + data.isGmail = (account != null && account.isGmail()); + data.folders = db.folder().getSystemFolders(aid); + data.attachments = db.attachment().getAttachments(id); - return db.folder().getSystemFolders(aid); + return data; } @Override - protected void onExecuted(Bundle args, List folders) { + protected void onExecuted(Bundle args, ToolData data) { long id = args.getLong("id"); TupleMessageEx amessage = getMessage(); if (amessage == null || !amessage.id.equals(id)) @@ -1672,14 +1648,15 @@ public class AdapterMessage extends RecyclerView.Adapter folders; + private List attachments; + } } AdapterMessage(Fragment parentFragment,