Merge "Prevent NPE if message not found"

This commit is contained in:
Marc Blank 2012-04-23 14:13:56 -07:00 committed by Android (Google) Code Review
commit cec3719547

View File

@ -2234,7 +2234,9 @@ outer:
Context context = getContext(); Context context = getContext();
long messageId = Long.parseLong(id); long messageId = Long.parseLong(id);
Message msg = Message.restoreMessageWithId(context, messageId); Message msg = Message.restoreMessageWithId(context, messageId);
if (msg != null && (msg.mFlagLoaded == Message.FLAG_LOADED_PARTIAL)) { ContentValues values = new ContentValues();
if (msg != null) {
if (msg.mFlagLoaded == Message.FLAG_LOADED_PARTIAL) {
EmailServiceProxy service = EmailServiceProxy service =
EmailServiceUtils.getServiceForAccount(context, null, msg.mAccountKey); EmailServiceUtils.getServiceForAccount(context, null, msg.mAccountKey);
try { try {
@ -2244,7 +2246,6 @@ outer:
} }
} }
Body body = Body.restoreBodyWithMessageId(context, messageId); Body body = Body.restoreBodyWithMessageId(context, messageId);
ContentValues values = new ContentValues();
if (body != null) { if (body != null) {
if (body.mHtmlContent != null) { if (body.mHtmlContent != null) {
if (IMG_TAG_START_REGEX.matcher(body.mHtmlContent).find()) { if (IMG_TAG_START_REGEX.matcher(body.mHtmlContent).find()) {
@ -2263,7 +2264,6 @@ outer:
} }
} }
values.put(UIProvider.MessageColumns.ALWAYS_SHOW_IMAGES, autoShowImages); values.put(UIProvider.MessageColumns.ALWAYS_SHOW_IMAGES, autoShowImages);
// Add attachments... // Add attachments...
Attachment[] atts = Attachment.restoreAttachmentsWithMessageId(context, messageId); Attachment[] atts = Attachment.restoreAttachmentsWithMessageId(context, messageId);
if (atts.length > 0) { if (atts.length > 0) {
@ -2281,7 +2281,7 @@ outer:
values.put(UIProvider.MessageColumns.ATTACHMENTS, values.put(UIProvider.MessageColumns.ATTACHMENTS,
com.android.mail.providers.Attachment.toJSONArray(uiAtts)); com.android.mail.providers.Attachment.toJSONArray(uiAtts));
} }
}
StringBuilder sb = genSelect(sMessageViewMap, uiProjection, values); StringBuilder sb = genSelect(sMessageViewMap, uiProjection, values);
sb.append(" FROM " + Message.TABLE_NAME + "," + Body.TABLE_NAME + " WHERE " + sb.append(" FROM " + Message.TABLE_NAME + "," + Body.TABLE_NAME + " WHERE " +
Body.MESSAGE_KEY + "=" + Message.TABLE_NAME + "." + Message.RECORD_ID + " AND " + Body.MESSAGE_KEY + "=" + Message.TABLE_NAME + "." + Message.RECORD_ID + " AND " +