Fixing race condition and other mistakes. Fixes #1603.

// FREEBIE
pull/1/head
Lukas Barth 10 years ago committed by Moxie Marlinspike
parent db1d846833
commit 2d9cd8eb52

@ -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<RecipientModifiedListener>) 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

@ -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);

Loading…
Cancel
Save