From 680c838b2430645ebf9d508b9f1fb69c7918e885 Mon Sep 17 00:00:00 2001 From: PetarVelikov Date: Thu, 19 Sep 2024 09:03:45 +0200 Subject: [PATCH 1/2] Fix compile error in ImgurAttachmentFactory.java. --- .../java/com/example/chattutorial/ImgurAttachmentFactory.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java b/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java index e87c76a..a77bcaf 100644 --- a/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java +++ b/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java @@ -16,11 +16,11 @@ import io.getstream.chat.android.models.Attachment; import io.getstream.chat.android.models.Message; import io.getstream.chat.android.ui.feature.messages.list.adapter.MessageListListenerContainer; -import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.AttachmentFactory; +import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.BaseAttachmentFactory; import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.InnerAttachmentViewHolder; /** A custom attachment factory to show an imgur logo if the attachment URL is an imgur image. **/ -public class ImgurAttachmentFactory implements AttachmentFactory { +public class ImgurAttachmentFactory extends BaseAttachmentFactory { // Step 1 - Check whether the message contains an Imgur attachment From 3cdeb97a5f6a76e3614cebe22c88de19f190363b Mon Sep 17 00:00:00 2001 From: PetarVelikov Date: Thu, 19 Sep 2024 09:05:46 +0200 Subject: [PATCH 2/2] Migrate to use non-deprecated AttachmentFactory$createViewHolder. --- .../com/example/chattutorial/ImgurAttachmentFactory.java | 8 +++++--- .../com/example/chattutorial/ImgurAttachmentFactory.kt | 6 +++--- 2 files changed, 8 insertions(+), 6 deletions(-) diff --git a/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java b/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java index a77bcaf..aaaa483 100644 --- a/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java +++ b/samplejava/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.java @@ -15,11 +15,13 @@ import coil.request.ImageRequest; import io.getstream.chat.android.models.Attachment; import io.getstream.chat.android.models.Message; -import io.getstream.chat.android.ui.feature.messages.list.adapter.MessageListListenerContainer; +import io.getstream.chat.android.ui.feature.messages.list.adapter.MessageListListeners; import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.BaseAttachmentFactory; import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.InnerAttachmentViewHolder; -/** A custom attachment factory to show an imgur logo if the attachment URL is an imgur image. **/ +/** + * A custom attachment factory to show an imgur logo if the attachment URL is an imgur image. + **/ public class ImgurAttachmentFactory extends BaseAttachmentFactory { @@ -35,7 +37,7 @@ public boolean canHandle(@NonNull Message message) { @Override public InnerAttachmentViewHolder createViewHolder( @NonNull Message message, - @Nullable MessageListListenerContainer listeners, + @Nullable MessageListListeners listeners, @NonNull ViewGroup parent ) { Attachment imgurAttachment = containsImgurAttachments(message); diff --git a/samplekotlin/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.kt b/samplekotlin/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.kt index 9485495..d1c9d33 100644 --- a/samplekotlin/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.kt +++ b/samplekotlin/src/main/java/com/example/chattutorial/ImgurAttachmentFactory.kt @@ -6,7 +6,7 @@ import coil.load import com.example.chattutorial.databinding.AttachmentImgurBinding import io.getstream.chat.android.models.Attachment import io.getstream.chat.android.models.Message -import io.getstream.chat.android.ui.feature.messages.list.adapter.MessageListListenerContainer +import io.getstream.chat.android.ui.feature.messages.list.adapter.MessageListListeners import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.AttachmentFactory import io.getstream.chat.android.ui.feature.messages.list.adapter.viewholder.attachment.InnerAttachmentViewHolder @@ -23,10 +23,10 @@ class ImgurAttachmentFactory : AttachmentFactory { // over Imgur attachments override fun createViewHolder( message: Message, - listeners: MessageListListenerContainer?, + listeners: MessageListListeners?, parent: ViewGroup ): InnerAttachmentViewHolder { - val imgurAttachment = message.attachments.first() { it.isImgurAttachment() } + val imgurAttachment = message.attachments.first { it.isImgurAttachment() } val binding = AttachmentImgurBinding .inflate(LayoutInflater.from(parent.context), null, false) return ImgurAttachmentViewHolder(