聊天增加分类筛选

This commit is contained in:
ningwenqiang 2024-08-27 14:01:00 +08:00
parent cfb5a5aac2
commit 7fb4a10425
27 changed files with 721 additions and 42 deletions

View File

@ -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<BaseUiConversation> srcList;
private List<BaseUiConversation> allDataList;
private Context mContext;
private boolean isChat = true;
private OnRecyclerListRefreshListener<List<BaseUiConversation>> onRefreshListener;
private Map<String, Integer> 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<BaseUiConversation> FilterData(int filterType, List<BaseUiConversation> data){
List<BaseUiConversation> 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<BaseUiConversation> srcList) {
this.srcList = srcList;
notifyDataSetChanged();
this.srcList = srcList;
super.setDataCollection(FilterData(mFilter, allDataList));
// notifyDataSetChanged();
}
public void setOnRefreshListener(OnRecyclerListRefreshListener<List<BaseUiConversation>> 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<BaseUiConversation> 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<BaseUiConversation> showData= FilterData(mFilter,tmp);
super.setDataCollection(showData);
}
private List<String> 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 {
});
}
}

View File

@ -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) {

View File

@ -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);
}
}

View File

@ -0,0 +1,11 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"> <!-- 设置形状为圆形 -->
<solid android:color="#6DFF7C" /> <!-- 设置填充颜色 -->
<!-- 可以添加额外的属性如边框等 -->
<!-- <stroke
android:width="2dp"
android:color="#000000" /> -->
</shape>

View File

@ -0,0 +1,10 @@
<shape xmlns:android="http://schemas.android.com/apk/res/android"
android:shape="oval"> <!-- 设置形状为圆形 -->
<solid android:color="#ffff4874" /> <!-- 设置填充颜色 -->
<stroke
android:width="2dp"
android:color="#30ff4874" /> <!-- 设置边框颜色为黑色并带有 70% 的不透明度 (BB 是 alpha 值) -->
</shape>

View File

@ -0,0 +1,6 @@
<?xml version="1.0" encoding="utf-8"?>
<shape xmlns:android="http://schemas.android.com/apk/res/android">
<corners android:radius="20dp"/>
<solid android:color="@color/white"/>
</shape>

View File

@ -0,0 +1,29 @@
<?xml version="1.0" encoding="utf-8"?>
<LinearLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rc_conversation_item"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="horizontal">
<TextView
android:id="@+id/chatTypeTv"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="10dp"
android:layout_marginBottom="10dp"
android:layout_weight="1"
android:textColor="@color/colorMainTab"
tools:text="全部聊天" />
<ImageView
android:id="@+id/chatTypeImg"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="20dp"
android:src="@mipmap/ic_chat_type_select" />
</LinearLayout>

View File

@ -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" />

View File

