From b044a68168d1a8831bdadae60931d8cfe667d6c1 Mon Sep 17 00:00:00 2001 From: Moxie Marlinspike Date: Mon, 4 Feb 2013 21:51:25 -0800 Subject: [PATCH] Fix for mysterious 'anonymous sender' NPE. --- .../thoughtcrime/securesms/ConversationAdapter.java | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/src/org/thoughtcrime/securesms/ConversationAdapter.java b/src/org/thoughtcrime/securesms/ConversationAdapter.java index 2b1d330d15..7c09e27096 100644 --- a/src/org/thoughtcrime/securesms/ConversationAdapter.java +++ b/src/org/thoughtcrime/securesms/ConversationAdapter.java @@ -25,6 +25,7 @@ import android.view.View; import android.view.ViewGroup; import android.widget.CursorAdapter; +import org.thoughtcrime.securesms.contacts.ContactPhotoFactory; import org.thoughtcrime.securesms.crypto.MasterCipher; import org.thoughtcrime.securesms.crypto.MasterSecret; import org.thoughtcrime.securesms.crypto.MessageDisplayHelper; @@ -260,15 +261,20 @@ public class ConversationAdapter extends CursorAdapter { Recipient recipient; try { - if (address == null) recipient = recipients.getPrimaryRecipient(); - else recipient = RecipientFactory.getRecipientsFromString(context, address, false).getPrimaryRecipient(); + if (address == null) recipient = recipients.getPrimaryRecipient(); + else recipient = RecipientFactory.getRecipientsFromString(context, address, false).getPrimaryRecipient(); + + if (recipient == null) recipient = new Recipient("Unknown", "Unknown", null, + ContactPhotoFactory.getDefaultContactPhoto(context)); } catch (RecipientFormattingException e) { Log.w("ConversationAdapter", e); - recipient = new Recipient("Unknown", "Unknown", null, null); + recipient = new Recipient("Unknown", "Unknown", null, + ContactPhotoFactory.getDefaultContactPhoto(context)); } return recipient; } + @Override protected void onContentChanged() { super.onContentChanged();