From 47030425cd842030d549c8ef35bd8a30d20d57c9 Mon Sep 17 00:00:00 2001 From: 18401019693 Date: Sat, 23 Jul 2022 18:14:42 +0800 Subject: [PATCH] 11111 --- .../live/dialog/PDLiveMessageListAdapter.java | 13 ++-- .../res/layout/rc_conversationlist_item.xml | 61 +++++++++++-------- .../PDLiveCustomConversationProvider.java | 15 +++-- 3 files changed, 54 insertions(+), 35 deletions(-) diff --git a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java index e6bf05489..7fc26cb6e 100644 --- a/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java +++ b/live/src/main/java/com/yunbao/live/dialog/PDLiveMessageListAdapter.java @@ -31,16 +31,18 @@ public class PDLiveMessageListAdapter extends MessageListAdapter { Message.MessageDirection messageDirection = mDataList.get(position).getMessage().getMessageDirection(); Message.SentStatus sentStatus = mDataList.get(position).getMessage().getSentStatus(); ImageView readReceipt = holder.getConvertView().findViewById(R.id.rc_read_receipt); + readReceipt.setVisibility(View.GONE); ImageView readReceiptNew = holder.getConvertView().findViewById(R.id.rc_read_receipt_new); - if (readReceipt != null && readReceiptNew != null) { - if (readReceipt.getVisibility() == View.VISIBLE) { - readReceipt.setVisibility(View.GONE); + if (!mDataList.get(position).getMessage().getSenderUserId().equals(mDataList.get(position).getTargetId())) { + if (sentStatus.equals(Message.SentStatus.READ)) { readReceiptNew.setBackgroundResource(R.mipmap.icon_message_read); } else { - if (messageDirection.equals(Message.MessageDirection.SEND) && sentStatus.equals(Message.SentStatus.SENT)) - readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread); + readReceiptNew.setBackgroundResource(R.mipmap.icon_message_unread); } + } else { + readReceipt.setVisibility(View.GONE); } + holder.getConvertView().setOnTouchListener(new View.OnTouchListener() { @Override public boolean onTouch(View v, MotionEvent event) { @@ -50,4 +52,5 @@ public class PDLiveMessageListAdapter extends MessageListAdapter { } }); } + } diff --git a/live/src/main/res/layout/rc_conversationlist_item.xml b/live/src/main/res/layout/rc_conversationlist_item.xml index 462eac0b1..0e63cb8fa 100644 --- a/live/src/main/res/layout/rc_conversationlist_item.xml +++ b/live/src/main/res/layout/rc_conversationlist_item.xml @@ -26,30 +26,6 @@ android:scaleType="centerCrop" /> - - - - - - @@ -86,18 +62,51 @@ android:layout_marginStart="15dp" android:layout_marginEnd="4dp" /> + + + + + + + + + diff --git a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java index 74d3ec39d..5d73a3316 100644 --- a/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java +++ b/main/src/main/java/com/yunbao/main/utils/PDLiveCustomConversationProvider.java @@ -1,6 +1,8 @@ package com.yunbao.main.utils; +import android.text.TextUtils; import android.util.Log; +import android.view.View; import android.view.ViewGroup; import android.widget.ImageView; @@ -34,18 +36,23 @@ public class PDLiveCustomConversationProvider extends BaseConversationProvider { @Override public void bindViewHolder(ViewHolder holder, BaseUiConversation uiConversation, int position, List list, IViewProviderListener listener) { - //根据业务需要,自定义处理 super.bindViewHolder(holder, uiConversation, position, list, listener); - if (list.size() > 0) { - Message.ReceivedStatus receivedStatus = list.get(position).mCore.getReceivedStatus(); + Message.SentStatus sentStatus = list.get(position).mCore.getSentStatus(); ImageView readReceipt = holder.itemView.findViewById(com.yunbao.live.R.id.rc_read_receipt_new); - if (receivedStatus.isRead()) { + View rcMargin = holder.itemView.findViewById(com.yunbao.live.R.id.rc_margin); + if (TextUtils.equals(list.get(position).mCore.getSenderUserId(), list.get(position).mCore.getTargetId())) { + readReceipt.setVisibility(View.GONE); + rcMargin.setVisibility(View.VISIBLE); + } + if (sentStatus == Message.SentStatus.READ) { readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_read); } else { readReceipt.setBackgroundResource(com.yunbao.live.R.mipmap.icon_messagelist_unread); } + + }