聊天增加分类筛选 细节调整完整

This commit is contained in:
ningwenqiang 2024-08-27 14:22:48 +08:00
parent 7fb4a10425
commit 6abe02390e
4 changed files with 33 additions and 20 deletions

View File

@ -75,6 +75,8 @@ public class MainConversationListAdapter extends ConversationListAdapter {
} }
public void setFilter(int mFilter) { public void setFilter(int mFilter) {
if (this.mFilter == mFilter)
return;
this.mFilter = mFilter; this.mFilter = mFilter;
super.setDataCollection(FilterData(mFilter, allDataList)); super.setDataCollection(FilterData(mFilter, allDataList));
} }

View File

@ -87,21 +87,23 @@ public class MsgChatTypeSelectPoPupView extends AttachPopupView implements andro
@Override @Override
public void onClick(android.view.View v) { public void onClick(android.view.View v) {
if (v.getId()==R.id.chatTypeImg1){ if (v.getId()==R.id.chatTypeImg1){
mResultCallBack.callBack(MainConversationListAdapter.FILTER_ALL); mResultCallBack.callBack(MainConversationListAdapter.FILTER_ALL,chatTypeTv1.getText().toString());
}else if (v.getId()==R.id.chatTypeImg2){ }else if (v.getId()==R.id.chatTypeImg2){
mResultCallBack.callBack(MainConversationListAdapter.FILTER_ONLINE); mResultCallBack.callBack(MainConversationListAdapter.FILTER_ONLINE,chatTypeTv2.getText().toString());
}else if (v.getId()==R.id.chatTypeImg3){ }else if (v.getId()==R.id.chatTypeImg3){
mResultCallBack.callBack(MainConversationListAdapter.FILTER_OFFLINE); mResultCallBack.callBack(MainConversationListAdapter.FILTER_OFFLINE,chatTypeTv3.getText().toString());
}else if (v.getId()==R.id.chatTypeImg4){ }else if (v.getId()==R.id.chatTypeImg4){
mResultCallBack.callBack(MainConversationListAdapter.FILTER_READ); mResultCallBack.callBack(MainConversationListAdapter.FILTER_READ,chatTypeTv4.getText().toString());
}else if (v.getId()==R.id.chatTypeImg5){ }else if (v.getId()==R.id.chatTypeImg5){
mResultCallBack.callBack(MainConversationListAdapter.FILTER_UNREAD); mResultCallBack.callBack(MainConversationListAdapter.FILTER_UNREAD,chatTypeTv5.getText().toString());
} }
dismiss(); dismiss();
} }
public interface ResultCallBack { public interface ResultCallBack {
void callBack(int i); void callBack(int i,String string);
} }
} }

View File

@ -2,7 +2,7 @@
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android" <androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools" xmlns:tools="http://schemas.android.com/tools"
android:layout_width="350dp" android:layout_width="360dp"
android:layout_height="wrap_content" android:layout_height="wrap_content"
android:background="@drawable/shape_white"> android:background="@drawable/shape_white">
@ -13,11 +13,12 @@
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/all_chats"
android:textColor="#777777" android:textColor="#777777"
tools:textColor="@color/colorMainTab" android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" app:layout_constraintTop_toTopOf="parent"
android:text="@string/all_chats" /> tools:textColor="@color/colorMainTab" />
<ImageView <ImageView
android:id="@+id/chatTypeImg1" android:id="@+id/chatTypeImg1"
@ -26,10 +27,10 @@
android:layout_gravity="center_vertical" android:layout_gravity="center_vertical"
android:layout_marginEnd="20dp" android:layout_marginEnd="20dp"
android:src="@mipmap/ic_chat_type_unselect" android:src="@mipmap/ic_chat_type_unselect"
tools:src="@mipmap/ic_chat_type_select"
app:layout_constraintBottom_toBottomOf="@+id/chatTypeTv1" app:layout_constraintBottom_toBottomOf="@+id/chatTypeTv1"
app:layout_constraintEnd_toEndOf="parent" app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintTop_toTopOf="@+id/chatTypeTv1" /> app:layout_constraintTop_toTopOf="@+id/chatTypeTv1"
tools:src="@mipmap/ic_chat_type_select" />
<TextView <TextView
@ -39,10 +40,11 @@
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/online_only"
android:textColor="#777777" android:textColor="#777777"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv1" app:layout_constraintTop_toBottomOf="@+id/chatTypeTv1" />
android:text="@string/online_only" />
<ImageView <ImageView
android:id="@+id/chatTypeImg2" android:id="@+id/chatTypeImg2"
@ -62,10 +64,11 @@
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/offline_only"
android:textColor="#777777" android:textColor="#777777"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv2" app:layout_constraintTop_toBottomOf="@+id/chatTypeTv2" />
android:text="@string/offline_only" />
<ImageView <ImageView
android:id="@+id/chatTypeImg3" android:id="@+id/chatTypeImg3"
@ -85,10 +88,11 @@
android:layout_marginStart="20dp" android:layout_marginStart="20dp"
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/read_only"
android:textColor="#777777" android:textColor="#777777"
android:textSize="14sp"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv3" app:layout_constraintTop_toBottomOf="@+id/chatTypeTv3" />
android:text="@string/read_only" />
<ImageView <ImageView
android:id="@+id/chatTypeImg4" android:id="@+id/chatTypeImg4"
@ -109,11 +113,12 @@
android:layout_marginTop="20dp" android:layout_marginTop="20dp"
android:layout_marginBottom="20dp" android:layout_marginBottom="20dp"
android:layout_weight="1" android:layout_weight="1"
android:text="@string/unread_only"
android:textColor="#777777" android:textColor="#777777"
android:textSize="14sp"
app:layout_constraintBottom_toBottomOf="parent" app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent" app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/chatTypeTv4" app:layout_constraintTop_toBottomOf="@+id/chatTypeTv4" />
android:text="@string/unread_only" />
<ImageView <ImageView
android:id="@+id/chatTypeImg5" android:id="@+id/chatTypeImg5"

View File

@ -250,13 +250,17 @@ public class MainMessageViewHolder extends AbsMainViewHolder {
ImageView expendImg = (ImageView) view; ImageView expendImg = (ImageView) view;
expendImg.setImageResource(R.mipmap.ic_expend_down); expendImg.setImageResource(R.mipmap.ic_expend_down);
XPopup.Builder builder = new XPopup.Builder(mContext).atView(relativeLayouts.get(position)); XPopup.Builder builder = new XPopup.Builder(mContext).atView(relativeLayouts.get(position));
builder.offsetY(16);
builder.dismissOnTouchOutside(false);
builder.asCustom(new MsgChatTypeSelectPoPupView(mContext, chatFragment.getFilter(), new MsgChatTypeSelectPoPupView.ResultCallBack() { builder.asCustom(new MsgChatTypeSelectPoPupView(mContext, chatFragment.getFilter(), new MsgChatTypeSelectPoPupView.ResultCallBack() {
@Override @Override
public void callBack(int i) { public void callBack(int i,String str) {
tabTexts.get(position).setText(str);
chatFragment.setFilter(i); chatFragment.setFilter(i);
expendImg.setImageResource(R.mipmap.ic_expend_up); expendImg.setImageResource(R.mipmap.ic_expend_up);
} }
})).show(); })).show();
} }