|
@@ -1,19 +1,27 @@
|
|
package com.cooleshow.teacher.ui.course;
|
|
package com.cooleshow.teacher.ui.course;
|
|
|
|
|
|
import android.text.TextUtils;
|
|
import android.text.TextUtils;
|
|
|
|
+import android.view.LayoutInflater;
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
+import android.view.ViewGroup;
|
|
|
|
+import android.widget.PopupWindow;
|
|
import android.widget.TextView;
|
|
import android.widget.TextView;
|
|
|
|
|
|
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
|
import com.bigkoo.pickerview.builder.TimePickerBuilder;
|
|
import com.bigkoo.pickerview.listener.CustomListener;
|
|
import com.bigkoo.pickerview.listener.CustomListener;
|
|
import com.bigkoo.pickerview.view.TimePickerView;
|
|
import com.bigkoo.pickerview.view.TimePickerView;
|
|
|
|
+import com.chad.library.adapter.base.BaseQuickAdapter;
|
|
|
|
+import com.chad.library.adapter.base.listener.OnItemClickListener;
|
|
import com.chad.library.adapter.base.listener.OnLoadMoreListener;
|
|
import com.chad.library.adapter.base.listener.OnLoadMoreListener;
|
|
import com.cooleshow.base.ui.fragment.BaseMVPFragment;
|
|
import com.cooleshow.base.ui.fragment.BaseMVPFragment;
|
|
import com.cooleshow.base.utils.LogUtils;
|
|
import com.cooleshow.base.utils.LogUtils;
|
|
|
|
+import com.cooleshow.base.utils.PopupUtil;
|
|
import com.cooleshow.base.utils.TimeUtils;
|
|
import com.cooleshow.base.utils.TimeUtils;
|
|
import com.cooleshow.teacher.R;
|
|
import com.cooleshow.teacher.R;
|
|
|
|
+import com.cooleshow.teacher.adapter.CourseStatusFilterAdapter;
|
|
import com.cooleshow.teacher.adapter.LiveCourseListAdapter;
|
|
import com.cooleshow.teacher.adapter.LiveCourseListAdapter;
|
|
import com.cooleshow.teacher.adapter.SparringCourseListAdapter;
|
|
import com.cooleshow.teacher.adapter.SparringCourseListAdapter;
|
|
|
|
+import com.cooleshow.teacher.bean.CourseFilterStatusBean;
|
|
import com.cooleshow.teacher.bean.LiveCourseListBean;
|
|
import com.cooleshow.teacher.bean.LiveCourseListBean;
|
|
import com.cooleshow.teacher.bean.SparringCourseListBean;
|
|
import com.cooleshow.teacher.bean.SparringCourseListBean;
|
|
import com.cooleshow.teacher.constants.CourseFilterConstants;
|
|
import com.cooleshow.teacher.constants.CourseFilterConstants;
|
|
@@ -26,11 +34,13 @@ import com.cooleshow.teacher.presenter.course.SparringCoursePresenter;
|
|
import com.scwang.smart.refresh.layout.api.RefreshLayout;
|
|
import com.scwang.smart.refresh.layout.api.RefreshLayout;
|
|
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
|
|
import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
|
|
|
|
|
|
|
|
+import java.util.ArrayList;
|
|
import java.util.Calendar;
|
|
import java.util.Calendar;
|
|
import java.util.Date;
|
|
import java.util.Date;
|
|
|
|
|
|
import androidx.annotation.NonNull;
|
|
import androidx.annotation.NonNull;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
+import androidx.recyclerview.widget.RecyclerView;
|
|
|
|
|
|
/**
|
|
/**
|
|
* Author by pq, Date on 2022/4/25.
|
|
* Author by pq, Date on 2022/4/25.
|
|
@@ -45,6 +55,9 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
private View mEmptyView;
|
|
private View mEmptyView;
|
|
private TextView mTvEmptyTip;
|
|
private TextView mTvEmptyTip;
|
|
private TimePickerView pvTime;
|
|
private TimePickerView pvTime;
|
|
|
|
+ private PopupWindow mPopupWindow;
|
|
|
|
+ private ArrayList<CourseFilterStatusBean> mCourseFilterStatusBeans;
|
|
|
|
+ private CourseStatusFilterAdapter mCourseStatusFilterAdapter;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected FragmentLiveCourseLayoutBinding getLayoutView() {
|
|
protected FragmentLiveCourseLayoutBinding getLayoutView() {
|
|
@@ -58,14 +71,22 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void initView(View rootView) {
|
|
protected void initView(View rootView) {
|
|
- reBuildFilter(null,CourseFilterConstants.COURSE_FILTER_ALL);
|
|
|
|
mViewBinding.tvTime.setOnClickListener(this);
|
|
mViewBinding.tvTime.setOnClickListener(this);
|
|
|
|
+ mViewBinding.tvCourseStatus.setOnClickListener(this);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void buildDefaultCourseStatusFilterList() {
|
|
|
|
+ mCourseFilterStatusBeans = new ArrayList<>();
|
|
|
|
+ mCourseFilterStatusBeans.add(new CourseFilterStatusBean(CourseFilterConstants.COURSE_FILTER_ALL, "全部"));
|
|
|
|
+ mCourseFilterStatusBeans.add(new CourseFilterStatusBean(CourseFilterConstants.COURSE_FILTER_HAS_NOT_STARTED, "未开始"));
|
|
|
|
+ mCourseFilterStatusBeans.add(new CourseFilterStatusBean(CourseFilterConstants.COURSE_FILTER_IN_PROGRESS, "进行中"));
|
|
|
|
+ mCourseFilterStatusBeans.add(new CourseFilterStatusBean(CourseFilterConstants.COURSE_FILTER_COMPLETED, "已结束"));
|
|
}
|
|
}
|
|
|
|
|
|
private void reBuildFilter(Date date, String status) {
|
|
private void reBuildFilter(Date date, String status) {
|
|
currentSelectDate = date != null ? date : TimeUtils.getNowDate();
|
|
currentSelectDate = date != null ? date : TimeUtils.getNowDate();
|
|
String targetDateTimeStr = TimeUtils.date2String(currentSelectDate, TimeUtils.getSafeDateFormat("yyyy-MM"));
|
|
String targetDateTimeStr = TimeUtils.date2String(currentSelectDate, TimeUtils.getSafeDateFormat("yyyy-MM"));
|
|
- if (TextUtils.equals(targetDateTimeStr, currentFilterDate) && TextUtils.equals(currentCourseFilterStatus,status)) {
|
|
|
|
|
|
+ if (TextUtils.equals(targetDateTimeStr, currentFilterDate) && TextUtils.equals(currentCourseFilterStatus, status)) {
|
|
//防止重复条件触发
|
|
//防止重复条件触发
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
@@ -87,6 +108,7 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
});
|
|
});
|
|
|
|
|
|
mAdapter = new LiveCourseListAdapter(R.layout.item_live_course_list_layout);
|
|
mAdapter = new LiveCourseListAdapter(R.layout.item_live_course_list_layout);
|
|
|
|
+ mAdapter.getLoadMoreModule().setEnableLoadMoreIfNotFullPage(false);
|
|
mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
@Override
|
|
@Override
|
|
public void onLoadMore() {
|
|
public void onLoadMore() {
|
|
@@ -97,7 +119,9 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
});
|
|
});
|
|
mViewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
|
mViewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
|
mViewBinding.recyclerView.setAdapter(mAdapter);
|
|
mViewBinding.recyclerView.setAdapter(mAdapter);
|
|
- queryCourse();
|
|
|
|
|
|
+
|
|
|
|
+ buildDefaultCourseStatusFilterList();
|
|
|
|
+ reBuildFilter(null, CourseFilterConstants.COURSE_FILTER_ALL);
|
|
}
|
|
}
|
|
|
|
|
|
private void queryCourse() {
|
|
private void queryCourse() {
|
|
@@ -119,9 +143,9 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
//第一页
|
|
//第一页
|
|
mViewBinding.refreshLayout.finishRefresh();
|
|
mViewBinding.refreshLayout.finishRefresh();
|
|
if (mAdapter != null) {
|
|
if (mAdapter != null) {
|
|
|
|
+ mAdapter.getData().clear();
|
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
if (liveCourseListBean.rows != null && liveCourseListBean.rows.size() > 0) {
|
|
if (liveCourseListBean.rows != null && liveCourseListBean.rows.size() > 0) {
|
|
- mAdapter.getData().clear();
|
|
|
|
- mAdapter.notifyDataSetChanged();
|
|
|
|
mAdapter.setNewInstance(liveCourseListBean.rows);
|
|
mAdapter.setNewInstance(liveCourseListBean.rows);
|
|
} else {
|
|
} else {
|
|
showEmptyView();
|
|
showEmptyView();
|
|
@@ -207,6 +231,44 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
|
|
|
|
+ private void initPopu(View targetView) {
|
|
|
|
+ if (mPopupWindow == null) {
|
|
|
|
+ View popupContentView = LayoutInflater.from(requireContext()).inflate(com.cooleshow.base.R.layout.list_popu_layout, null);
|
|
|
|
+ RecyclerView recyclerView = popupContentView.findViewById(R.id.recyclerView);
|
|
|
|
+ View bg = popupContentView.findViewById(com.cooleshow.base.R.id.view);
|
|
|
|
+ bg.setOnClickListener(new View.OnClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onClick(View v) {
|
|
|
|
+ if (mPopupWindow != null) {
|
|
|
|
+ mPopupWindow.dismiss();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ mCourseStatusFilterAdapter = new CourseStatusFilterAdapter(com.cooleshow.base.R.layout.notice_popu_list_item);
|
|
|
|
+ mCourseStatusFilterAdapter.setOnItemClickListener(new OnItemClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
|
|
|
|
+ Object object = mCourseStatusFilterAdapter.getData().get(position);
|
|
|
|
+ if (object instanceof CourseFilterStatusBean) {
|
|
|
|
+ if (mCourseStatusFilterAdapter != null) {
|
|
|
|
+ mCourseStatusFilterAdapter.setSelect(position);
|
|
|
|
+ }
|
|
|
|
+ CourseFilterStatusBean filterStatusBean = (CourseFilterStatusBean) object;
|
|
|
|
+ mViewBinding.tvCourseStatus.setText(filterStatusBean.showText);
|
|
|
|
+ reBuildFilter(currentSelectDate, filterStatusBean.value);
|
|
|
|
+ }
|
|
|
|
+ mPopupWindow.dismiss();
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
|
|
|
+ recyclerView.setAdapter(mCourseStatusFilterAdapter);
|
|
|
|
+ mCourseStatusFilterAdapter.setNewInstance(mCourseFilterStatusBeans);
|
|
|
|
+ mPopupWindow = PopupUtil.createNoBackPopupWindow(popupContentView, requireContext(), ViewGroup.LayoutParams.MATCH_PARENT,
|
|
|
|
+ ViewGroup.LayoutParams.WRAP_CONTENT, true);
|
|
|
|
+ }
|
|
|
|
+ mPopupWindow.showAsDropDown(targetView);
|
|
|
|
+ }
|
|
|
|
+
|
|
@Override
|
|
@Override
|
|
public void onClick(View v) {
|
|
public void onClick(View v) {
|
|
if (v.getId() == R.id.tv_time) {
|
|
if (v.getId() == R.id.tv_time) {
|
|
@@ -214,5 +276,11 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
showTimeSelectPicker();
|
|
showTimeSelectPicker();
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+ if (v.getId() == R.id.tv_course_status) {
|
|
|
|
+ //课程状态筛选
|
|
|
|
+ initPopu(mViewBinding.tvCourseStatus);
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
}
|
|
}
|
|
}
|
|
}
|