From e0c1e9c64fa069e6ae9c599648d655197154c588 Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Thu, 5 Sep 2024 16:55:13 +0800 Subject: [PATCH] =?UTF-8?q?=E6=90=9C=E7=B4=A2=E7=9A=84=E6=95=B0=E6=8D=AE?= =?UTF-8?q?=E9=87=8D=E6=96=B0=E5=8A=A0=E8=BD=BD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/MainConversationListAdapter.java | 20 ++++++++++++------- .../fragment/MainMessageChatFragment.java | 18 +++++++++++++++-- 2 files changed, 29 insertions(+), 9 deletions(-) diff --git a/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java b/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java index bc31d942c..462469640 100644 --- a/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java @@ -132,11 +132,13 @@ public class MainConversationListAdapter extends ConversationListAdapter { int type = super.getItemViewType(position); if (mDataList.size() > position) { String objectName = mDataList.get(position).mCore.getObjectName(); + Log.i("聊天数据源发现","objectName::"+objectName); if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_USER")) { type = TYPE_SEARCH_USER; } else if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_CHAT")) { type = TYPE_SEARCH_CHAT; } else if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_TITLE")) { + Log.i("聊天数据源发现 ","getItemViewTypeSEARCH_TITLE"); type = TYPE_SEARCH_TITLE; } } else if (mDataList.isEmpty() || isEmpty() || srcList.isEmpty()) { @@ -156,7 +158,9 @@ public class MainConversationListAdapter extends ConversationListAdapter { } else if (getItemViewType(position) == TYPE_SEARCH_CHAT) { bindChat(holder, position); } else if (getItemViewType(position) == TYPE_SEARCH_TITLE) { + Log.i("聊天数据源设置标题头","SEARCH_TITLE::"+position); bindTitle(holder, position); + return; } else if (getItemViewType(position) != -200) { bindChatNew(holder, position); super.onBindViewHolder(holder, position); @@ -297,7 +301,8 @@ public class MainConversationListAdapter extends ConversationListAdapter { if (mContext == null) mContext = AppManager.getInstance().getLastActivity(); for (BaseUiConversation item : data) { - if (urls.contains(item.mCore.getTargetId())) continue; + if (urls.contains(item.mCore.getTargetId()) && item.mCore.getTargetId()!=null) continue; + // if ( item.mCore.getConversationTitle()==null || item.mCore.getTargetId()==null) continue; if (item.mConversationContent != null && item.mConversationContent.toString().contains("_method_")) { IMCenter.getInstance().deleteMessages(Conversation.ConversationType.PRIVATE, item.mCore.getTargetId(), @@ -316,7 +321,8 @@ public class MainConversationListAdapter extends ConversationListAdapter { IMCenter.getInstance().clearMessagesUnreadStatus(Conversation.ConversationType.PRIVATE, item.mCore.getTargetId(), null); } urls.add(item.mCore.getTargetId()); - Log.i("聊天数据源", item.mCore.getConversationTitle() + "|" + item.mCore.getPortraitUrl() + "|" + item.mCore.getTargetId()); + Log.i("聊天数据源", item.mCore.getConversationTitle() + "|" + item.mCore.getPortraitUrl() + "|" + item.mCore.getTargetId() +"|"+item.mCore.getObjectName()); + if (!tmpUids.contains(item.mCore.getTargetId())) { BaseUiConversation cn = new SingleConversation(mContext, item.mCore); srcList.add(cn); @@ -332,21 +338,21 @@ public class MainConversationListAdapter extends ConversationListAdapter { } List showData = null; if (isSearch) { - Log.i("聊天数据源", "FilterData isSearch"); - showData = UiConversationCodeUtil.FilterData(mFilter, tmp, allDataList); + // Log.i("聊天数据源", "FilterData isSearch"); + showData = tmp ;//UiConversationCodeUtil.FilterData(mFilter, tmp, allDataList); } else { allDataList = tmp; if (mFilter != FILTER_OFFLINE && mFilter != FILTER_ONLINE ) { - Log.i("聊天数据源", "FilterData notSearch"); + // Log.i("聊天数据源", "FilterData notSearch"); showData = UiConversationCodeUtil.FilterData(mFilter, allDataList); } } if (showData != null && !UiConversationCodeUtil.checkIsSame(showData, mDataList)) { - Log.i("聊天数据源", "数据源有变化" + showData.size()); + // Log.i("聊天数据源", "数据源有变化" + showData.size()); super.setDataCollection(showData); } else { - Log.i("聊天数据源", "数据源无变化"); + // Log.i("聊天数据源", "数据源无变化"); } } diff --git a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatFragment.java b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatFragment.java index e6dcc4810..abc219736 100644 --- a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatFragment.java @@ -1,6 +1,8 @@ package com.yunbao.common.fragment; import android.os.Bundle; +import android.os.Parcel; +import android.text.TextUtils; import android.util.Log; import android.view.LayoutInflater; import android.view.View; @@ -28,6 +30,8 @@ import io.rong.imkit.conversationlist.model.SingleConversation; import io.rong.imkit.event.Event; import io.rong.imlib.RongIMClient; import io.rong.imlib.model.Conversation; +import io.rong.imlib.model.Message; +import io.rong.imlib.model.MessageContent; import io.rong.imlib.model.SearchConversationResult; public class MainMessageChatFragment extends ConversationListFragment { @@ -82,6 +86,10 @@ public class MainMessageChatFragment extends ConversationListFragment { } public void search(String search) { + if (TextUtils.isEmpty(search)){ + mRefreshLayout.autoRefresh(); + return; + } ((MainConversationListAdapter) mAdapter).setSearch(); getContactsList(search); } @@ -95,10 +103,11 @@ public class MainMessageChatFragment extends ConversationListFragment { List uidList = new ArrayList<>(); BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation()); + conversation.mCore.setMessage(new Message()); conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_contacts)); + Log.i("聊天数据源设置数据", "聊天数据源: " + conversation.mCore.getObjectName()); conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE); list.add(conversation); - List data = new ArrayList<>(); System.err.println(" ----------------------->" + mAdapter.getData().size()); for (BaseUiConversation cn : ((MainConversationListAdapter) mAdapter).getSrcList()) { @@ -137,7 +146,9 @@ public class MainMessageChatFragment extends ConversationListFragment { @Override public void onSuccess(List searchConversationResults) { BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation()); + conversation.mCore.setMessage(new Message()); conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_chat_records)); + Log.i("聊天数据源设置数据", "聊天数据源: " + conversation.mCore.getObjectName()); conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE); list.add(conversation); List data = new ArrayList<>(); @@ -155,6 +166,9 @@ public class MainMessageChatFragment extends ConversationListFragment { list.remove(list.size() - 1); } list.addAll(data); + for (BaseUiConversation cn : list){ + Log.i("聊天数据源搜索前的", cn.mCore.getConversationTitle() + "|" + cn.mCore.getPortraitUrl() + "|" + cn.mCore.getTargetId()); + } ((MainConversationListAdapter) mAdapter).setDataCollectionV2(list,true); } @@ -172,7 +186,7 @@ public class MainMessageChatFragment extends ConversationListFragment { ((MainConversationListAdapter) mAdapter).clear(); System.out.println(">!>!>!>!!>" + mConversationListViewModel); subscribeUi(); - + mRefreshLayout.autoRefresh(); } @Override