@ -0,0 +1,156 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/rc_conversation_item"
android:layout_width="match_parent"
android:layout_height="@dimen/rc_conversation_item_height">
<com.yunbao.common.views.weight.ClipPathCircleImage
android:id="@+id/rc_conversation_portrait"
android:layout_width="54dp"
android:layout_height="54dp"
android:layout_marginTop="12dp"
android:scaleType="centerCrop"
android:src="@mipmap/beauty_jingbai"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<ImageView
android:id="@+id/rc_conversation_live_online"
android:layout_width="12dp"
android:layout_height="12dp"
android:layout_marginTop="1dp"
android:layout_marginEnd="1dp"
android:layout_centerInParent="true"
android:src="@drawable/green_dot"
app:layout_constraintEnd_toEndOf="@+id/rc_conversation_portrait"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_portrait" />
<TextView
android:id="@+id/rc_conversation_title"
style="@style/TextStyle.Alignment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginStart="12dp"
android:layout_marginTop="4dp"
android:ellipsize="end"
android:maxWidth="120dp"
android:maxLines="1"
android:textColor="@color/rc_text_main_color"
android:textSize="13dp"
app:layout_constraintStart_toEndOf="@+id/rc_conversation_portrait"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_portrait"
tools:text="张三11111111111111111111111" />
<TextView
android:id="@+id/rc_conversation_live_status"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:background="@drawable/bg_main_message_chat_list_live_timer"
android:paddingStart="5dp"
android:paddingTop="2dp"
android:paddingEnd="3dp"
android:paddingBottom="3dp"
android:singleLine="true"
android:textColor="#EC70FD"
android:layout_marginStart="12dp"
android:textSize="10sp"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_title"
app:layout_constraintBottom_toBottomOf="@+id/rc_conversation_title"
app:layout_constraintStart_toEndOf="@+id/rc_conversation_title"
android:visibility="gone"
tools:text="看直播10min"
tools:visibility="visible" />
<TextView
android:id="@+id/rc_conversation_date"
style="@style/TextStyle.Alignment"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="3 月 22 日"
android:layout_marginEnd="12dp"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_title"
app:layout_constraintBottom_toBottomOf="@+id/rc_conversation_title"
app:layout_constraintEnd_toEndOf="parent"
android:textColor="@color/rc_auxiliary_color"
android:textSize="@dimen/rc_font_nav_or_date_size"
/>
<TextView
android:id="@+id/rc_conversation_unread_tv"
android:layout_width="wrap_content"
android:layout_marginBottom="4dp"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="@+id/rc_conversation_portrait"
app:layout_constraintStart_toStartOf="@+id/rc_conversation_title"
android:ellipsize="end"
android:maxLines="1"
tools:text="[已读]"
android:textColor="@color/rc_secondary_color"
android:textSize="13dp" />
<TextView
android:id="@+id/rc_conversation_content"
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"
android:textColor="@color/rc_secondary_color"
android:textSize="13dp"
app:layout_constraintBottom_toBottomOf="@+id/rc_conversation_unread_tv"
app:layout_constraintEnd_toStartOf="@+id/rc_conversation_read_receipt"
app:layout_constraintHorizontal_bias="0.0"
app:layout_constraintStart_toEndOf="@+id/rc_conversation_unread_tv"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_unread_tv"
tools:text="你好朋友111111111111111111111" />
<TextView
android:id="@+id/rc_conversation_unread_count"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_unread_tv"
app:layout_constraintBottom_toBottomOf="@+id/rc_conversation_unread_tv"
app:layout_constraintEnd_toEndOf="@+id/rc_conversation_date"
style="@style/TextStyle.Alignment"
app:layout_constraintDimensionRatio="1"
android:layout_width="18dp"
android:gravity="center"
android:layout_height="18dp"
android:background="@drawable/red_dot"
android:text="15"
android:textColor="@color/rc_white_color"
android:textSize="10sp" />
<ImageView
android:id="@+id/rc_conversation_no_disturb"
android:layout_width="wrap_content"
android:layout_marginEnd="@dimen/rc_margin_size_2"
android:layout_height="wrap_content"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_unread_count"
app:layout_constraintBottom_toBottomOf="@+id/rc_conversation_unread_count"
app:layout_constraintEnd_toStartOf="@+id/rc_conversation_unread_count"
android:src="@drawable/rc_no_disturb"
android:visibility="gone"
tools:visibility="visible" />
<ImageView
android:id="@+id/rc_conversation_read_receipt"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginEnd="@dimen/rc_margin_size_2"
android:src="@drawable/rc_read_receipt"
android:visibility="gone"
app:layout_constraintBottom_toBottomOf="@+id/rc_conversation_no_disturb"
app:layout_constraintEnd_toStartOf="@+id/rc_conversation_no_disturb"
app:layout_constraintTop_toTopOf="@+id/rc_conversation_no_disturb"
app:layout_constraintVertical_bias="1.0"
tools:visibility="visible" />
</androidx.constraintlayout.widget.ConstraintLayout>

View File

