From 195ad614d581fd108dc7f03a4819e17fe63481fb Mon Sep 17 00:00:00 2001 From: M66B Date: Tue, 16 Feb 2021 14:12:24 +0100 Subject: [PATCH] Pre load attachments --- .../eu/faircode/email/AdapterMessage.java | 31 ++++++++++++++++++- 1 file changed, 30 insertions(+), 1 deletion(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 785057f022..2f1ef8998f 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -1606,7 +1606,36 @@ 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"); + } } private void setupTools(final TupleMessageEx message, final boolean scroll, final boolean bind) {