1919import io .getstream .chat .android .ui .message .list .adapter .viewholder .attachment .AttachmentFactory ;
2020import io .getstream .chat .android .ui .message .list .adapter .viewholder .attachment .InnerAttachmentViewHolder ;
2121
22- /** A custom attachment factory to show an imgur logo if the attachment URL is an imgur image. **/
22+ /**
23+ * A custom attachment factory to show an imgur logo if the attachment URL is an imgur image.
24+ **/
2325public class ImgurAttachmentFactory implements AttachmentFactory {
2426
2527
@@ -57,10 +59,10 @@ private Attachment containsImgurAttachments(@NotNull Message message) {
5759 return null ;
5860 }
5961
60- private class ImgurAttachmentViewHolder extends InnerAttachmentViewHolder {
62+ private static class ImgurAttachmentViewHolder extends InnerAttachmentViewHolder {
6163
6264 public ImgurAttachmentViewHolder (AttachmentImgurBinding binding ,
63- Attachment imgurAttachment ) {
65+ @ Nullable Attachment imgurAttachment ) {
6466 super (binding .getRoot ());
6567
6668 ShapeAppearanceModel shapeAppearanceModel = binding .ivMediaThumb .getShapeAppearanceModel ()
@@ -70,14 +72,16 @@ public ImgurAttachmentViewHolder(AttachmentImgurBinding binding,
7072
7173 binding .ivMediaThumb .setShapeAppearanceModel (shapeAppearanceModel );
7274
73- ImageRequest imageRequest = new ImageRequest .Builder (binding .getRoot ().getContext ())
74- .data (imgurAttachment .getImageUrl ())
75- .allowHardware (false )
76- .crossfade (true )
77- .placeholder (R .drawable .stream_ui_picture_placeholder )
78- .target (binding .ivMediaThumb )
79- .build ();
80- Coil .imageLoader (binding .getRoot ().getContext ()).enqueue (imageRequest );
75+ if (imgurAttachment != null ) {
76+ ImageRequest imageRequest = new ImageRequest .Builder (binding .getRoot ().getContext ())
77+ .data (imgurAttachment .getImageUrl ())
78+ .allowHardware (false )
79+ .crossfade (true )
80+ .placeholder (R .drawable .stream_ui_picture_placeholder )
81+ .target (binding .ivMediaThumb )
82+ .build ();
83+ Coil .imageLoader (binding .getRoot ().getContext ()).enqueue (imageRequest );
84+ }
8185 }
8286 }
8387}
0 commit comments