From 6cb02410b62db3bcba8e9763dc5911af99d331ed Mon Sep 17 00:00:00 2001 From: M66B Date: Wed, 31 Oct 2018 12:47:31 +0000 Subject: [PATCH] Prevent crash --- .../eu/faircode/email/AdapterMessage.java | 31 ++++++++++--------- 1 file changed, 17 insertions(+), 14 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/AdapterMessage.java b/app/src/main/java/eu/faircode/email/AdapterMessage.java index 00bb60195b..554e8a6eb1 100644 --- a/app/src/main/java/eu/faircode/email/AdapterMessage.java +++ b/app/src/main/java/eu/faircode/email/AdapterMessage.java @@ -615,21 +615,24 @@ public class AdapterMessage extends PagedListAdapter"; - EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid); - if (attachment == null || !attachment.available) { - Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); - d.setBounds(0, 0, px, px); - return d; - } else { - File file = EntityAttachment.getFile(context, attachment.id); - Drawable d = Drawable.createFromPath(file.getAbsolutePath()); - if (d == null) { - d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); + String[] cids = source.split(":"); + if (cids.length > 1) { + String cid = "<" + cids[1] + ">"; + EntityAttachment attachment = DB.getInstance(context).attachment().getAttachment(message.id, cid); + if (attachment == null || !attachment.available) { + Drawable d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); d.setBounds(0, 0, px, px); - } else - d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); - return d; + return d; + } else { + File file = EntityAttachment.getFile(context, attachment.id); + Drawable d = Drawable.createFromPath(file.getAbsolutePath()); + if (d == null) { + d = context.getResources().getDrawable(R.drawable.baseline_warning_24, context.getTheme()); + d.setBounds(0, 0, px, px); + } else + d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); + return d; + } } }