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 50a222466..a639fd5ea 100644 --- a/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java +++ b/common/src/main/java/com/yunbao/common/adapter/MainConversationListAdapter.java @@ -12,6 +12,7 @@ import android.widget.ImageView; import android.widget.TextView; import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; import com.blankj.utilcode.util.LogUtils; import com.yunbao.common.R; @@ -27,6 +28,8 @@ import com.yunbao.common.utils.ViewUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.weight.ViewClicksAntiShake; +import org.spongycastle.jcajce.provider.asymmetric.rsa.ISOSignatureSpi; + import java.util.ArrayList; import java.util.HashMap; import java.util.List; @@ -52,18 +55,80 @@ public class MainConversationListAdapter extends ConversationListAdapter { public static final int TYPE_SEARCH_USER = 510; public static final int TYPE_SEARCH_CHAT = 520; private List srcList; + private List allDataList; private Context mContext; private boolean isChat = true; private OnRecyclerListRefreshListener> onRefreshListener; private Map timerMap = new HashMap<>(); + + public static final int FILTER_OFFLINE = 0; + public static final int FILTER_ONLINE = 1; + public static final int FILTER_UNREAD = 2; + public static final int FILTER_READ = 4; + public static final int FILTER_ALL = 7; + + private int mFilter = FILTER_ALL; + + public int getFilter() { + return mFilter; + } + + public void setFilter(int mFilter) { + this.mFilter = mFilter; + super.setDataCollection(FilterData(mFilter, allDataList)); + } + + private List FilterData(int filterType, List data){ + List showData= new ArrayList<>();; + Log.i("MainConversationListAdapter", "FilterData: 源" + data.size()); + switch (filterType) { + case FILTER_ALL: + showData = data; + break; + case FILTER_ONLINE : + for (BaseUiConversation conversation : data) { + if ("0".equals(conversation.mCore.getDraft())) { + showData.add(conversation); + } + } + break; + case FILTER_OFFLINE: + for (BaseUiConversation conversation : data) { + if (!"0".equals(conversation.mCore.getDraft())) { + showData.add(conversation); + } + } + break; + case FILTER_READ: + for (BaseUiConversation conversation : data) { + if (conversation.mCore.getUnreadMessageCount() <= 0) { + showData.add(conversation); + } + } + break; + case FILTER_UNREAD: + for (BaseUiConversation conversation : data) { + if (conversation.mCore.getUnreadMessageCount() > 0) { + showData.add(conversation); + } + } + break; + } + Log.i("MainConversationListAdapter", "FilterData: 结果" + showData.size()); + return showData; + } + + + public MainConversationListAdapter(Context mContext) { this.mContext = mContext; } public void setSrcList(List srcList) { - this.srcList = srcList; - notifyDataSetChanged(); + this.srcList = srcList; + super.setDataCollection(FilterData(mFilter, allDataList)); + // notifyDataSetChanged(); } public void setOnRefreshListener(OnRecyclerListRefreshListener> onRefreshListener) { @@ -87,7 +152,7 @@ public class MainConversationListAdapter extends ConversationListAdapter { View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.item_main_msg_search_chat, parent, false); holder = ViewHolder.createViewHolder(parent.getContext(), view); } else if (viewType != -200) { - View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rc_conversationlist_item, parent, false); + View view = LayoutInflater.from(parent.getContext()).inflate(R.layout.rc_conversationlist_item2, parent, false); holder = ViewHolder.createViewHolder(parent.getContext(), view); } else { holder = super.onCreateViewHolder(parent, viewType); @@ -126,13 +191,62 @@ public class MainConversationListAdapter extends ConversationListAdapter { } else if (getItemViewType(position) == TYPE_SEARCH_TITLE) { bindTitle(holder, position); } else if (getItemViewType(position) != -200) { + bindChatNew(holder, position); super.onBindViewHolder(holder, position); + return; } if (getItemViewType(position) != -200) { bindDefault(holder, position); } } + + private void bindChatNew(ViewHolder holder, int position) { + BaseUiConversation conversation = mDataList.get(position); + ImgLoader.display(holder.getContext(), conversation.mCore.getPortraitUrl(), holder.getView(R.id.rc_conversation_portrait)); + holder.setText(R.id.rc_conversation_title, conversation.mCore.getConversationTitle()); + ((TextView) holder.getView(R.id.rc_conversation_content)).setText(ChatMsgTypeUtils.getMsg(conversation.mConversationContent.toString())); + if (conversation.mCore.getSentTime() != -1 && holder.getView(R.id.rc_conversation_date) != null) { + holder.setText(R.id.rc_conversation_date, DateFormatUtil.getDateTimeString(conversation.mCore.getSentTime(), true, holder.getContext())); + holder.getView(R.id.rc_conversation_date).setVisibility(View.VISIBLE); + } else if (holder.getView(R.id.rc_conversation_date) != null) { + holder.getView(R.id.rc_conversation_date).setVisibility(View.GONE); + } + holder.setVisible(R.id.rc_conversation_live_online, "0".equals(conversation.mCore.getDraft())); + int unReadCount = conversation.mCore.getUnreadMessageCount(); + + if (unReadCount > 0) { + holder.setVisible(R.id.rc_conversation_unread_count, true); + holder.setText(R.id.rc_conversation_unread_count, String.valueOf(unReadCount)); + 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_count, false); + 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)); + } + + if (holder.getView(R.id.rc_conversation_live_status) == null || IMLoginManager.get(holder.getContext()).getAnchorB() != 1) { + return; + } + Integer timer = timerMap.get(mDataList.get(position).mCore.getTargetId()); + if (timer == null) { + holder.getView(R.id.rc_conversation_live_status).setVisibility(View.GONE); + return; + } + if (timer >= 10) { + holder.setText(R.id.rc_conversation_live_status, + String.format(WordUtil.getNewString(R.string.message_chat_msg_look_live), timer) + ); + holder.getView(R.id.rc_conversation_live_status).setVisibility(View.VISIBLE); + } else { + holder.getView(R.id.rc_conversation_live_status).setVisibility(View.GONE); + } + + + } + + private void bindDefault(ViewHolder holder, int position) { BaseUiConversation conversation = mDataList.get(position); Log.i("列表", "bindDefault: 用户头像:" + conversation.mCore.getPortraitUrl()); @@ -171,6 +285,7 @@ public class MainConversationListAdapter extends ConversationListAdapter { } } + private void bindEmpty(ViewHolder holder, int position) { if (isChat) { ViewUtils.findViewById(holder.itemView, R.id.imageView, ImageView.class).setImageResource(R.mipmap.ic_message_not_chat_list); @@ -183,12 +298,13 @@ public class MainConversationListAdapter extends ConversationListAdapter { public void onFinish() { if (onRefreshListener != null) { - Log.i("聊天数据源", "设置数据源: " + mDataList.size()); - onRefreshListener.onFinish(mDataList); + Log.i("聊天数据源", "设置数据源: " + allDataList.size()); + onRefreshListener.onFinish(allDataList); } } private int listHashCode = 0; + @Override public synchronized void setDataCollection(List data) { if (data.hashCode() == listHashCode) return; @@ -236,8 +352,9 @@ public class MainConversationListAdapter extends ConversationListAdapter { } tmp.add(item); } - // ToastUtil.showDebug("消息数:"+data.size()); - super.setDataCollection(tmp); + allDataList= tmp; + List showData= FilterData(mFilter,tmp); + super.setDataCollection(showData); } private List tmpUids = new ArrayList<>(); @@ -349,15 +466,15 @@ public class MainConversationListAdapter extends ConversationListAdapter { BaseUiConversation conversation = mDataList.get(id); conversation.mCore.setSentTime(bean.getSentTime()); conversation.mCore.setUnreadMessageCount(integer); - if(bean.getContent() instanceof SightMessage){ - conversation.mConversationContent = new SpannableString(WordUtil.isNewZh()?"[小視頻]":"[Video]"); - }else if(bean.getContent() instanceof HQVoiceMessage){ - conversation.mConversationContent = new SpannableString(WordUtil.isNewZh()?"[語音]":"[Voice]"); - } else if(bean.getContent() instanceof ImageMessage){ - conversation.mConversationContent = new SpannableString(WordUtil.isNewZh()?"[圖片]":"[picture]"); - }else if(bean.getContent() instanceof MessageChatCardContent){ - conversation.mConversationContent = new SpannableString(WordUtil.isNewZh()?"[站內分享]":"[In-app sharing]"); - } else{ + if (bean.getContent() instanceof SightMessage) { + conversation.mConversationContent = new SpannableString(WordUtil.isNewZh() ? "[小視頻]" : "[Video]"); + } else if (bean.getContent() instanceof HQVoiceMessage) { + conversation.mConversationContent = new SpannableString(WordUtil.isNewZh() ? "[語音]" : "[Voice]"); + } else if (bean.getContent() instanceof ImageMessage) { + conversation.mConversationContent = new SpannableString(WordUtil.isNewZh() ? "[圖片]" : "[picture]"); + } else if (bean.getContent() instanceof MessageChatCardContent) { + conversation.mConversationContent = new SpannableString(WordUtil.isNewZh() ? "[站內分享]" : "[In-app sharing]"); + } else { conversation.mConversationContent = new SpannableString(((TextMessage) bean.getContent()).getContent()); } mDataList.set(id, conversation); @@ -375,4 +492,6 @@ public class MainConversationListAdapter extends ConversationListAdapter { }); } + + } 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 e479828d2..966eca9b0 100644 --- a/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java +++ b/common/src/main/java/com/yunbao/common/fragment/MainMessageChatListFragment.java @@ -165,6 +165,14 @@ public class MainMessageChatListFragment extends AbsMainMessageChatListFragment } + public int getFilter() { + return mAdapter.getFilter(); + } + + public void setFilter(int mFilter) { + mAdapter.setFilter(mFilter); + } + @Override public void onViewCreated(@NonNull View view, @Nullable Bundle savedInstanceState) { diff --git a/common/src/main/java/com/yunbao/common/views/MsgChatTypeSelectPoPupView.java b/common/src/main/java/com/yunbao/common/views/MsgChatTypeSelectPoPupView.java new file mode 100644 index 000000000..183bc5b84 --- /dev/null +++ b/common/src/main/java/com/yunbao/common/views/MsgChatTypeSelectPoPupView.java @@ -0,0 +1,107 @@ +package com.yunbao.common.views; + +import static io.rong.imlib.publicservice.model.PublicServiceMenu.PublicServiceMenuItemType.View; + +import android.content.Context; +import android.view.View; +import android.widget.ImageView; +import android.widget.TextView; + +import androidx.annotation.NonNull; +import androidx.core.content.ContextCompat; + +import com.lxj.xpopup.core.AttachPopupView; +import com.yunbao.common.R; +import com.yunbao.common.adapter.MainConversationListAdapter; +import com.yunbao.common.views.weight.ViewClicksAntiShake; + +import org.repackage.com.zui.opendeviceidlibrary.OpenDeviceId; + +public class MsgChatTypeSelectPoPupView extends AttachPopupView implements android.view.View.OnClickListener { + + private TextView chatTypeTv1, chatTypeTv2, chatTypeTv3, chatTypeTv4, chatTypeTv5; + private ImageView chatTypeImg1, chatTypeImg2, chatTypeImg3, chatTypeImg4, chatTypeImg5; + + private ResultCallBack mResultCallBack; + private int lastType; + public MsgChatTypeSelectPoPupView(@NonNull Context context,int type, ResultCallBack itemDelListener) { + super(context); + mResultCallBack = itemDelListener; + lastType = type; + } + + @Override + protected int getImplLayoutId() { + return R.layout.view_msg_select_chat_type; + } + + @Override + protected void onCreate() { + chatTypeTv1 =findViewById(R.id.chatTypeTv1); + chatTypeImg1 =findViewById(R.id.chatTypeImg1); + chatTypeTv2 =findViewById(R.id.chatTypeTv2); + chatTypeImg2 =findViewById(R.id.chatTypeImg2); + chatTypeTv3 =findViewById(R.id.chatTypeTv3); + chatTypeImg3 =findViewById(R.id.chatTypeImg3); + chatTypeTv4 =findViewById(R.id.chatTypeTv4); + chatTypeImg4 =findViewById(R.id.chatTypeImg4); + chatTypeTv5 =findViewById(R.id.chatTypeTv5); + chatTypeImg5 =findViewById(R.id.chatTypeImg5); + + chatTypeImg1.setOnClickListener(this); + chatTypeImg2.setOnClickListener(this); + chatTypeImg3.setOnClickListener(this); + chatTypeImg4.setOnClickListener(this); + chatTypeImg5.setOnClickListener(this); + + handleChatTypeClick(lastType); + } + + + + private void handleChatTypeClick(int type) { + switch (type) { + case MainConversationListAdapter.FILTER_ALL: + chatTypeImg1.setImageResource(R.mipmap.ic_chat_type_select); + chatTypeTv1.setTextColor(ContextCompat.getColor(chatTypeTv1.getContext(),R.color.colorMainTab)); + break; + case MainConversationListAdapter.FILTER_ONLINE: + chatTypeImg2.setImageResource(R.mipmap.ic_chat_type_select); + chatTypeTv2.setTextColor(ContextCompat.getColor(chatTypeTv2.getContext(),R.color.colorMainTab)); + break; + case MainConversationListAdapter.FILTER_OFFLINE: + chatTypeImg3.setImageResource(R.mipmap.ic_chat_type_select); + chatTypeTv3.setTextColor(ContextCompat.getColor(chatTypeTv3.getContext(),R.color.colorMainTab)); + break; + case MainConversationListAdapter.FILTER_READ: + chatTypeImg4.setImageResource(R.mipmap.ic_chat_type_select); + chatTypeTv4.setTextColor(ContextCompat.getColor(chatTypeTv4.getContext(),R.color.colorMainTab)); + break; + case MainConversationListAdapter.FILTER_UNREAD: + chatTypeImg5.setImageResource(R.mipmap.ic_chat_type_select); + chatTypeTv5.setTextColor(ContextCompat.getColor(chatTypeTv5.getContext(),R.color.colorMainTab)); + break; + } + } + + @Override + public void onClick(android.view.View v) { + if (v.getId()==R.id.chatTypeImg1){ + mResultCallBack.callBack(MainConversationListAdapter.FILTER_ALL); + }else if (v.getId()==R.id.chatTypeImg2){ + mResultCallBack.callBack(MainConversationListAdapter.FILTER_ONLINE); + }else if (v.getId()==R.id.chatTypeImg3){ + mResultCallBack.callBack(MainConversationListAdapter.FILTER_OFFLINE); + }else if (v.getId()==R.id.chatTypeImg4){ + mResultCallBack.callBack(MainConversationListAdapter.FILTER_READ); + }else if (v.getId()==R.id.chatTypeImg5){ + mResultCallBack.callBack(MainConversationListAdapter.FILTER_UNREAD); + } + dismiss(); + } + + + public interface ResultCallBack { + void callBack(int i); + } +} diff --git a/common/src/main/res/drawable/green_dot.xml b/common/src/main/res/drawable/green_dot.xml new file mode 100644 index 000000000..46fab62ef --- /dev/null +++ b/common/src/main/res/drawable/green_dot.xml @@ -0,0 +1,11 @@ + + + + + + + + diff --git a/common/src/main/res/drawable/red_dot.xml b/common/src/main/res/drawable/red_dot.xml new file mode 100644 index 000000000..39d9237fe --- /dev/null +++ b/common/src/main/res/drawable/red_dot.xml @@ -0,0 +1,10 @@ + + + + + + + diff --git a/common/src/main/res/drawable/shape_white.xml b/common/src/main/res/drawable/shape_white.xml new file mode 100644 index 000000000..a9043c57d --- /dev/null +++ b/common/src/main/res/drawable/shape_white.xml @@ -0,0 +1,6 @@ + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/rc_conversation_type_item.xml b/common/src/main/res/layout/rc_conversation_type_item.xml new file mode 100644 index 000000000..5b7fe7538 --- /dev/null +++ b/common/src/main/res/layout/rc_conversation_type_item.xml @@ -0,0 +1,29 @@ + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/rc_conversationlist_item.xml b/common/src/main/res/layout/rc_conversationlist_item.xml index 30703b211..da3a74afc 100644 --- a/common/src/main/res/layout/rc_conversationlist_item.xml +++ b/common/src/main/res/layout/rc_conversationlist_item.xml @@ -14,7 +14,6 @@ android:id="@+id/rc_conversation_portrait_rl" android:layout_width="48dp" android:layout_height="48dp" - android:layout_marginTop="@dimen/rc_margin_size_12" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintStart_toStartOf="parent" @@ -180,6 +179,7 @@ android:layout_marginBottom="@dimen/rc_margin_size_12" android:src="@drawable/rc_read_receipt" android:visibility="gone" + tools:visibility="visible" app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintEnd_toStartOf="@+id/rc_conversation_no_disturb" app:layout_goneMarginRight="@dimen/rc_margin_size_12" /> diff --git a/common/src/main/res/layout/rc_conversationlist_item2.xml b/common/src/main/res/layout/rc_conversationlist_item2.xml new file mode 100644 index 000000000..188c1721b --- /dev/null +++ b/common/src/main/res/layout/rc_conversationlist_item2.xml @@ -0,0 +1,156 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + \ No newline at end of file diff --git a/common/src/main/res/layout/view_msg_select_chat_type.xml b/common/src/main/res/layout/view_msg_select_chat_type.xml new file mode 100644 index 000000000..2ae32ab29 --- /dev/null +++ b/common/src/main/res/layout/view_msg_select_chat_type.xml @@ -0,0 +1,128 @@ + + + + + + + + + + + + + + + + + + + + + + + + + + + + diff --git a/common/src/main/res/mipmap-mdpi/ic_chat_type_select.png b/common/src/main/res/mipmap-mdpi/ic_chat_type_select.png new file mode 100644 index 000000000..3f5330bc3 Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/ic_chat_type_select.png differ diff --git a/common/src/main/res/mipmap-mdpi/ic_chat_type_unselect.png b/common/src/main/res/mipmap-mdpi/ic_chat_type_unselect.png new file mode 100644 index 000000000..8f04b106f Binary files /dev/null and b/common/src/main/res/mipmap-mdpi/ic_chat_type_unselect.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/ic_chat_type_select.png b/common/src/main/res/mipmap-xxhdpi/ic_chat_type_select.png new file mode 100644 index 000000000..b203b6426 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_chat_type_select.png differ diff --git a/common/src/main/res/mipmap-xxhdpi/ic_chat_type_unselect.png b/common/src/main/res/mipmap-xxhdpi/ic_chat_type_unselect.png new file mode 100644 index 000000000..09da11206 Binary files /dev/null and b/common/src/main/res/mipmap-xxhdpi/ic_chat_type_unselect.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/ic_chat_type_select.png b/common/src/main/res/mipmap-xxxhdpi/ic_chat_type_select.png new file mode 100644 index 000000000..f03e755b2 Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/ic_chat_type_select.png differ diff --git a/common/src/main/res/mipmap-xxxhdpi/ic_chat_type_unselect.png b/common/src/main/res/mipmap-xxxhdpi/ic_chat_type_unselect.png new file mode 100644 index 000000000..e68a3dd8f Binary files /dev/null and b/common/src/main/res/mipmap-xxxhdpi/ic_chat_type_unselect.png differ diff --git a/common/src/main/res/values-en-rUS/strings.xml b/common/src/main/res/values-en-rUS/strings.xml index 51b015de3..2c7e16aff 100644 --- a/common/src/main/res/values-en-rUS/strings.xml +++ b/common/src/main/res/values-en-rUS/strings.xml @@ -1474,4 +1474,11 @@ Limited ride And limited avatar frame Include: 看直播%dmin Chat Records + [Read] + [Unread] + All Chats + Show Online Only + Show Offline Only + Show Read Only + Show Unread Only diff --git a/common/src/main/res/values-zh/strings.xml b/common/src/main/res/values-zh/strings.xml index c98de881c..ebbb31de6 100644 --- a/common/src/main/res/values-zh/strings.xml +++ b/common/src/main/res/values-zh/strings.xml @@ -1604,5 +1604,11 @@ 違規原因: 處罰內容: 處罰時間: - + [已讀] + [未讀] + 全部聊天 + 僅展示在線 + 僅展示離線 + 僅展示已讀 + 僅展示未讀 diff --git a/common/src/main/res/values/strings.xml b/common/src/main/res/values/strings.xml index e59cb38c7..3c55e3931 100644 --- a/common/src/main/res/values/strings.xml +++ b/common/src/main/res/values/strings.xml @@ -1412,5 +1412,11 @@ Limited ride And limited avatar frame Personal hal Whole site hal Honors - + [Read] + [Unread] + All Chats + Show Online Only + Show Offline Only + Show Read Only + Show Unread Only 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 220d8341a..1327fe7c7 100644 --- a/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java +++ b/main/src/main/java/com/yunbao/main/views/MainMessageViewHolder.java @@ -73,6 +73,7 @@ import com.yunbao.common.utils.ToastUtil; import com.yunbao.common.utils.ViewPageIndicatorUtils; import com.yunbao.common.utils.WordUtil; import com.yunbao.common.views.AbsMainViewHolder; +import com.yunbao.common.views.MsgChatTypeSelectPoPupView; import com.yunbao.common.views.MsgRecommendPopupView; import com.yunbao.common.views.MsgSysDelPopupView; import com.yunbao.common.views.weight.ViewClicksAntiShake; @@ -134,12 +135,14 @@ public class MainMessageViewHolder extends AbsMainViewHolder { private ConstraintLayout tabLayout1, tabLayout2, tabLayout3; private TextView tab1, tab2, tab3; + private ImageView imageView1, imageView2, imageView3; private View tab_line1, tab_line2, tab_line3; private ImageView tab_icon; private List relativeLayouts = new ArrayList<>(); private List tabTexts = new ArrayList<>(); private List tabLine = new ArrayList<>(); + private List tabExpend = new ArrayList<>(); private LinearLayout tabLayouts; private int userType = 0; // (0)普通用户 (1)主播A (2)主播B @@ -201,6 +204,20 @@ public class MainMessageViewHolder extends AbsMainViewHolder { tab2 = findViewById(R.id.tab2); tab3 = findViewById(R.id.tab3); + imageView1 = findViewById(R.id.expendImg1); + imageView2 = findViewById(R.id.expendImg2); + imageView3 = findViewById(R.id.expendImg3); + + imageView1.setOnClickListener(view -> { + selectChatType(view, 0); + }); + imageView2.setOnClickListener(view -> { + selectChatType(view, 1); + }); + imageView3.setOnClickListener(view -> { + selectChatType(view, 2); + }); + tab_line1 = findViewById(R.id.tab_line1); tab_line2 = findViewById(R.id.tab_line2); tab_line3 = findViewById(R.id.tab_line3); @@ -224,6 +241,25 @@ public class MainMessageViewHolder extends AbsMainViewHolder { }); } + private void selectChatType(View view, int position) { + AbsMainMessageChatListFragment fragment = fragmentList.get(position); + if (!(fragment instanceof MainMessageChatListFragment) || !(view instanceof ImageView)) { + return; + } + MainMessageChatListFragment chatFragment = (MainMessageChatListFragment) fragment; + ImageView expendImg = (ImageView) view; + expendImg.setImageResource(R.mipmap.ic_expend_down); + XPopup.Builder builder = new XPopup.Builder(mContext).atView(relativeLayouts.get(position)); + builder.asCustom(new MsgChatTypeSelectPoPupView(mContext, chatFragment.getFilter(), new MsgChatTypeSelectPoPupView.ResultCallBack() { + @Override + public void callBack(int i) { + chatFragment.setFilter(i); + expendImg.setImageResource(R.mipmap.ic_expend_up); + } + })).show(); + } + + private void initFragment() { final String[] titles; fragmentList = new ArrayList<>(); @@ -264,9 +300,9 @@ public class MainMessageViewHolder extends AbsMainViewHolder { return fragmentList.get(i); } }); - if(userType==1){ + if (userType == 1) { viewPager.setCurrentItem(1); - }else{ + } else { viewPager.setCurrentItem(0); } viewPager.setUserInputEnabled(false); @@ -340,7 +376,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { @Override public void onPageSelected(int position) { super.onPageSelected(position); - if(!StringUtil.isEmpty(search.getText().toString())) { + if (!StringUtil.isEmpty(search.getText().toString())) { search.setText(""); } selectTab(position); @@ -369,6 +405,12 @@ public class MainMessageViewHolder extends AbsMainViewHolder { }); } + + private void showChatTypeSelect() { + + } + + private void initTabView() { relativeLayouts = new ArrayList<>(); tabTexts = new ArrayList<>(); @@ -382,6 +424,10 @@ public class MainMessageViewHolder extends AbsMainViewHolder { tabTexts.add(tab2); tabTexts.add(tab3); + tabExpend.add(imageView1); + tabExpend.add(imageView2); + tabExpend.add(imageView3); + tabLine.add(tab_line1); tabLine.add(tab_line2); tabLine.add(tab_line3); @@ -390,6 +436,7 @@ public class MainMessageViewHolder extends AbsMainViewHolder { tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_all_an_a)); ViewGroup.LayoutParams params = tabLayouts.getLayoutParams(); params.width = LinearLayout.LayoutParams.WRAP_CONTENT; + tabExpend.get(0).setVisibility(View.VISIBLE); tabLayouts.setLayoutParams(params); } else if (userType == 1) {//主播A tab_icon.setVisibility(View.VISIBLE); @@ -410,7 +457,9 @@ 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(R.string.message_chat_msg_all_an_a)); + tabExpend.get(1).setVisibility(View.VISIBLE); } else { //主播B + tabExpend.get(0).setVisibility(View.VISIBLE); relativeLayouts.get(0).setVisibility(View.VISIBLE); tabTexts.get(0).setText(WordUtil.getNewString(R.string.message_chat_msg_all)); relativeLayouts.get(1).setVisibility(View.VISIBLE); @@ -428,9 +477,9 @@ public class MainMessageViewHolder extends AbsMainViewHolder { } }); } - if(userType==1){ + if (userType == 1) { selectTab(1); - }else{ + } else { selectTab(0); } } diff --git a/main/src/main/res/layout/view_main_message.xml b/main/src/main/res/layout/view_main_message.xml index 47097b605..ac0ba6b34 100644 --- a/main/src/main/res/layout/view_main_message.xml +++ b/main/src/main/res/layout/view_main_message.xml @@ -312,12 +312,12 @@ android:paddingEnd="20dp"> + android:layout_weight="1" + android:visibility="gone" + tools:visibility="visible"> + + + + android:layout_weight="1" + android:visibility="gone" + tools:visibility="visible"> + + android:layout_weight="1" + android:visibility="gone" + tools:visibility="visible"> + + diff --git a/main/src/main/res/mipmap-mdpi/ic_expend_down.png b/main/src/main/res/mipmap-mdpi/ic_expend_down.png new file mode 100644 index 000000000..bdb75c255 Binary files /dev/null and b/main/src/main/res/mipmap-mdpi/ic_expend_down.png differ diff --git a/main/src/main/res/mipmap-mdpi/ic_expend_up.png b/main/src/main/res/mipmap-mdpi/ic_expend_up.png new file mode 100644 index 000000000..983c25251 Binary files /dev/null and b/main/src/main/res/mipmap-mdpi/ic_expend_up.png differ diff --git a/main/src/main/res/mipmap-xxhdpi/ic_expend_down.png b/main/src/main/res/mipmap-xxhdpi/ic_expend_down.png new file mode 100644 index 000000000..2b70c60e5 Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/ic_expend_down.png differ diff --git a/main/src/main/res/mipmap-xxhdpi/ic_expend_up.png b/main/src/main/res/mipmap-xxhdpi/ic_expend_up.png new file mode 100644 index 000000000..d75a1b232 Binary files /dev/null and b/main/src/main/res/mipmap-xxhdpi/ic_expend_up.png differ diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_expend_down.png b/main/src/main/res/mipmap-xxxhdpi/ic_expend_down.png new file mode 100644 index 000000000..3432b8e1b Binary files /dev/null and b/main/src/main/res/mipmap-xxxhdpi/ic_expend_down.png differ diff --git a/main/src/main/res/mipmap-xxxhdpi/ic_expend_up.png b/main/src/main/res/mipmap-xxxhdpi/ic_expend_up.png new file mode 100644 index 000000000..b7ebb6707 Binary files /dev/null and b/main/src/main/res/mipmap-xxxhdpi/ic_expend_up.png differ