From c5b0cde2bd1c43339d5b6a2a360fc1d9d3e9ffe4 Mon Sep 17 00:00:00 2001 From: kaixed Date: Thu, 12 Dec 2024 16:19:00 +0800 Subject: [PATCH] =?UTF-8?q?fix:=20=E4=BF=AE=E5=A4=8D=E4=B8=BB=E9=A1=B5?= =?UTF-8?q?=E8=81=8A=E5=A4=A9=E5=88=97=E8=A1=A8=E5=A4=B4=E5=83=8F=E6=9C=AA?= =?UTF-8?q?=E5=AF=B9=E5=BA=94=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../java/com/kaixed/kchat/ui/activity/ChatActivity.kt | 1 - .../main/java/com/kaixed/kchat/ui/adapter/ChatAdapter.kt | 9 +++++++-- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/app/src/main/java/com/kaixed/kchat/ui/activity/ChatActivity.kt b/app/src/main/java/com/kaixed/kchat/ui/activity/ChatActivity.kt index c365850..4c0cb10 100644 --- a/app/src/main/java/com/kaixed/kchat/ui/activity/ChatActivity.kt +++ b/app/src/main/java/com/kaixed/kchat/ui/activity/ChatActivity.kt @@ -443,7 +443,6 @@ class ChatActivity : BaseActivity(), OnItemClickListener, timestamp = System.currentTimeMillis(), senderId = username, takerId = talkerId, - avatarUrl = getAvatarUrl(), type = type, ) val msg = MessageProcessor.processorMsg(messages) diff --git a/app/src/main/java/com/kaixed/kchat/ui/adapter/ChatAdapter.kt b/app/src/main/java/com/kaixed/kchat/ui/adapter/ChatAdapter.kt index 4106991..d0189d5 100644 --- a/app/src/main/java/com/kaixed/kchat/ui/adapter/ChatAdapter.kt +++ b/app/src/main/java/com/kaixed/kchat/ui/adapter/ChatAdapter.kt @@ -19,6 +19,7 @@ import com.kaixed.kchat.data.local.entity.Messages import com.kaixed.kchat.databinding.ChatRecycleItemCustomNormalBinding import com.kaixed.kchat.databinding.ChatRecycleItemImageNormalBinding import com.kaixed.kchat.databinding.ChatRecycleItemTipBinding +import com.kaixed.kchat.utils.ConstantsUtil import com.kaixed.kchat.utils.ConstantsUtil.getUsername import com.kaixed.kchat.utils.PopWindowUtil.showPopupWindow import com.kaixed.kchat.utils.TextUtil @@ -161,7 +162,9 @@ class ChatAdapter( contentId = binding.tvMsgContent.id, contentMineId = binding.tvMsgContentMine.id ) - Glide.with(binding.root.context).load(message.avatarUrl) + val avatarUrl = + if (sender) ConstantsUtil.getAvatarUrl() else message.avatarUrl + Glide.with(binding.root.context).load(avatarUrl) .into(if (sender) binding.ifvAvatarMine else binding.ifvAvatar) val contentView = if (sender) binding.tvMsgContentMine else binding.tvMsgContent @@ -179,7 +182,9 @@ class ChatAdapter( RecyclerView.ViewHolder(binding.root), HasTimer { fun bindData(message: Messages) { val sender = message.senderId == getUsername() - Glide.with(binding.root.context).load(message.avatarUrl) + val avatarUrl = + if (sender) ConstantsUtil.getAvatarUrl() else message.avatarUrl + Glide.with(binding.root.context).load(avatarUrl) .into(if (sender) binding.ifvAvatarMine else binding.ifvAvatar) setViewVisibility( parentView = binding.root,