소스 검색

增加老师端我的课程VIP定制课课程组页面筛选

Pq 3 달 전
부모
커밋
96ab95b2a4

+ 41 - 0
BaseLibrary/src/main/java/com/cooleshow/base/adapter/CourseGroupFilterAdapter.java

@@ -0,0 +1,41 @@
+package com.cooleshow.base.adapter;
+
+import android.widget.TextView;
+
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.viewholder.BaseViewHolder;
+import com.cooleshow.base.R;
+import com.cooleshow.base.interfaces.IFilterViewData;
+
+import androidx.annotation.NonNull;
+
+/**
+ * Author by pq, Date on 2023/4/12.
+ */
+public class CourseGroupFilterAdapter extends BaseQuickAdapter<IFilterViewData, BaseViewHolder> {
+    private int selectPos = -1;
+
+    public CourseGroupFilterAdapter() {
+        super(R.layout.item_filter_text_layout);
+    }
+
+    public void setSelectPos(int pos) {
+        selectPos = pos;
+        notifyDataSetChanged();
+    }
+
+    public String getSelectDataId() {
+        if (selectPos != -1 && selectPos < getData().size()) {
+            return getData().get(selectPos).getDataId();
+        }
+        return "";
+    }
+
+    @Override
+    protected void convert(@NonNull BaseViewHolder holder, IFilterViewData skillSelectBean) {
+        holder.setText(R.id.tv_text, skillSelectBean.getShowName());
+        TextView tv_text = holder.getView(R.id.tv_text);
+        int pos = holder.getLayoutPosition();
+        tv_text.setSelected(pos == selectPos);
+    }
+}

+ 13 - 1
BaseLibrary/src/main/java/com/cooleshow/base/constanst/CourseGroupStatusType.java

@@ -1,11 +1,13 @@
 package com.cooleshow.base.constanst;
 
 import com.contrarywind.interfaces.IPickerViewData;
+import com.cooleshow.base.interfaces.IFilterViewData;
 
 /**
  * Author by pq, Date on 2022/12/23.
  */
