From 2615d70a1d53bc51bc448bce3e02ac03ab303874 Mon Sep 17 00:00:00 2001 From: Daniel Applebaum Date: Wed, 25 Feb 2009 02:32:20 +0000 Subject: [PATCH] Issue 321 Add null checks around more uses of mMessage --- .../android/email/activity/MessageView.java | 27 ++++++++++++------- 1 file changed, 18 insertions(+), 9 deletions(-) diff --git a/src/com/android/email/activity/MessageView.java b/src/com/android/email/activity/MessageView.java index 474391220..8ed680062 100644 --- a/src/com/android/email/activity/MessageView.java +++ b/src/com/android/email/activity/MessageView.java @@ -619,11 +619,14 @@ public class MessageView extends Activity } private void onMarkAsUnread() { + if (mMessage != null) + { MessagingController.getInstance(getApplication()).markMessageRead( mAccount, mFolder, mMessage.getUid(), false); + } } /** @@ -669,21 +672,27 @@ public class MessageView extends Activity Toast.LENGTH_SHORT).show(); return; } - MessagingController.getInstance(getApplication()).loadAttachment( - mAccount, - mMessage, - attachment.part, - new Object[] { true, attachment }, - mListener); + if (mMessage != null) + { + MessagingController.getInstance(getApplication()).loadAttachment( + mAccount, + mMessage, + attachment.part, + new Object[] { true, attachment }, + mListener); + } } private void onViewAttachment(Attachment attachment) { + if (mMessage != null) + { MessagingController.getInstance(getApplication()).loadAttachment( mAccount, mMessage, attachment.part, new Object[] { false, attachment }, mListener); + } } private void onShowPictures() { @@ -771,16 +780,16 @@ public class MessageView extends Activity if (menu != null) { MenuItem flagItem = menu.findItem(R.id.flag); - if (flagItem != null) + if (flagItem != null && mMessage != null) { flagItem.setTitle((mMessage.isSet(Flag.FLAGGED) ? R.string.unflag_action : R.string.flag_action)); } } } - + public CacheResult service(String url, Map headers) { String prefix = "http://cid/"; - if (url.startsWith(prefix)) { + if (url.startsWith(prefix) && mMessage != null) { try { String contentId = url.substring(prefix.length()); final Part part = MimeUtility.findPartByContentId(mMessage, "<" + contentId + ">");