@ -0,0 +1,128 @@
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="350dp"
android:layout_height="wrap_content"
android:background="@drawable/shape_white">
<TextView
android:id="@+id/chatTypeTv1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:textColor="#777777"
tools:textColor="@color/colorMainTab"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent"
android:text="@string/all_chats" />
<ImageView
android:id="@+id/chatTypeImg1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:layout_marginEnd="20dp"
android:src="@mipmap/ic_chat_type_unselect"
tools:src="@mipmap/ic_chat_type_select"
app:layout_constraintBottom_toBottomOf="@+id/chatTypeTv1"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/chatTypeTv1" />
<TextView
android:id="@+id/chatTypeTv2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:textColor="#777777"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv1"
android:text="@string/online_only" />
<ImageView
android:id="@+id/chatTypeImg2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_chat_type_unselect"
app:layout_constraintBottom_toBottomOf="@+id/chatTypeTv2"
app:layout_constraintEnd_toEndOf="@+id/chatTypeImg1"
app:layout_constraintTop_toTopOf="@+id/chatTypeTv2" />
<TextView
android:id="@+id/chatTypeTv3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:textColor="#777777"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv2"
android:text="@string/offline_only" />
<ImageView
android:id="@+id/chatTypeImg3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_chat_type_unselect"
app:layout_constraintBottom_toBottomOf="@+id/chatTypeTv3"
app:layout_constraintEnd_toEndOf="@+id/chatTypeImg1"
app:layout_constraintTop_toTopOf="@+id/chatTypeTv3" />
<TextView
android:id="@+id/chatTypeTv4"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_weight="1"
android:textColor="#777777"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv3"
android:text="@string/read_only" />
<ImageView
android:id="@+id/chatTypeImg4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_chat_type_unselect"
app:layout_constraintBottom_toBottomOf="@+id/chatTypeTv4"
app:layout_constraintEnd_toEndOf="@+id/chatTypeImg1"
app:layout_constraintTop_toTopOf="@+id/chatTypeTv4" />
<TextView
android:id="@+id/chatTypeTv5"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_marginStart="20dp"
android:layout_marginTop="20dp"
android:layout_marginBottom="20dp"
android:layout_weight="1"
android:textColor="#777777"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv4"
android:text="@string/unread_only" />
<ImageView
android:id="@+id/chatTypeImg5"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_gravity="center_vertical"
android:src="@mipmap/ic_chat_type_unselect"
app:layout_constraintBottom_toBottomOf="@+id/chatTypeTv5"
app:layout_constraintEnd_toEndOf="@+id/chatTypeImg1"
app:layout_constraintTop_toTopOf="@+id/chatTypeTv5" />
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 642 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 542 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.1 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 2.0 KiB

Binary file not shown.

After

Width:  |  Height:  |  Size: 1.7 KiB

View File

@ -1474,4 +1474,11 @@ Limited ride And limited avatar frame</string>
<string name="activity_msg_list_include">Include:</string>
<string name="message_chat_msg_look_live">看直播%dmin</string>
<string name="activity_msg_list_title_chat_records">Chat Records</string>
<string name="message_chat_msg_read_tip">[Read]</string>
<string name="message_chat_msg_unread_tip">[Unread]</string>
<string name="all_chats">All Chats</string>
<string name="online_only">Show Online Only</string>
<string name="offline_only">Show Offline Only</string>
<string name="read_only">Show Read Only</string>
<string name="unread_only">Show Unread Only</string>
</resources>

View File

@ -1604,5 +1604,11 @@
<string name="live_end_view_ban_reason">違規原因:</string>
<string name="live_end_view_ban_content">處罰內容:</string>
<string name="live_end_view_ban_timer">處罰時間:</string>
<string name="message_chat_msg_read_tip">[已讀]</string>
<string name="message_chat_msg_unread_tip">[未讀]</string>
<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>
</resources>

View File

@ -1412,5 +1412,11 @@ Limited ride And limited avatar frame</string>
<string name="dialog_gift_wall_text_personal_hal">Personal hal</string>
<string name="dialog_gift_wall_text_site_hal">Whole site hal</string>
<string name="dialog_gift_wall_text_honors">Honors</string>
<string name="message_chat_msg_read_tip">[Read]</string>
<string name="message_chat_msg_unread_tip">[Unread]</string>
<string name="all_chats">All Chats</string>
<string name="online_only">Show Online Only</string>
<string name="offline_only">Show Offline Only</string>
<string name="read_only">Show Read Only</string>
<string name="unread_only">Show Unread Only</string>
</resources>

