33import android .content .Context ;
44import android .content .Intent ;
55import android .provider .ContactsContract ;
6+ import android .support .annotation .Nullable ;
67import android .util .AttributeSet ;
78import android .view .View ;
89import android .widget .ImageView ;
910
11+ import org .thoughtcrime .securesms .contacts .ContactPhotoFactory ;
1012import org .thoughtcrime .securesms .recipients .Recipient ;
1113
1214public class AvatarImageView extends ImageView {
@@ -21,9 +23,14 @@ public AvatarImageView(Context context, AttributeSet attrs) {
2123 setScaleType (ScaleType .CENTER_INSIDE );
2224 }
2325
24- public void setAvatar (Recipient recipient , boolean quickContactEnabled ) {
25- setImageDrawable (recipient .getContactPhoto ());
26- setAvatarClickHandler (recipient , quickContactEnabled );
26+ public void setAvatar (@ Nullable Recipient recipient , boolean quickContactEnabled ) {
27+ if (recipient != null ) {
28+ setImageDrawable (recipient .getContactPhoto ());
29+ setAvatarClickHandler (recipient , quickContactEnabled );
30+ } else {
31+ setImageDrawable (ContactPhotoFactory .getDefaultContactPhoto (getContext (), null ));
32+ setOnClickListener (null );
33+ }
2734 }
2835
2936 private void setAvatarClickHandler (final Recipient recipient , boolean quickContactEnabled ) {
0 commit comments