From ad7072e333758ea7261aa3564a42fb99bc6cf317 Mon Sep 17 00:00:00 2001 From: M66B Date: Sat, 15 Sep 2018 05:52:59 +0000 Subject: [PATCH] Prevent crash --- .../java/eu/faircode/email/FragmentMessages.java | 16 +++++++++++----- 1 file changed, 11 insertions(+), 5 deletions(-) diff --git a/app/src/main/java/eu/faircode/email/FragmentMessages.java b/app/src/main/java/eu/faircode/email/FragmentMessages.java index db39ce64..6c5a41c0 100644 --- a/app/src/main/java/eu/faircode/email/FragmentMessages.java +++ b/app/src/main/java/eu/faircode/email/FragmentMessages.java @@ -462,17 +462,23 @@ public class FragmentMessages extends FragmentEx { new SimpleTask() { @Override protected Long onLoad(Context context, Bundle args) { - long folder = args.getLong("folder", -1); + 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) - account = db.folder().getFolder(folder).account; - } else - account = db.message().getMessage(thread).account; + 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; + } if (account == null) { // outbox