只有主播B才能进行消息筛选

This commit is contained in:
ningwenqiang 2024-08-29 14:23:44 +08:00
parent c7f4c1276f
commit 02387a7321
5 changed files with 24 additions and 15 deletions

View File

@ -81,14 +81,12 @@ public class MainConversationListAdapter extends ConversationListAdapter {
if (this.mFilter == mFilter) if (this.mFilter == mFilter)
return; return;
this.mFilter = mFilter; this.mFilter = mFilter;
if (allDataList !=null && !allDataList.isEmpty()){ // if (allDataList !=null && !allDataList.isEmpty()){
super.setDataCollection(UiConversationCodeUtil.FilterData(mFilter, allDataList)); // super.setDataCollection(UiConversationCodeUtil.FilterData(mFilter, allDataList));
} // }
} }
public MainConversationListAdapter(Context mContext) { public MainConversationListAdapter(Context mContext) {
this.mContext = mContext; this.mContext = mContext;
} }
@ -287,8 +285,7 @@ public class MainConversationListAdapter extends ConversationListAdapter {
private int listHashCode = 0; private int listHashCode = 0;
@Override public synchronized void setDataCollectionV2(List<BaseUiConversation> data, boolean isSearch) {
public synchronized void setDataCollection(List<BaseUiConversation> data) {
if (data.hashCode() == listHashCode) return; if (data.hashCode() == listHashCode) return;
listHashCode = data.hashCode(); listHashCode = data.hashCode();
List<BaseUiConversation> tmp = new ArrayList<>(); List<BaseUiConversation> tmp = new ArrayList<>();
@ -335,15 +332,21 @@ public class MainConversationListAdapter extends ConversationListAdapter {
tmp.add(item); tmp.add(item);
} }
allDataList = tmp; allDataList = tmp;
if(mFilter!=FILTER_OFFLINE){ if (mFilter != FILTER_OFFLINE || isSearch == true) {
List<BaseUiConversation> showData = UiConversationCodeUtil.FilterData(mFilter, tmp); List<BaseUiConversation> showData = UiConversationCodeUtil.FilterData(mFilter, tmp);
if(!UiConversationCodeUtil.checkIsSame(showData,mDataList)){ if (!UiConversationCodeUtil.checkIsSame(showData, mDataList)) {
super.setDataCollection(showData); super.setDataCollection(showData);
} }
} }
} }
@Override
public void setDataCollection(List<BaseUiConversation> data) {
setDataCollectionV2(data, false);
}
private List<String> tmpUids = new ArrayList<>(); private List<String> tmpUids = new ArrayList<>();
public void clear() { public void clear() {

View File

@ -76,6 +76,11 @@ public class MainMessageChatFragment extends ConversationListFragment {
} }
public void refreshData() {
mRefreshLayout.autoRefresh();
//onConversationListRefresh(mRefreshLayout)
}
public void search(String search) { public void search(String search) {
((MainConversationListAdapter) mAdapter).setSearch(); ((MainConversationListAdapter) mAdapter).setSearch();
getContactsList(search); getContactsList(search);
@ -150,7 +155,7 @@ public class MainMessageChatFragment extends ConversationListFragment {
list.remove(list.size() - 1); list.remove(list.size() - 1);
} }
list.addAll(data); list.addAll(data);
mAdapter.setDataCollection(list); ((MainConversationListAdapter) mAdapter).setDataCollectionV2(list,true);
} }
@Override @Override
@ -172,9 +177,9 @@ public class MainMessageChatFragment extends ConversationListFragment {
@Override @Override
protected ConversationListAdapter onResolveAdapter() { protected ConversationListAdapter onResolveAdapter() {
MainConversationListAdapter adapter= new MainConversationListAdapter(getContext()); MainConversationListAdapter adapter = new MainConversationListAdapter(getContext());
// adapter.setFilter(chatViewModel.getChatFilter()); // adapter.setFilter(chatViewModel.getChatFilter());
this.mAdapter =adapter; this.mAdapter = adapter;
return this.mAdapter; return this.mAdapter;
} }
} }

View File

@ -175,6 +175,7 @@ public class MainMessageChatListFragment extends AbsMainMessageChatListFragment
public void setFilter(int mFilter) { public void setFilter(int mFilter) {
mAdapter.setFilter(mFilter); mAdapter.setFilter(mFilter);
chatViewModel.setChatFilter(mFilter); chatViewModel.setChatFilter(mFilter);
conversationListFragment.refreshData();
} }

View File

@ -491,7 +491,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
tabTexts.get(0).setText(WordUtil.getNewString(chatViewModel.getTitleTextId())); tabTexts.get(0).setText(WordUtil.getNewString(chatViewModel.getTitleTextId()));
ViewGroup.LayoutParams params = tabLayouts.getLayoutParams(); ViewGroup.LayoutParams params = tabLayouts.getLayoutParams();
params.width = LinearLayout.LayoutParams.WRAP_CONTENT; params.width = LinearLayout.LayoutParams.WRAP_CONTENT;
tabExpend.get(0).setVisibility(View.VISIBLE); //tabExpend.get(0).setVisibility(View.VISIBLE);
tabLayouts.setLayoutParams(params); tabLayouts.setLayoutParams(params);
} else if (userType == 1) {//主播A } else if (userType == 1) {//主播A
tab_icon.setVisibility(View.VISIBLE); tab_icon.setVisibility(View.VISIBLE);
@ -512,7 +512,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_recommend)); tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_recommend));
relativeLayouts.get(1).setVisibility(View.VISIBLE); relativeLayouts.get(1).setVisibility(View.VISIBLE);
tabTexts.get(1).setText(WordUtil.getNewString(chatViewModel.getTitleTextId())); tabTexts.get(1).setText(WordUtil.getNewString(chatViewModel.getTitleTextId()));
tabExpend.get(1).setVisibility(View.VISIBLE); // tabExpend.get(1).setVisibility(View.VISIBLE);
} else { //主播B } else { //主播B
tabExpend.get(0).setVisibility(View.VISIBLE); tabExpend.get(0).setVisibility(View.VISIBLE);
relativeLayouts.get(0).setVisibility(View.VISIBLE); relativeLayouts.get(0).setVisibility(View.VISIBLE);

View File

@ -367,7 +367,7 @@
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:visibility="gone" android:visibility="gone"
tools:visibility="visible" tools:visibility="visible"
app:constraint_referenced_ids="tab1,tab_icon,tab_line1"/> app:constraint_referenced_ids="tab1,tab_line1"/>
<View <View
android:id="@+id/view2" android:id="@+id/view2"