View File

@ -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<ConstraintLayout> relativeLayouts = new ArrayList<>();
private List<TextView> tabTexts = new ArrayList<>();
private List<View> tabLine = new ArrayList<>();
private List<ImageView> 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);
}
}

View File

@ -312,12 +312,12 @@
android:paddingEnd="20dp">
<androidx.constraintlayout.widget.ConstraintLayout
android:visibility="gone"
tools:visibility="visible"
android:id="@+id/tabLayout1"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:visibility="gone"
tools:visibility="visible">
<ImageView
android:id="@+id/tab_icon"
@ -363,26 +363,39 @@
android:id="@+id/tab_line1"
android:layout_width="0dp"
android:layout_height="3dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="3dp"
android:layout_marginTop="3dp"
android:layout_below="@+id/tab_top1"
android:layout_centerHorizontal="true"
android:layout_marginStart="3dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="3dp"
android:background="@drawable/bg_main_com_type"
app:layout_constraintEnd_toEndOf="@+id/tab1"
app:layout_constraintStart_toStartOf="@+id/tab1"
app:layout_constraintTop_toBottomOf="@+id/tab1" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/expendImg1"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:visibility="gone"
tools:visibility="visible"
android:src="@mipmap/ic_expend_up"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/tab_top1"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:visibility="gone"
tools:visibility="visible"
android:id="@+id/tabLayout2"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:visibility="gone"
tools:visibility="visible">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/tab_top2"
@ -414,27 +427,38 @@
<View
android:id="@+id/tab_line2"
android:layout_width="0dp"
android:layout_marginTop="3dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="3dp"
android:layout_height="3dp"
android:layout_below="@+id/tab_top2"
android:layout_centerHorizontal="true"
android:layout_marginStart="3dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="3dp"
android:background="@drawable/bg_main_com_type"
app:layout_constraintEnd_toEndOf="@+id/tab2"
app:layout_constraintStart_toStartOf="@+id/tab2"
app:layout_constraintTop_toBottomOf="@+id/tab2" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/expendImg2"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:visibility="gone"
tools:visibility="visible"
android:src="@mipmap/ic_expend_up"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/tab_top2"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>
<androidx.constraintlayout.widget.ConstraintLayout
android:visibility="gone"
tools:visibility="visible"
android:id="@+id/tabLayout3"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_weight="1">
android:layout_weight="1"
android:visibility="gone"
tools:visibility="visible">
<androidx.constraintlayout.widget.ConstraintLayout
android:id="@+id/tab_top3"
@ -466,18 +490,31 @@
<View
android:id="@+id/tab_line3"
android:layout_width="0dp"
android:layout_marginStart="3dp"
android:layout_marginEnd="3dp"
android:layout_height="3dp"
android:layout_marginTop="3dp"
android:layout_below="@+id/tab_top3"
android:layout_centerHorizontal="true"
android:layout_marginStart="3dp"
android:layout_marginTop="3dp"
android:layout_marginEnd="3dp"
android:background="@drawable/bg_main_com_type"
app:layout_constraintEnd_toEndOf="@+id/tab3"
app:layout_constraintStart_toStartOf="@+id/tab3"
app:layout_constraintTop_toBottomOf="@+id/tab3" />
</androidx.constraintlayout.widget.ConstraintLayout>
<ImageView
android:id="@+id/expendImg3"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:padding="5dp"
android:visibility="gone"
tools:visibility="visible"
android:layout_centerHorizontal="true"
android:src="@mipmap/ic_expend_up"
app:layout_constraintTop_toTopOf="parent"
app:layout_constraintStart_toEndOf="@+id/tab_top3"
app:layout_constraintBottom_toBottomOf="parent"/>
</androidx.constraintlayout.widget.ConstraintLayout>

Binary file not shown.

After

Width:  |  Height:  |  Size: 377 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 366 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 1009 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 950 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 455 B

Binary file not shown.

After

Width:  |  Height:  |  Size: 433 B