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