update消息页面接入融云搜索历史记录
This commit is contained in:
parent
a22e600b52
commit
e2e7ce8183
@ -51,7 +51,7 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
String objectName = mDataList.get(position).mCore.getObjectName();
|
||||
if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_USER")) {
|
||||
type = TYPE_SEARCH_USER;
|
||||
} else if (!StringUtil.isEmpty(objectName) && objectName.equals("SEARCH_CHAT")) {
|
||||
} else if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_CHAT")) {
|
||||
type = TYPE_SEARCH_CHAT;
|
||||
} else if (!StringUtil.isEmpty(objectName) && objectName.startsWith("SEARCH_TITLE")) {
|
||||
type = TYPE_SEARCH_TITLE;
|
||||
@ -103,7 +103,10 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
private void bindChat(ViewHolder holder, int position) {
|
||||
ImgLoader.display(holder.getContext(), mDataList.get(position).mCore.getPortraitUrl(), holder.getView(R.id.rc_conversation_portrait));
|
||||
holder.setText(R.id.rc_conversation_title, mDataList.get(position).mCore.getConversationTitle());
|
||||
Spanned spanned = Html.fromHtml(WordUtil.getNewString(R.string.activity_msg_list_include) + "<font color='#FF4874'>" + mDataList.get(position).mConversationContent + "</font>");
|
||||
String title = mDataList.get(position).mConversationContent.toString();
|
||||
String key = mDataList.get(position).mCore.getObjectName().replace("SEARCH_CHAT", "");
|
||||
title = title.replace(key, "<font color='#FF4874'>" + key + "</font>");
|
||||
Spanned spanned = Html.fromHtml(WordUtil.getNewString(R.string.activity_msg_list_include) +title);
|
||||
((TextView) holder.getView(R.id.rc_conversation_content)).setText(spanned);
|
||||
int type = mDataList.get(position).mCore.getMentionedCount();
|
||||
holder.getView(R.id.itemDecorationTop).setVisibility(View.GONE);
|
||||
|
@ -23,7 +23,9 @@ import io.rong.imkit.conversationlist.ConversationListAdapter;
|
||||
import io.rong.imkit.conversationlist.ConversationListFragment;
|
||||
import io.rong.imkit.conversationlist.model.BaseUiConversation;
|
||||
import io.rong.imkit.conversationlist.model.SingleConversation;
|
||||
import io.rong.imlib.RongIMClient;
|
||||
import io.rong.imlib.model.Conversation;
|
||||
import io.rong.imlib.model.SearchConversationResult;
|
||||
|
||||
public class MainMessageChatFragment extends ConversationListFragment {
|
||||
|
||||
@ -70,19 +72,21 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
||||
}
|
||||
|
||||
private void getChatRecordList(List<BaseUiConversation> list, String search) {
|
||||
Conversation.ConversationType[] conversationTypes = {Conversation.ConversationType.PRIVATE};
|
||||
String[] messageTypeObjectNames = {"RC:TxtMsg"};
|
||||
|
||||
RongIMClient.getInstance().searchConversations(search, conversationTypes, messageTypeObjectNames, new RongIMClient.ResultCallback<List<SearchConversationResult>>() {
|
||||
@Override
|
||||
public void onSuccess(List<SearchConversationResult> searchConversationResults) {
|
||||
BaseUiConversation conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_TITLE" + WordUtil.getNewString(R.string.activity_msg_list_title_chat_records));
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
list.add(conversation);
|
||||
List<BaseUiConversation> data = new ArrayList<>();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
conversation = new SingleConversation(getContext(), new Conversation());
|
||||
conversation.mCore.setObjectName("SEARCH_CHAT");
|
||||
conversation.mCore.setConversationTitle(search + "|" + i);
|
||||
conversation.mCore.setConversationType(Conversation.ConversationType.PRIVATE);
|
||||
conversation.mConversationContent = new SpannableString(search);
|
||||
conversation.mCore.setPortraitUrl("https://downs.yaoulive.com/defaultpink.png");
|
||||
data.add(conversation);
|
||||
for (SearchConversationResult result : searchConversationResults) {
|
||||
BaseUiConversation cn = new SingleConversation(getContext(), result.getConversation());
|
||||
cn.mCore.setObjectName("SEARCH_CHAT"+search);
|
||||
data.add(cn);
|
||||
}
|
||||
if (data.size() == 1) {
|
||||
data.get(0).mCore.setMentionedCount(3);
|
||||
@ -97,6 +101,17 @@ public class MainMessageChatFragment extends ConversationListFragment {
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onError(RongIMClient.ErrorCode e) {
|
||||
ToastUtil.show("搜索出错了:"+e.getMessage());
|
||||
mAdapter.setDataCollection(list);
|
||||
mAdapter.notifyDataSetChanged();
|
||||
}
|
||||
});
|
||||
|
||||
|
||||
}
|
||||
|
||||
public void onChatList() {
|
||||
mAdapter.getData().clear();
|
||||
subscribeUi();
|
||||
|
@ -261,6 +261,7 @@
|
||||
<!-- 此容器用于动态放置 fragment-->
|
||||
<FrameLayout
|
||||
android:id="@+id/container"
|
||||
android:layout_marginBottom="50dp"
|
||||
android:layout_width="match_parent"
|
||||
android:layout_height="match_parent" />
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user