-public enum CourseGroupStatusType implements IPickerViewData {
+public enum CourseGroupStatusType implements IPickerViewData, IFilterViewData {
+    ALL("", "全部"),
     NOT("NOT", "未开始"),
     ING("ING", "进行"),
     COMPLETE("COMPLETE", "已结课"),
@@ -32,4 +34,14 @@ public enum CourseGroupStatusType implements IPickerViewData {
     public String getPickerViewText() {
         return getValue();
     }
+
+    @Override
+    public String getDataId() {
+        return getId();
+    }
+
+    @Override
+    public String getShowName() {
+        return getValue();
+    }
 }

+ 11 - 0
BaseLibrary/src/main/java/com/cooleshow/base/utils/PopupUtil.java

@@ -74,6 +74,17 @@ public class PopupUtil {
     }
 
     /*下方显示PopupWindow,包裹内容有偏移值*/
+    public static PopupWindow showInDropWrapNObg(Context activity, View contentView, View anchor, ShowListener showListener) {
+        PopupWindow popupWindow = createNoBackPopupWindow(contentView, activity, ViewGroup.LayoutParams.MATCH_PARENT,
+                ViewGroup.LayoutParams.WRAP_CONTENT, true);
+        popupWindow.showAsDropDown(anchor);
+        if (showListener != null) {
+            showListener.onShow(contentView, popupWindow);
+        }
+        return popupWindow;
+    }
+
+    /*下方显示PopupWindow,包裹内容有偏移值*/
     public static PopupWindow showInDropWrapNObg(Context activity, int resourcesId, View anchor, ShowListener showListener) {
         View popupView = LayoutInflater.from(activity).inflate(resourcesId, null);
         PopupWindow popupWindow = createNoBackPopupWindow(popupView, activity, ViewGroup.LayoutParams.MATCH_PARENT,

+ 179 - 0
BaseLibrary/src/main/java/com/cooleshow/base/widgets/CourseGroupFilterView.java

@@ -0,0 +1,179 @@
+package com.cooleshow.base.widgets;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.view.LayoutInflater;
+import android.view.View;
+import android.widget.FrameLayout;
+import android.widget.RadioButton;
+
+import com.chad.library.adapter.base.BaseQuickAdapter;
+import com.chad.library.adapter.base.listener.OnItemClickListener;
+import com.cooleshow.base.R;
+import com.cooleshow.base.adapter.CourseGroupFilterAdapter;
+import com.cooleshow.base.interfaces.IFilterViewData;
+
+import java.util.ArrayList;
+import java.util.List;
+
+import androidx.annotation.NonNull;
+import androidx.annotation.Nullable;
+import androidx.constraintlayout.widget.Group;
+import androidx.recyclerview.widget.GridLayoutManager;
+import androidx.recyclerview.widget.RecyclerView;
+
+/**
+ * Author by pq, Date on 2023/3/14.
+ */
+public class CourseGroupFilterView extends FrameLayout implements View.OnClickListener {
+    public static final String[] STATUS_VALUES = new String[]{"UNASSIGNED", "ASSIGNED", "DEADLINE"};
+
+    private View mFlRoot;
+    private Group groupOne, groupTwo;
+    private RecyclerView recyclerView1;
+    private RecyclerView recyclerView2;
+    private CourseGroupFilterAdapter mAdapterOne;
+    private CourseGroupFilterAdapter mAdapterTwo;
+
+    public CourseGroupFilterView(@NonNull Context context) {
+        this(context, null);
+    }
+
+    public CourseGroupFilterView(@NonNull Context context, @Nullable AttributeSet attrs) {
+        this(context, attrs, -1);
+    }
+
+    public CourseGroupFilterView(@NonNull Context context, @Nullable AttributeSet attrs, int defStyleAttr) {
+        super(context, attrs, defStyleAttr);
+        init();
+    }
+
+    private void init() {
+        LayoutInflater.from(getContext()).inflate(R.layout.view_course_group_filter_pop_layout, this);
+        recyclerView1 = findViewById(R.id.recyclerView1);
+        recyclerView2 = findViewById(R.id.recyclerView2);
+        groupOne = findViewById(R.id.group_one);
+        groupTwo = findViewById(R.id.group_two);
+        mFlRoot = findViewById(R.id.fl_root);
+
+        mAdapterOne = new CourseGroupFilterAdapter();
+        recyclerView1.setLayoutManager(new GridLayoutManager(getContext(), 4));
+        recyclerView1.setAdapter(mAdapterOne);
+
+        mAdapterTwo = new CourseGroupFilterAdapter();
+        recyclerView2.setLayoutManager(new GridLayoutManager(getContext(), 3));
+        recyclerView2.setAdapter(mAdapterTwo);
+        initListener();
+    }
+
+    private void initListener() {
+        mFlRoot.setOnClickListener(new OnClickListener() {
+            @Override
+            public void onClick(View v) {
+                if (mEventListener != null) {
+                    mEventListener.onDismiss();
+                }
+            }
+        });
+        mAdapterOne.setOnItemClickListener(new OnItemClickListener() {
+            @Override
+            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
+                if (position < mAdapterOne.getData().size()) {
+                    mAdapterOne.setSelectPos(position);
+                }
+            }
+        });
+
+        mAdapterTwo.setOnItemClickListener(new OnItemClickListener() {
+            @Override
+            public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
+                if (position < mAdapterTwo.getData().size()) {
+                    mAdapterTwo.setSelectPos(position);
+                }
+            }
+        });
+        findViewById(R.id.tv_confirm).setOnClickListener(this);
+        findViewById(R.id.tv_cancel).setOnClickListener(this);
+    }
+
+    public View getRootView() {
+        return mFlRoot;
+    }
+
+
+    private OnEventListener mEventListener;
+
+    public void setOnEventListener(OnEventListener onEventListener) {
+        this.mEventListener = onEventListener;
+    }
+
+    private List<IFilterViewData> datas = new ArrayList<>();
+    private List<IFilterViewData> secondDatas = new ArrayList<>();
+
+    public void setData(List<IFilterViewData> firstDatas, List<IFilterViewData> secondData) {
+        datas.clear();
+        datas.addAll(firstDatas);
+        secondDatas.clear();
+        secondDatas.addAll(secondData);
+        refreshView();
+    }
+
+    private void refreshView() {
+        if (recyclerView1 == null) {
+            return;
+        }
+        if (datas != null && datas.size() > 0) {
+            groupOne.setVisibility(View.VISIBLE);
+            mAdapterOne.setNewInstance(datas);
+        } else {
+            groupOne.setVisibility(View.GONE);
+        }
+
+        if (secondDatas != null && secondDatas.size() > 0) {
+            groupTwo.setVisibility(View.VISIBLE);
+            mAdapterTwo.setNewInstance(secondDatas);
+        } else {
+            groupTwo.setVisibility(View.GONE);
+        }
+    }
+
+    private void handleConfirm() {
+        String orchestraId = null;
+        if (mAdapterOne != null) {
+            orchestraId = mAdapterOne.getSelectDataId();
+        }
+        String subjectId = null;
+        if (mAdapterTwo != null) {
+            subjectId = mAdapterTwo.getSelectDataId();
+        }
+        if (mEventListener != null) {
+            mEventListener.onQuery(orchestraId, subjectId);
+        }
+    }
+
+    @Override
+    public void onClick(View v) {
+        int id = v.getId();
+        if (id == R.id.tv_cancel) {
+            clearCheck();
+            handleConfirm();
+            return;
+        }
+
+        if (id == R.id.tv_confirm) {
+            handleConfirm();
+            return;
+        }
+    }
+
+    private void clearCheck() {
+        mAdapterOne.setSelectPos(-1);
+        mAdapterTwo.setSelectPos(-1);
+    }
+
+    public interface OnEventListener {
+        void onDismiss();
+
+        void onQuery(String orchestraId, String status);
+    }
+}

+ 5 - 0
BaseLibrary/src/main/res/color/selector_course_group_filter_item_text_color.xml

@@ -0,0 +1,5 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:color="@color/color_2dc7aa" android:state_checked="true"/>
+    <item android:color="@color/color_333333"/>
+</selector>

+ 8 - 0
BaseLibrary/src/main/res/drawable/bg_white_bottom_20dp.xml

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

+ 6 - 0
BaseLibrary/src/main/res/drawable/selector_course_group_filter_item.xml

@@ -0,0 +1,6 @@
+<?xml version="1.0" encoding="utf-8"?>
+<selector xmlns:android="http://schemas.android.com/apk/res/android">
+    <item android:drawable="@drawable/shape_e9ff8_4dp_border_2dc7aa_1dp" android:state_checked="true" />
+    <item android:drawable="@drawable/shape_e9ff8_4dp_border_2dc7aa_1dp" android:state_selected="true" />
+    <item android:drawable="@drawable/shape_f8f8f8_4dp" />
+</selector>

+ 6 - 0
BaseLibrary/src/main/res/drawable/shape_e9ff8_4dp_border_2dc7aa_1dp.xml

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

+ 5 - 0
BaseLibrary/src/main/res/drawable/shape_f8f8f8_4dp.xml

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

+ 25 - 0
BaseLibrary/src/main/res/layout/item_filter_text_layout.xml

@@ -0,0 +1,25 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
+    xmlns:tools="http://schemas.android.com/tools"
+    android:layout_width="match_parent"
+    android:layout_marginStart="5dp"
+    android:layout_marginEnd="5dp"
+    android:layout_marginTop="5dp"
+    android:layout_marginBottom="5dp"
+    android:layout_height="wrap_content">
+
+    <TextView
+        android:gravity="center"
+        android:id="@+id/tv_text"
+        android:paddingStart="5dp"
+        android:paddingEnd="5dp"
+        android:ellipsize="middle"
+        android:singleLine="true"
+        android:layout_width="match_parent"
+        android:layout_height="34dp"
+        android:background="@drawable/selector_course_group_filter_item"
+        android:includeFontPadding="false"
+        android:textColor="@color/selector_course_group_filter_item_text_color"
+        android:textSize="@dimen/sp_13"
+        tools:text="长笛" />
+</FrameLayout>

+ 166 - 0
BaseLibrary/src/main/res/layout/view_course_group_filter_pop_layout.xml

@@ -0,0 +1,166 @@
+<?xml version="1.0" encoding="utf-8"?>
+<FrameLayout 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/fl_root"
+    android:layout_width="match_parent"
+    android:layout_height="match_parent"
+    android:background="#60000000"
+    android:overScrollMode="never"
+    android:scrollbars="none">
+
+    <androidx.constraintlayout.widget.ConstraintLayout
+        android:id="@+id/fl_container"
+        android:layout_width="match_parent"
+        android:layout_height="wrap_content"
+        android:background="@drawable/bg_white_bottom_20dp"
+        android:paddingTop="18dp"
+        android:paddingBottom="18dp">
+
+        <androidx.core.widget.NestedScrollView
+            android:id="@+id/sv_top"
+            android:layout_width="match_parent"
+            android:layout_height="wrap_content"
+            app:layout_constraintHeight_max="401dp"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintTop_toTopOf="parent">
+
+            <androidx.constraintlayout.widget.ConstraintLayout
+                android:layout_width="match_parent"
+                android:layout_height="wrap_content">
+
+                <ImageView
+                    android:id="@+id/iv_icon"
+                    android:layout_width="4dp"
+                    android:layout_height="@dimen/dp_11"
+                    android:layout_marginStart="@dimen/dp_16"
+                    android:background="@drawable/btn_green_stu_line_shape"
+                    app:layout_constraintBottom_toBottomOf="@+id/tv_title1"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="@+id/tv_title1" />
+
+                <TextView
+                    android:id="@+id/tv_title1"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="6dp"
+                    android:text="课程状态"
+                    android:textColor="@color/color_333333"
+                    android:textSize="@dimen/sp_16"
+                    android:textStyle="bold"
+                    android:visibility="gone"
+                    app:layout_constraintLeft_toRightOf="@+id/iv_icon"
+                    app:layout_constraintTop_toTopOf="parent"
+                    tools:visibility="visible" />
+
+                <androidx.recyclerview.widget.RecyclerView
+                    android:id="@+id/recyclerView1"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="4dp"
+                    android:orientation="horizontal"
+                    android:overScrollMode="never"
+                    android:paddingStart="9dp"
+                    android:paddingEnd="9dp"
+                    android:scrollbars="none"
+                    android:visibility="gone"
+                    app:layout_constraintTop_toBottomOf="@+id/tv_title1"
+                    tools:visibility="visible" />
+
+                <androidx.constraintlayout.widget.Group
+                    android:id="@+id/group_one"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:visibility="visible"
+                    app:constraint_referenced_ids="recyclerView1,tv_title1,iv_icon" />
+
+                <ImageView
+                    android:id="@+id/iv_icon2"
+                    android:layout_width="4dp"
+                    android:layout_height="@dimen/dp_11"
+                    android:layout_marginStart="@dimen/dp_16"
+                    android:background="@drawable/btn_green_stu_line_shape"
+                    app:layout_constraintBottom_toBottomOf="@+id/tv_title2"
+                    app:layout_constraintStart_toStartOf="parent"
+                    app:layout_constraintTop_toTopOf="@+id/tv_title2" />
+
+                <TextView
+                    android:id="@+id/tv_title2"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:layout_marginStart="6dp"
+                    android:layout_marginTop="13dp"
+                    android:text="声部"
+                    android:textColor="@color/color_333333"
+                    android:textSize="@dimen/sp_16"
+                    android:textStyle="bold"
+                    android:visibility="gone"
+                    app:layout_constraintLeft_toRightOf="@+id/iv_icon2"
+                    app:layout_constraintTop_toBottomOf="@+id/recyclerView1"
+                    app:layout_goneMarginTop="0dp"
+                    tools:visibility="visible" />
+
+                <androidx.recyclerview.widget.RecyclerView
+                    android:id="@+id/recyclerView2"
+                    android:layout_width="match_parent"
+                    android:layout_height="wrap_content"
+                    android:layout_marginTop="4dp"
+                    android:orientation="horizontal"
+                    android:overScrollMode="never"
+                    android:paddingStart="9dp"
+                    android:paddingEnd="9dp"
+                    android:scrollbars="none"
+                    android:visibility="gone"
+                    app:layout_constraintTop_toBottomOf="@+id/tv_title2"
+                    tools:visibility="visible" />
+
+
+                <androidx.constraintlayout.widget.Group
+                    android:id="@+id/group_two"
+                    android:layout_width="wrap_content"
+                    android:layout_height="wrap_content"
+                    android:visibility="visible"
+                    app:constraint_referenced_ids="recyclerView2,tv_title2,iv_icon2" />
+            </androidx.constraintlayout.widget.ConstraintLayout>
+        </androidx.core.widget.NestedScrollView>
+
+        <View
+            android:id="@+id/view_line"
+            android:layout_width="match_parent"
+            android:layout_height="1dp"
+            android:layout_marginTop="20dp"
+            android:background="@color/color_f2f2f2"
+            app:layout_constraintTop_toBottomOf="@+id/sv_top" />
+
+        <TextView
+            android:id="@+id/tv_cancel"
+            android:layout_width="0dp"
+            android:layout_height="44dp"
+            android:layout_marginStart="13dp"
+            android:layout_marginTop="17dp"
+            android:background="@drawable/shape_border_dbdbdb_1dp_22dp"
+            android:gravity="center"
+            android:text="重置"
+            android:textColor="@color/color_333333"
+            android:textStyle="bold"
+            app:layout_constraintLeft_toLeftOf="parent"
+            app:layout_constraintRight_toLeftOf="@+id/tv_confirm"
+            app:layout_constraintTop_toBottomOf="@+id/view_line" />
+
+        <TextView
+            android:id="@+id/tv_confirm"
+            android:layout_width="0dp"
+            android:layout_height="44dp"
+            android:layout_marginStart="15dp"
+            android:layout_marginEnd="13dp"
+            android:background="@drawable/shape_2dc7aa_22dp"
+            android:gravity="center"
+            android:text="查询"
+            android:textColor="@color/white"
+            android:textSize="@dimen/sp_16"
+            android:textStyle="bold"
+            app:layout_constraintLeft_toRightOf="@+id/tv_cancel"
+            app:layout_constraintRight_toRightOf="parent"
+            app:layout_constraintTop_toTopOf="@+id/tv_cancel" />
+    </androidx.constraintlayout.widget.ConstraintLayout>
+</FrameLayout>

+ 12 - 1
teacher/src/main/java/com/cooleshow/teacher/bean/QuerySubjectBean.java

@@ -1,6 +1,7 @@
 package com.cooleshow.teacher.bean;
 
 import com.contrarywind.interfaces.IPickerViewData;
+import com.cooleshow.base.interfaces.IFilterViewData;
 
 import java.util.List;
 
@@ -10,7 +11,7 @@ import java.util.List;
  * @author Ryan
  * 类说明:
  */
-public class QuerySubjectBean implements IPickerViewData {
+public class QuerySubjectBean implements IPickerViewData, IFilterViewData {
     /*
     	"code": "",
 			"createTime": "",
@@ -62,4 +63,14 @@ public class QuerySubjectBean implements IPickerViewData {
     public String getPickerViewText() {
         return name;
     }
+
+    @Override
+    public String getDataId() {
+        return String.valueOf(id);
+    }
+
+    @Override
+    public String getShowName() {
+        return name;
+    }
 }

+ 13 - 4
teacher/src/main/java/com/cooleshow/teacher/ui/course/MineCourseActivity.java

@@ -42,6 +42,7 @@ public class MineCourseActivity extends BaseMVPActivity<ActivityMineCourseLayout
     private LiveCourseFragment mLiveCourseFragment;
     private VideoCourseFragment mVideoCourseFragment;
     private PianoRoomCourseFragment mPianoRoomCourseFragment;
+    private VIPCourseGroupFragment mVipCourseFragment;
 
     @Override
     protected void onCreate(@Nullable Bundle savedInstanceState) {
@@ -78,8 +79,8 @@ public class MineCourseActivity extends BaseMVPActivity<ActivityMineCourseLayout
         mLiveCourseFragment = new LiveCourseFragment();
         mVideoCourseFragment = new VideoCourseFragment();
         mPianoRoomCourseFragment = new PianoRoomCourseFragment();
-        VIPCourseGroupFragment vipCourseFragment =new VIPCourseGroupFragment();
-        mFragments.add(vipCourseFragment);
+        mVipCourseFragment = new VIPCourseGroupFragment();
+        mFragments.add(mVipCourseFragment);
         mFragments.add(mSparringCourseFragment);
         mFragments.add(mLiveCourseFragment);
         mFragments.add(mVideoCourseFragment);
@@ -90,8 +91,6 @@ public class MineCourseActivity extends BaseMVPActivity<ActivityMineCourseLayout
         viewBinding.viewPager.setOffscreenPageLimit(mFragments.size());
         tabLayoutMediator.attach();
 
-
-        presenter.querySubjectItem();
         if (selectPosition != -1 && selectPosition < mFragments.size()) {
             viewBinding.viewPager.post(new Runnable() {
                 @Override
@@ -147,8 +146,18 @@ public class MineCourseActivity extends BaseMVPActivity<ActivityMineCourseLayout
         return new MineCoursePresenter();
     }
 
+
+    @Override
+    protected void onResume() {
+        super.onResume();
+        presenter.querySubjectItem();
+    }
+
     @Override
     public void querySubjectItemSuccess(List<QuerySubjectBean> data) {
+        if (mVipCourseFragment != null) {
+            mVipCourseFragment.querySubjectItemSuccess(data);
+        }
         if (mSparringCourseFragment != null) {
             mSparringCourseFragment.querySubjectItemSuccess(data);
         }

+ 83 - 2
teacher/src/main/java/com/cooleshow/teacher/ui/course/VIPCourseGroupFragment.java

@@ -1,24 +1,34 @@
 package com.cooleshow.teacher.ui.course;
 
 import android.view.View;
+import android.view.ViewGroup;
+import android.widget.PopupWindow;
 
 import com.chad.library.adapter.base.BaseQuickAdapter;
 import com.chad.library.adapter.base.listener.OnItemClickListener;
 import com.cooleshow.base.constanst.Constants;
+import com.cooleshow.base.constanst.CourseGroupStatusType;
+import com.cooleshow.base.interfaces.IFilterViewData;
 import com.cooleshow.base.ui.fragment.BaseMVPFragment;
 import com.cooleshow.base.utils.LOG;
+import com.cooleshow.base.utils.PopupUtil;
+import com.cooleshow.base.utils.UiUtils;
+import com.cooleshow.base.widgets.CourseGroupFilterView;
 import com.cooleshow.base.widgets.EmptyViewLayout;
+import com.cooleshow.teacher.R;
 import com.cooleshow.teacher.adapter.VIPCourseAdapter;
 import com.cooleshow.teacher.bean.QuerySubjectBean;
 import com.cooleshow.teacher.bean.VIPCourseGroupListBean;
 import com.cooleshow.teacher.contract.VipCourseContract;
 import com.cooleshow.teacher.databinding.FgVipCourseLayoutBinding;
 import com.cooleshow.teacher.presenter.course.VipCoursePresenter;
+import com.scwang.smart.refresh.footer.ClassicsFooter;
 import com.scwang.smart.refresh.layout.api.RefreshLayout;
 import com.scwang.smart.refresh.layout.listener.OnLoadMoreListener;
 import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
 
 import java.util.ArrayList;
+import java.util.Arrays;
 import java.util.List;
 
 import androidx.annotation.NonNull;
@@ -28,17 +38,20 @@ import androidx.recyclerview.widget.LinearLayoutManager;
  * Author by pq, Date on 2022/5/9.
  */
 public class VIPCourseGroupFragment extends BaseMVPFragment<FgVipCourseLayoutBinding, VipCoursePresenter> implements VipCourseContract.View, View.OnClickListener {
-    private List<QuerySubjectBean> subjectList = new ArrayList<>();
+    private List<IFilterViewData> subjectBeanList = new ArrayList<>();//声部筛选
     private VIPCourseAdapter mAdapter;
     private int currentPage = 1;
     private boolean hasNext = true;
     private String status = "";
     private String currentSubjectId;
     private String searchCondition;
+    private CourseGroupFilterView mCourseGroupFilterView;
+    private PopupWindow mPopupWindow;
+    private List<IFilterViewData> statusList;//状态筛选
 
     @Override
     protected void initView(View rootView) {
-
+        mViewBinding.refreshLayout.setRefreshFooter(new ClassicsFooter(getContext()));
         LinearLayoutManager manager = new LinearLayoutManager(getContext());
         mViewBinding.recyclerViewList.setLayoutManager(manager);
         mAdapter = new VIPCourseAdapter();
@@ -51,11 +64,18 @@ public class VIPCourseGroupFragment extends BaseMVPFragment<FgVipCourseLayoutBin
 
     @Override
     protected void initData() {
+        CourseGroupStatusType[] values = CourseGroupStatusType.values();
+        List<CourseGroupStatusType> courseGroupStatusTypes = Arrays.asList(values);
+        statusList = new ArrayList<com.cooleshow.base.interfaces.IFilterViewData>(courseGroupStatusTypes);
+
+
         initListener();
         getData(true);
     }
 
     private void initListener() {
+        mViewBinding.tvFilter.setOnClickListener(this);
+        mViewBinding.tvSearch.setOnClickListener(this);
         mViewBinding.refreshLayout.setOnRefreshListener(new OnRefreshListener() {
             @Override
             public void onRefresh(@NonNull RefreshLayout refreshLayout) {
@@ -103,6 +123,61 @@ public class VIPCourseGroupFragment extends BaseMVPFragment<FgVipCourseLayoutBin
 
     @Override
     public void onClick(View view) {
+        int id = view.getId();
+        if (id == R.id.tv_filter) {
+            showFilterView();
+            return;
+        }
+
+        if (id == R.id.tv_search) {
+            currentPage = 1;
+            searchCondition = mViewBinding.etTargetName.getText().toString().trim();
+            getData(false);
+            return;
+        }
+    }
+
+
+    private void showFilterView() {
+        if (mCourseGroupFilterView == null) {
+            mCourseGroupFilterView = new CourseGroupFilterView(getContext());
+            mCourseGroupFilterView.setOnEventListener(new CourseGroupFilterView.OnEventListener() {
+                @Override
+                public void onDismiss() {
+                    if (mPopupWindow != null) {
+                        mPopupWindow.dismiss();
+                    }
+                }
+
+                @Override
+                public void onQuery(String obj, String obj2) {
+                    if (mPopupWindow != null) {
+                        mPopupWindow.dismiss();
+                    }
+                    currentPage = 1;
+                    VIPCourseGroupFragment.this.status = obj;
+                    VIPCourseGroupFragment.this.currentSubjectId = obj2;
+                    getData(true);
+                }
+            });
+        }
+        mCourseGroupFilterView.setData(statusList, subjectBeanList);
+        ViewGroup parent = (ViewGroup) mCourseGroupFilterView.getParent();
+        if (parent != null) {
+            parent.removeView(mCourseGroupFilterView);
+        }
+        mPopupWindow = PopupUtil.showInDropWrapNObg(getContext(), mCourseGroupFilterView, mViewBinding.viewTopLine, new PopupUtil.ShowListener() {
+            @Override
+            public void onShow(View view, PopupWindow popupWindow) {
+                UiUtils.refreshFilterTextStyle(true, mViewBinding.tvFilter);
+            }
+        });
+        mPopupWindow.setOnDismissListener(new PopupWindow.OnDismissListener() {
+            @Override
+            public void onDismiss() {
+                UiUtils.refreshFilterTextStyle(false, mViewBinding.tvFilter);
+            }
+        });
     }
 
 
@@ -164,4 +239,10 @@ public class VIPCourseGroupFragment extends BaseMVPFragment<FgVipCourseLayoutBin
             }
         }
     }
+
+    public void querySubjectItemSuccess(List<QuerySubjectBean> data) {
+        subjectBeanList.clear();
+        subjectBeanList.add(new QuerySubjectBean("全部", 0));
+        subjectBeanList.addAll(data);
+    }
 }

+ 8 - 2
teacher/src/main/res/layout/fg_vip_course_layout.xml

@@ -81,16 +81,22 @@
         app:layout_constraintRight_toRightOf="@+id/view_search_bg"
         app:layout_constraintTop_toTopOf="@+id/view_search_bg" />
 
+    <View
+        android:layout_marginTop="12dp"
+        app:layout_constraintLeft_toLeftOf="parent"
+        app:layout_constraintTop_toBottomOf="@+id/view_search_bg"
+        android:id="@+id/view_top_line"
+        android:layout_width="match_parent"
+        android:layout_height="1px"/>
 
     <com.scwang.smart.refresh.layout.SmartRefreshLayout
         android:id="@+id/refreshLayout"
         android:layout_width="match_parent"
         android:layout_height="0dp"
-        android:layout_marginTop="12dp"
         app:layout_constraintRight_toRightOf="parent"
         app:layout_constraintBottom_toBottomOf="parent"
         app:layout_constraintLeft_toLeftOf="parent"
-        app:layout_constraintTop_toBottomOf="@+id/view_search_bg"
+        app:layout_constraintTop_toBottomOf="@+id/view_top_line"
         app:srlEnableLoadMore="true">
 
         <androidx.recyclerview.widget.RecyclerView