From 2d9cd8eb52e3e1af317d4cd13ebb9ceb184bcf4b Mon Sep 17 00:00:00 2001 From: Lukas Barth Date: Sat, 21 Jun 2014 15:31:45 +0200 Subject: [PATCH] Fixing race condition and other mistakes. Fixes #1603. // FREEBIE --- .../securesms/recipients/Recipient.java | 20 ++++++++++++------- .../recipients/RecipientProvider.java | 15 +++++++++----- 2 files changed, 23 insertions(+), 12 deletions(-) diff --git a/src/org/thoughtcrime/securesms/recipients/Recipient.java b/src/org/thoughtcrime/securesms/recipients/Recipient.java index b7d29424c2..6598102a84 100644 --- a/src/org/thoughtcrime/securesms/recipients/Recipient.java +++ b/src/org/thoughtcrime/securesms/recipients/Recipient.java @@ -78,6 +78,7 @@ public class Recipient implements Parcelable, CanonicalRecipient { Recipient.this.contactUri = result.contactUri; Recipient.this.contactPhoto = result.avatar; Recipient.this.circleCroppedContactPhoto = result.croppedAvatar; + localListeners = (HashSet) listeners.clone(); listeners.clear(); } @@ -94,12 +95,15 @@ public class Recipient implements Parcelable, CanonicalRecipient { }); } - Recipient(String name, String number, long recipientId, Uri contactUri, Bitmap contactPhoto) { - this.number = number; - this.recipientId = recipientId; - this.contactUri = contactUri; - this.name = name; - this.contactPhoto = contactPhoto; + Recipient(String name, String number, long recipientId, Uri contactUri, Bitmap contactPhoto, + Bitmap circleCroppedContactPhoto) + { + this.number = number; + this.recipientId = recipientId; + this.contactUri = contactUri; + this.name = name; + this.contactPhoto = contactPhoto; + this.circleCroppedContactPhoto = circleCroppedContactPhoto; } public Recipient(Parcel in) { @@ -185,7 +189,9 @@ public class Recipient implements Parcelable, CanonicalRecipient { } public static Recipient getUnknownRecipient(Context context) { - return new Recipient("Unknown", "Unknown", -1, null, ContactPhotoFactory.getDefaultContactPhoto(context)); + return new Recipient("Unknown", "Unknown", -1, null, + ContactPhotoFactory.getDefaultContactPhoto(context), + ContactPhotoFactory.getDefaultContactPhotoCropped(context)); } @Override diff --git a/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java b/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java index 725bd7ece7..c075348893 100644 --- a/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java +++ b/src/org/thoughtcrime/securesms/recipients/RecipientProvider.java @@ -72,12 +72,17 @@ public class RecipientProvider { else details = getRecipientDetails(context, number); if (details != null) { - recipient = new Recipient(details.name, number, recipientId, details.contactUri, details.avatar); + recipient = new Recipient(details.name, number, recipientId, details.contactUri, details.avatar, + details.croppedAvatar); } else { - final Bitmap defaultPhoto = isGroupRecipient - ? ContactPhotoFactory.getDefaultGroupPhoto(context) - : ContactPhotoFactory.getDefaultContactPhoto(context); - recipient = new Recipient(null, number, recipientId, null, defaultPhoto); + final Bitmap defaultPhoto = isGroupRecipient + ? ContactPhotoFactory.getDefaultGroupPhoto(context) + : ContactPhotoFactory.getDefaultContactPhoto(context); + final Bitmap defaultCroppedPhoto = isGroupRecipient + ? ContactPhotoFactory.getDefaultGroupPhotoCropped(context) + : ContactPhotoFactory.getDefaultContactPhotoCropped(context); + + recipient = new Recipient(null, number, recipientId, null, defaultPhoto, defaultCroppedPhoto); } recipientCache.put(recipientId, recipient);