From 0a73e8cd459f4839f7c54fd74c9085271a1fb806 Mon Sep 17 00:00:00 2001 From: Makoto Onuki Date: Tue, 11 Jan 2011 17:20:45 -0800 Subject: [PATCH] Fix NPE in MessageListItem Not sure in what condition Message.displayName can be null, but addign this check won't harm... Bug 3339309 Change-Id: Ic2261fc33cf2be759411b998707a96eedd4e4fdb --- src/com/android/email/activity/MessageListItem.java | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/src/com/android/email/activity/MessageListItem.java b/src/com/android/email/activity/MessageListItem.java index a7a55ba81..7b430c845 100644 --- a/src/com/android/email/activity/MessageListItem.java +++ b/src/com/android/email/activity/MessageListItem.java @@ -328,7 +328,12 @@ public class MessageListItem extends View { TextPaint senderPaint = mRead ? sDefaultPaint : sBoldPaint; int senderWidth = (mMode == MODE_WIDE) ? sSenderWidth : mSenderSnippetWidth; // And get the ellipsized string for the calculated width - mFormattedSender = TextUtils.ellipsize(mSender, senderPaint, senderWidth, TruncateAt.END); + if (TextUtils.isEmpty(mSender)) { + mFormattedSender = ""; + } else { + mFormattedSender = TextUtils.ellipsize(mSender, senderPaint, senderWidth, + TruncateAt.END); + } // Get a nicely formatted date string (relative to today) String date = DateUtils.getRelativeTimeSpanString(getContext(), mTimestamp).toString(); // And make it fit to our size