From c9c1a120cd38885adb7e7d5bd7ee4c256c7d5bb7 Mon Sep 17 00:00:00 2001 From: M66B Date: Thu, 13 Sep 2018 19:03:50 +0000 Subject: [PATCH] Small improvement --- .../java/eu/faircode/email/FragmentCompose.java | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentCompose.java b/app/src/main/java/eu/faircode/email/FragmentCompose.java index 4aa6f36a..378d0682 100644 --- a/app/src/main/java/eu/faircode/email/FragmentCompose.java +++ b/app/src/main/java/eu/faircode/email/FragmentCompose.java @@ -611,7 +611,7 @@ public class FragmentCompose extends FragmentEx { actionLoader.load(this, args); } - private EntityAttachment addAttachment(Context context, long id, Uri uri, boolean image) throws IOException { + private static EntityAttachment addAttachment(Context context, long id, Uri uri, boolean image) throws IOException { EntityAttachment attachment = new EntityAttachment(); String name = null; @@ -1195,11 +1195,13 @@ public class FragmentCompose extends FragmentEx { @Override public Drawable getDrawable(String source) { if (source != null && source.startsWith("cid")) { - String cid = source.split(":")[1]; - File file = EntityAttachment.getFile(getContext(), Long.parseLong(cid)); - Drawable d = Drawable.createFromPath(file.getAbsolutePath()); - d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); - return d; + String[] cid = source.split(":"); + if (cid.length > 1) { + File file = EntityAttachment.getFile(getContext(), Long.parseLong(cid[1])); + Drawable d = Drawable.createFromPath(file.getAbsolutePath()); + d.setBounds(0, 0, d.getIntrinsicWidth(), d.getIntrinsicHeight()); + return d; + } } float scale = getContext().getResources().getDisplayMetrics().density;