Skip to content

Commit b7df9c0

Browse files
committed
- Remove linter warnings
1 parent c687504 commit b7df9c0

File tree

1 file changed

+15
-11
lines changed

1 file changed

+15
-11
lines changed

samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java

Lines changed: 15 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -19,7 +19,9 @@
1919
import io.getstream.chat.android.ui.message.list.adapter.viewholder.attachment.AttachmentFactory;
2020
import 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+
**/
2325
public 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

Comments
 (0)