mirror of
https://github.com/oxen-io/session-android.git
synced 2025-02-19 20:08:27 +00:00
Fix for NPE when Recipients is empty for thread.
// FREEBIE
This commit is contained in:
parent
2be8a9bf12
commit
437ffba4b1
@ -3,10 +3,12 @@ package org.thoughtcrime.securesms.components;
|
||||
import android.content.Context;
|
||||
import android.content.Intent;
|
||||
import android.provider.ContactsContract;
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.AttributeSet;
|
||||
import android.view.View;
|
||||
import android.widget.ImageView;
|
||||
|
||||
import org.thoughtcrime.securesms.contacts.ContactPhotoFactory;
|
||||
import org.thoughtcrime.securesms.recipients.Recipient;
|
||||
|
||||
public class AvatarImageView extends ImageView {
|
||||
@ -21,9 +23,14 @@ public class AvatarImageView extends ImageView {
|
||||
setScaleType(ScaleType.CENTER_INSIDE);
|
||||
}
|
||||
|
||||
public void setAvatar(Recipient recipient, boolean quickContactEnabled) {
|
||||
setImageDrawable(recipient.getContactPhoto());
|
||||
setAvatarClickHandler(recipient, quickContactEnabled);
|
||||
public void setAvatar(@Nullable Recipient recipient, boolean quickContactEnabled) {
|
||||
if (recipient != null) {
|
||||
setImageDrawable(recipient.getContactPhoto());
|
||||
setAvatarClickHandler(recipient, quickContactEnabled);
|
||||
} else {
|
||||
setImageDrawable(ContactPhotoFactory.getDefaultContactPhoto(getContext(), null));
|
||||
setOnClickListener(null);
|
||||
}
|
||||
}
|
||||
|
||||
private void setAvatarClickHandler(final Recipient recipient, boolean quickContactEnabled) {
|
||||
|
@ -16,6 +16,7 @@
|
||||
*/
|
||||
package org.thoughtcrime.securesms.recipients;
|
||||
|
||||
import android.support.annotation.Nullable;
|
||||
import android.util.Patterns;
|
||||
|
||||
import org.thoughtcrime.securesms.recipients.Recipient.RecipientModifiedListener;
|
||||
@ -109,7 +110,7 @@ public class Recipients implements Iterable<Recipient> {
|
||||
return this.recipients.size() == 1;
|
||||
}
|
||||
|
||||
public Recipient getPrimaryRecipient() {
|
||||
public @Nullable Recipient getPrimaryRecipient() {
|
||||
if (!isEmpty())
|
||||
return this.recipients.get(0);
|
||||
else
|
||||
|
Loading…
x
Reference in New Issue
Block a user