From 02387a7321b1cf94b4225b61db828db2d85ff71e Mon Sep 17 00:00:00 2001 From: ningwenqiang Date: Thu, 29 Aug 2024 14:23:44 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8F=AA=E6=9C=89=E4=B8=BB=E6=92=ADB=E6=89=8D?= =?UTF-8?q?=E8=83=BD=E8=BF=9B=E8=A1=8C=E6=B6=88=E6=81=AF=E7=AD=9B=E9=80=89?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../adapter/MainConversationListAdapter.java | 21 +++++++++++-------- .../fragment/MainMessageChatFragment.java | 11 +++++++--- .../fragment/MainMessageChatListFragment.java | 1 + .../main/views/MainMessageViewHolder.java | 4 ++-- .../src/main/res/layout/view_main_message.xml | 2 +- 5 files changed, 24 insertions(+), 15 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 4835ceb5a..79f0c0892 100644 --- a/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java @@ -81,14 +81,12 @@ public class MainConversationListAdapter extends ConversationListAdapter { if (this.mFilter == mFilter) return; this.mFilter = mFilter; - if (allDataList !=null && !allDataList.isEmpty()){ - super.setDataCollection(UiConversationCodeUtil.FilterData(mFilter, allDataList)); - } +// if (allDataList !=null && !allDataList.isEmpty()){ +// super.setDataCollection(UiConversationCodeUtil.FilterData(mFilter, allDataList)); +// } } - - public MainConversationListAdapter(Context mContext) { this.mContext = mContext; } @@ -287,8 +285,7 @@ public class MainConversationListAdapter extends ConversationListAdapter { private int listHashCode = 0; - @Override - public synchronized void setDataCollection(List data) { + public synchronized void setDataCollectionV2(List data, boolean isSearch) { if (data.hashCode() == listHashCode) return; listHashCode = data.hashCode(); List tmp = new ArrayList<>(); @@ -335,15 +332,21 @@ public class MainConversationListAdapter extends ConversationListAdapter { tmp.add(item); } allDataList = tmp; - if(mFilter!=FILTER_OFFLINE){ + if (mFilter != FILTER_OFFLINE || isSearch == true) { List showData = UiConversationCodeUtil.FilterData(mFilter, tmp); - if(!UiConversationCodeUtil.checkIsSame(showData,mDataList)){ + if (!UiConversationCodeUtil.checkIsSame(showData, mDataList)) { super.setDataCollection(showData); } } } + @Override + public void setDataCollection(List data) { + setDataCollectionV2(data, false); + } + + private List tmpUids = new ArrayList<>(); public void clear() { 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 fbd7bb028..e6dcc4810 100644 --- a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatFragment.java @@ -76,6 +76,11 @@ public class MainMessageChatFragment extends ConversationListFragment { } + public void refreshData() { + mRefreshLayout.autoRefresh(); + //onConversationListRefresh(mRefreshLayout) + } + public void search(String search) { ((MainConversationListAdapter) mAdapter).setSearch(); getContactsList(search); @@ -150,7 +155,7 @@ public class MainMessageChatFragment extends ConversationListFragment { list.remove(list.size() - 1); } list.addAll(data); - mAdapter.setDataCollection(list); + ((MainConversationListAdapter) mAdapter).setDataCollectionV2(list,true); } @Override @@ -172,9 +177,9 @@ public class MainMessageChatFragment extends ConversationListFragment { @Override protected ConversationListAdapter onResolveAdapter() { - MainConversationListAdapter adapter= new MainConversationListAdapter(getContext()); + MainConversationListAdapter adapter = new MainConversationListAdapter(getContext()); // adapter.setFilter(chatViewModel.getChatFilter()); - this.mAdapter =adapter; + this.mAdapter = adapter; return this.mAdapter; } } diff --git a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java index 35f9a6f70..b85ed04ac 100644 --- a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java @@ -175,6 +175,7 @@ public class MainMessageChatListFragment extends AbsMainMessageChatListFragment public void setFilter(int mFilter) { mAdapter.setFilter(mFilter); chatViewModel.setChatFilter(mFilter); + conversationListFragment.refreshData(); } diff --git a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java index ff8e5df8c..10a092bb6 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java @@ -491,7 +491,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { tabTexts.get(0).setText(WordUtil.getNewString(chatViewModel.getTitleTextId())); ViewGroup.LayoutParams params = tabLayouts.getLayoutParams(); params.width = LinearLayout.LayoutParams.WRAP_CONTENT; - tabExpend.get(0).setVisibility(View.VISIBLE); + //tabExpend.get(0).setVisibility(View.VISIBLE); tabLayouts.setLayoutParams(params); } else if (userType == 1) {//主播A 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)); 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); diff --git a/main/src/main/res/layout/view_main_message.xml b/main/src/main/res/layout/view_main_message.xml index 5bc51d7be..d1c11947c 100644 --- a/main/src/main/res/layout/view_main_message.xml +++ b/main/src/main/res/layout/view_main_message.xml @@ -367,7 +367,7 @@ android:layout_height="wrap_content" android:visibility="gone" tools:visibility="visible" - app:constraint_referenced_ids="tab1,tab_icon,tab_line1"/> + app:constraint_referenced_ids="tab1,tab_line1"/>