消息分类后的搜索进行优化
This commit is contained in:
parent
08480af796
commit
b4574f730d
@ -674,6 +674,8 @@ rx.internal.util.atomic.LinkedQueueNode* consumerNode;
|
||||
|
||||
-keep class androidx.constraintlayout.widget.ConstraintLayout { <init>(android.content.Context, android.util.AttributeSet); }
|
||||
|
||||
-keep class androidx.constraintlayout.widget.Group { <init>(android.content.Context, android.util.AttributeSet); }
|
||||
|
||||
-keep class androidx.constraintlayout.widget.Guideline { <init>(android.content.Context, android.util.AttributeSet); }
|
||||
|
||||
-keep class androidx.coordinatorlayout.widget.CoordinatorLayout { <init>(android.content.Context, android.util.AttributeSet); }
|
||||
|
@ -81,9 +81,7 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
if (this.mFilter == mFilter)
|
||||
return;
|
||||
this.mFilter = mFilter;
|
||||
// if (allDataList !=null && !allDataList.isEmpty()){
|
||||
// super.setDataCollection(UiConversationCodeUtil.FilterData(mFilter, allDataList));
|
||||
// }
|
||||
|
||||
}
|
||||
|
||||
|
||||
@ -93,8 +91,11 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
|
||||
public void setSrcList(List<BaseUiConversation> srcList) {
|
||||
this.srcList = srcList;
|
||||
super.setDataCollection(UiConversationCodeUtil.FilterData(mFilter, allDataList));
|
||||
// notifyDataSetChanged();
|
||||
if (mFilter== FILTER_OFFLINE || mFilter == FILTER_ONLINE) {
|
||||
super.setDataCollection(UiConversationCodeUtil.FilterData(mFilter, allDataList));
|
||||
}else {
|
||||
notifyDataSetChanged();
|
||||
}
|
||||
}
|
||||
|
||||
public void setOnRefreshListener(OnRecyclerListRefreshListener<List<BaseUiConversation>> onRefreshListener) {
|
||||
@ -190,16 +191,16 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
|
||||
|
||||
Message message = conversation.mCore.getMessage();
|
||||
if (message != null && message.getMessageDirection()==Message.MessageDirection.SEND){
|
||||
holder.setVisible(R.id.rc_conversation_unread_tv, true);
|
||||
if (conversation.mCore.getSentStatus() == Message.SentStatus.READ){
|
||||
holder.setTextColor(R.id.rc_conversation_unread_tv, ContextCompat.getColor(holder.itemView.getContext(), R.color.rc_secondary_color));
|
||||
holder.setText(R.id.rc_conversation_unread_tv, WordUtil.getNewString(R.string.message_chat_msg_read_tip));
|
||||
}else {
|
||||
holder.setTextColor(R.id.rc_conversation_unread_tv, ContextCompat.getColor(holder.itemView.getContext(), R.color.red));
|
||||
holder.setText(R.id.rc_conversation_unread_tv, WordUtil.getNewString(R.string.message_chat_msg_unread_tip));
|
||||
}
|
||||
}else {
|
||||
if (message != null && message.getMessageDirection() == Message.MessageDirection.SEND) {
|
||||
holder.setVisible(R.id.rc_conversation_unread_tv, true);
|
||||
if (conversation.mCore.getSentStatus() == Message.SentStatus.READ) {
|
||||
holder.setTextColor(R.id.rc_conversation_unread_tv, ContextCompat.getColor(holder.itemView.getContext(), R.color.rc_secondary_color));
|
||||
holder.setText(R.id.rc_conversation_unread_tv, WordUtil.getNewString(R.string.message_chat_msg_read_tip));
|
||||
} else {
|
||||
holder.setTextColor(R.id.rc_conversation_unread_tv, ContextCompat.getColor(holder.itemView.getContext(), R.color.red));
|
||||
holder.setText(R.id.rc_conversation_unread_tv, WordUtil.getNewString(R.string.message_chat_msg_unread_tip));
|
||||
}
|
||||
} else {
|
||||
holder.setVisible(R.id.rc_conversation_unread_tv, false);
|
||||
}
|
||||
|
||||
@ -285,7 +286,8 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
if (data.hashCode() == listHashCode) return;
|
||||
listHashCode = data.hashCode();
|
||||
List<BaseUiConversation> tmp = new ArrayList<>();
|
||||
Log.i("聊天数据源", "setDataCollection: " + data.hashCode());
|
||||
Log.i("聊天数据源", "size()" + data.size() + " setDataCollection: " + data.hashCode());
|
||||
|
||||
List<String> urls = new ArrayList<>();
|
||||
if (srcList == null) {
|
||||
srcList = new ArrayList<>();
|
||||
@ -327,13 +329,24 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
}
|
||||
tmp.add(item);
|
||||
}
|
||||
allDataList = tmp;
|
||||
if (mFilter != FILTER_OFFLINE || isSearch == true) {
|
||||
List<BaseUiConversation> showData = UiConversationCodeUtil.FilterData(mFilter, tmp);
|
||||
if (!UiConversationCodeUtil.checkIsSame(showData, mDataList)) {
|
||||
super.setDataCollection(showData);
|
||||
List<BaseUiConversation> showData = null;
|
||||
if (isSearch) {
|
||||
Log.i("聊天数据源", "FilterData isSearch");
|
||||
showData = UiConversationCodeUtil.FilterData(mFilter, tmp, allDataList);
|
||||
} else {
|
||||
allDataList = tmp;
|
||||
if (mFilter != FILTER_OFFLINE)
|
||||
{
|
||||
Log.i("聊天数据源", "FilterData notSearch");
|
||||
showData = UiConversationCodeUtil.FilterData(mFilter, allDataList);
|
||||
}
|
||||
}
|
||||
if (showData != null && !UiConversationCodeUtil.checkIsSame(showData, mDataList)) {
|
||||
Log.i("聊天数据源", "数据源有变化" + showData.size());
|
||||
super.setDataCollection(showData);
|
||||
} else {
|
||||
Log.i("聊天数据源", "数据源无变化");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@ -346,6 +359,7 @@ public class MainConversationListAdapter extends ConversationListAdapter {
|
||||
private List<String> tmpUids = new ArrayList<>();
|
||||
|
||||
public void clear() {
|
||||
Log.i("聊天数据源", "clear: " + mDataList.size());
|
||||
mDataList.clear();
|
||||
if (srcList != null) {
|
||||
srcList.clear();
|
||||
|
@ -1295,7 +1295,7 @@ public interface PDLiveApi {
|
||||
@Query("open_off") int status
|
||||
);
|
||||
|
||||
@GET("/api/public/?service=Pdlmsg.sendBefore")
|
||||
@GET("/api/public/?service=Pdlmsg.sendBefore&new_pop=1")
|
||||
Observable<ResponseModel<MessageSayHiBean>> getMessageSayHiTimer(
|
||||
);
|
||||
|
||||
|
@ -71,6 +71,77 @@ public class UiConversationCodeUtil {
|
||||
}
|
||||
|
||||
|
||||
private static boolean isContains(List<BaseUiConversation> list, BaseUiConversation item) {
|
||||
// 根据 item.mCore.getChannelId() 判断 list 是否包含
|
||||
if (list == null || list.isEmpty() || item == null || item.mCore == null) {
|
||||
return false;
|
||||
}
|
||||
for (BaseUiConversation conversation : list) {
|
||||
// 增加空值检查
|
||||
if (conversation != null && conversation.mCore != null
|
||||
&& conversation.mCore.getTargetId() != null
|
||||
&& conversation.mCore.getTargetId().equals(item.mCore.getTargetId())) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
|
||||
public static List<BaseUiConversation> FilterData(int filterType, List<BaseUiConversation> keyList,List<BaseUiConversation> srcList) {
|
||||
List<BaseUiConversation> showData = new ArrayList<>();
|
||||
if (keyList == null || keyList.isEmpty())
|
||||
return showData;
|
||||
Log.i("MainConversationListAdapter", "FilterData: 源" + keyList.size());
|
||||
switch (filterType) {
|
||||
case FILTER_ALL:
|
||||
showData = keyList;
|
||||
break;
|
||||
case FILTER_ONLINE:
|
||||
for (BaseUiConversation conversation : srcList) {
|
||||
if ("0".equals(conversation.mCore.getDraft()) && isContains(keyList, conversation)) {
|
||||
showData.add(conversation);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FILTER_OFFLINE:
|
||||
for (BaseUiConversation conversation : keyList) {
|
||||
if (!"0".equals(conversation.mCore.getDraft())) {
|
||||
showData.add(conversation);
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FILTER_READ:
|
||||
for (BaseUiConversation conversation : keyList)
|
||||
if (conversation.mCore.getMessage() != null && conversation.mCore.getMessage().getMessageDirection() != null) {
|
||||
if (conversation.mCore.getMessage().getMessageDirection() == Message.MessageDirection.SEND) {
|
||||
if (conversation.mCore.getSentStatus() == Message.SentStatus.READ) {
|
||||
showData.add(conversation);
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
case FILTER_UNREAD:
|
||||
for (BaseUiConversation conversation : keyList) {
|
||||
boolean isRead;
|
||||
if (conversation.mCore.getMessage() != null && conversation.mCore.getMessage().getMessageDirection() != null) {
|
||||
if (conversation.mCore.getMessage().getMessageDirection() == Message.MessageDirection.SEND) {
|
||||
if (conversation.mCore.getSentStatus() != Message.SentStatus.READ) {
|
||||
showData.add(conversation);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
break;
|
||||
}
|
||||
Log.i("MainConversationListAdapter", "FilterData: 结果" + showData.size());
|
||||
return showData;
|
||||
}
|
||||
|
||||
|
||||
|
||||
|
||||
public static List<BaseUiConversation> FilterData(int filterType, List<BaseUiConversation> data) {
|
||||
List<BaseUiConversation> showData = new ArrayList<>();
|
||||
if (data == null || data.isEmpty())
|
||||
@ -106,7 +177,6 @@ public class UiConversationCodeUtil {
|
||||
break;
|
||||
case FILTER_UNREAD:
|
||||
for (BaseUiConversation conversation : data) {
|
||||
boolean isRead;
|
||||
if (conversation.mCore.getMessage() != null && conversation.mCore.getMessage().getMessageDirection() != null) {
|
||||
if (conversation.mCore.getMessage().getMessageDirection() == Message.MessageDirection.SEND) {
|
||||
if (conversation.mCore.getSentStatus() != Message.SentStatus.READ) {
|
||||
@ -117,6 +187,7 @@ public class UiConversationCodeUtil {
|
||||
}
|
||||
break;
|
||||
}
|
||||
Log.i("MainConversationListAdapter", "FilterData: 结果" + showData.size());
|
||||
return showData;
|
||||
}
|
||||
|
||||
|
@ -90,6 +90,10 @@
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
tools:text="[已读]"
|
||||
app:layout_constraintEnd_toStartOf="@id/rc_conversation_content"
|
||||
android:layout_marginEnd="6dp"
|
||||
android:visibility="gone"
|
||||
tools:visibility="visible"
|
||||
android:textColor="@color/rc_secondary_color"
|
||||
android:textSize="13dp" />
|
||||
|
||||
@ -99,7 +103,6 @@
|
||||
style="@style/TextStyle.Alignment"
|
||||
android:layout_width="0dp"
|
||||
android:layout_height="wrap_content"
|
||||
android:paddingStart="6dp"
|
||||
android:paddingEnd="6dp"
|
||||
android:ellipsize="end"
|
||||
android:maxLines="1"
|
||||
|
@ -1609,6 +1609,6 @@
|
||||
<string name="all_chats">全部聊天</string>
|
||||
<string name="online_only">僅展示在線</string>
|
||||
<string name="offline_only">僅展示離線</string>
|
||||
<string name="read_only">僅展示對方已讀</string>
|
||||
<string name="unread_only">僅展示對方未讀</string>
|
||||
<string name="read_only">展示對方已讀</string>
|
||||
<string name="unread_only">展示對方未讀</string>
|
||||
</resources>
|
||||
|
@ -512,7 +512,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
|
||||
tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_recommend));
|
||||
relativeLayouts.get(1).setVisibility(View.VISIBLE);
|
||||
tabTexts.get(1).setText(WordUtil.getNewString(chatViewModel.getTitleTextId()));
|
||||
// tabExpend.get(1).setVisibility(View.VISIBLE);
|
||||
tabExpend.get(1).setVisibility(View.VISIBLE);
|
||||
} else { //主播B
|
||||
tabExpend.get(0).setVisibility(View.VISIBLE);
|
||||
relativeLayouts.get(0).setVisibility(View.VISIBLE);
|
||||
|
Loading…
Reference in New Issue
Block a user