|
@@ -1,5 +1,6 @@
|
|
|
package com.cooleshow.student.ui.course;
|
|
|
|
|
|
+import android.annotation.SuppressLint;
|
|
|
import android.text.TextUtils;
|
|
|
import android.view.LayoutInflater;
|
|
|
import android.view.View;
|
|
@@ -31,6 +32,8 @@ import com.cooleshow.base.utils.PopupUtil;
|
|
|
import com.cooleshow.base.utils.TimeUtils;
|
|
|
import com.cooleshow.base.widgets.EmptyViewLayout;
|
|
|
|
|
|
+import com.cooleshow.base.widgets.poplist.PopMenuBean;
|
|
|
+import com.cooleshow.base.widgets.poplist.PopupListWindow;
|
|
|
import com.cooleshow.student.R;
|
|
|
import com.cooleshow.student.adapter.CourseStatusFilterAdapter;
|
|
|
import com.cooleshow.student.adapter.LiveCourseListAdapter;
|
|
@@ -60,12 +63,9 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
private int currentPage;
|
|
|
private LiveCourseListAdapter mAdapter;
|
|
|
private EmptyViewLayout mEmptyView;
|
|
|
- private TextView mTvEmptyTip;
|
|
|
- private ImageView mEmptyIcon;
|
|
|
private TimePickerView pvTime;
|
|
|
- private PopupWindow mPopupWindow;
|
|
|
private ArrayList<CourseFilterStatusBean> mCourseFilterStatusBeans;
|
|
|
- private CourseStatusFilterAdapter mCourseStatusFilterAdapter;
|
|
|
+ private List<QuerySubjectBean> subjectBeanList = new ArrayList<>();
|
|
|
private boolean hasNext = true;
|
|
|
private boolean isFirstLoad = true;
|
|
|
|
|
@@ -73,6 +73,7 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
LiveCourseFragment fragment = new LiveCourseFragment();
|
|
|
return fragment;
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
protected FragmentLiveCourseLayoutBinding getLayoutView() {
|
|
|
return FragmentLiveCourseLayoutBinding.inflate(getLayoutInflater());
|
|
@@ -89,10 +90,11 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
mViewBinding.tvCourseStatus.setOnClickListener(this);
|
|
|
mViewBinding.tvAgency.setOnClickListener(this);
|
|
|
}
|
|
|
+
|
|
|
@Override
|
|
|
public void onResume() {
|
|
|
super.onResume();
|
|
|
- if(isFirstLoad){
|
|
|
+ if (isFirstLoad) {
|
|
|
isFirstLoad = false;
|
|
|
reBuildFilter(null, CourseConstants.COURSE_FILTER_ALL);
|
|
|
}
|
|
@@ -104,6 +106,7 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
reBuildFilter(currentSelectDate, currentCourseFilterStatus);
|
|
|
isFirstLoad = false;
|
|
|
}
|
|
|
+
|
|
|
private void buildDefaultCourseStatusFilterList() {
|
|
|
mCourseFilterStatusBeans = new ArrayList<>();
|
|
|
mCourseFilterStatusBeans.add(new CourseFilterStatusBean(CourseConstants.COURSE_FILTER_ALL, "全部"));
|
|
@@ -128,41 +131,30 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
|
|
|
@Override
|
|
|
protected void initData() {
|
|
|
- mViewBinding.refreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
|
|
- @Override
|
|
|
- public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
|
|
- currentPage = 1;
|
|
|
- queryCourse(true);
|
|
|
- }
|
|
|
+ mViewBinding.refreshLayout.setOnRefreshListener(refreshLayout -> {
|
|
|
+ currentPage = 1;
|
|
|
+ queryCourse(true);
|
|
|
});
|
|
|
|
|
|
mAdapter = new LiveCourseListAdapter(R.layout.item_live_course_list_layout);
|
|
|
-// mAdapter.getLoadMoreModule().setEnableLoadMoreIfNotFullPage(false);
|
|
|
- mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
|
- @Override
|
|
|
- public void onLoadMore() {
|
|
|
- //上拉加载
|
|
|
- if (hasNext) {
|
|
|
- currentPage++;
|
|
|
- queryCourse(false);
|
|
|
- } else {
|
|
|
- mAdapter.getLoadMoreModule().loadMoreEnd();
|
|
|
- }
|
|
|
+ mAdapter.getLoadMoreModule().setOnLoadMoreListener(() -> {
|
|
|
+ //上拉加载
|
|
|
+ if (hasNext) {
|
|
|
+ currentPage++;
|
|
|
+ queryCourse(false);
|
|
|
+ } else {
|
|
|
+ mAdapter.getLoadMoreModule().loadMoreEnd();
|
|
|
}
|
|
|
});
|
|
|
mViewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
|
|
mViewBinding.recyclerView.setAdapter(mAdapter);
|
|
|
- presenter.querySubjectItem();
|
|
|
buildDefaultCourseStatusFilterList();
|
|
|
- mAdapter.setOnItemClickListener(new OnItemClickListener() {
|
|
|
- @Override
|
|
|
- public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
|
|
|
- LiveCourseListBean.RowsBean item = (LiveCourseListBean.RowsBean) adapter.getItem(position);
|
|
|
- ARouter.getInstance()
|
|
|
- .build(RouterPath.WebCenter.ACTIVITY_HTML)
|
|
|
- .withString(WebConstants.WEB_URL, WebConstants.TEACHER_LIVE_DETAIL + "?groupId=" + item.courseGroupId)
|
|
|
- .navigation();
|
|
|
- }
|
|
|
+ mAdapter.setOnItemClickListener((adapter, view, position) -> {
|
|
|
+ LiveCourseListBean.RowsBean item = (LiveCourseListBean.RowsBean) adapter.getItem(position);
|
|
|
+ ARouter.getInstance()
|
|
|
+ .build(RouterPath.WebCenter.ACTIVITY_HTML)
|
|
|
+ .withString(WebConstants.WEB_URL, WebConstants.TEACHER_LIVE_DETAIL + "?groupId=" + item.courseGroupId)
|
|
|
+ .navigation();
|
|
|
});
|
|
|
}
|
|
|
|
|
@@ -180,6 +172,7 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
}
|
|
|
|
|
|
|
|
|
+ @SuppressLint("NotifyDataSetChanged")
|
|
|
@Override
|
|
|
public void onGetLiveCourseSuccess(int page, LiveCourseListBean liveCourseListBean) {
|
|
|
if (isDetached()) {
|
|
@@ -242,22 +235,16 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
if (pvTime == null) {
|
|
|
pvTime = new TimePickerBuilder(requireContext(), (date, v) -> {//选中事件回调
|
|
|
reBuildFilter(date, currentCourseFilterStatus);
|
|
|
- }).setLayoutRes(com.cooleshow.base.R.layout.pickerview_default_layout, new CustomListener() {
|
|
|
- @Override
|
|
|
- public void customLayout(View v) {
|
|
|
- //自定义布局中的控件初始化及事件处理
|
|
|
- final TextView tvSubmit = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_finish);
|
|
|
- TextView ivCancel = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_cancel);
|
|
|
- tvSubmit.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- pvTime.returnData();
|
|
|
- pvTime.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
- ivCancel.setOnClickListener(v1 -> pvTime.dismiss());
|
|
|
+ }).setLayoutRes(com.cooleshow.base.R.layout.pickerview_default_layout, v -> {
|
|
|
+ //自定义布局中的控件初始化及事件处理
|
|
|
+ final TextView tvSubmit = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_finish);
|
|
|
+ TextView ivCancel = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_cancel);
|
|
|
+ tvSubmit.setOnClickListener(v12 -> {
|
|
|
+ pvTime.returnData();
|
|
|
+ pvTime.dismiss();
|
|
|
+ });
|
|
|
+ ivCancel.setOnClickListener(v1 -> pvTime.dismiss());
|
|
|
|
|
|
- }
|
|
|
}).setLineSpacingMultiplier(2.5f)
|
|
|
.setType(new boolean[]{true, true, false, false, false, false})// 默认全部显示
|
|
|
.setTextColorCenter(getResources().getColor(com.cooleshow.base.R.color.color_1a1a1a))//设置选中项的颜色
|
|
@@ -273,44 +260,6 @@ 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
|
|
|
public void onClick(View v) {
|
|
|
if (v.getId() == R.id.tv_time) {
|
|
@@ -321,60 +270,74 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayout
|
|
|
|
|
|
if (v.getId() == R.id.tv_course_status) {
|
|
|
//课程状态筛选
|
|
|
- initPopu(mViewBinding.tvCourseStatus);
|
|
|
+ List<PopMenuBean> popList = new ArrayList<>();
|
|
|
+ for (CourseFilterStatusBean bean : mCourseFilterStatusBeans) {
|
|
|
+ PopMenuBean popMenuBean = new PopMenuBean();
|
|
|
+ popMenuBean.setActionName(bean.showText);
|
|
|
+ popList.add(popMenuBean);
|
|
|
+ }
|
|
|
+ initCoursePop(mViewBinding.tvCourseStatus, popList, position -> {
|
|
|
+ CourseFilterStatusBean bean = mCourseFilterStatusBeans.get(position);
|
|
|
+ mViewBinding.tvCourseStatus.setText(bean.showText);
|
|
|
+ reBuildFilter(currentSelectDate, bean.value);
|
|
|
+ });
|
|
|
return;
|
|
|
}
|
|
|
|
|
|
- if (v.getId()==R.id.tv_agency){
|
|
|
+ if (v.getId() == R.id.tv_agency) {
|
|
|
//选择声部
|
|
|
- selectSubject();
|
|
|
+ if (subjectBeanList.size() == 0) {
|
|
|
+ subjectBeanList.add(new QuerySubjectBean("全部声部", 0));
|
|
|
+ }
|
|
|
+ List<PopMenuBean> popList = new ArrayList<>();
|
|
|
+ for (QuerySubjectBean bean : subjectBeanList) {
|
|
|
+ PopMenuBean popMenuBean = new PopMenuBean();
|
|
|
+ popMenuBean.setActionName(bean.name);
|
|
|
+ popList.add(popMenuBean);
|
|
|
+ }
|
|
|
+ initCoursePop(mViewBinding.tvCourseStatus, popList, position -> {
|
|
|
+ QuerySubjectBean bean = subjectBeanList.get(position);
|
|
|
+ currentSubjectId = bean.id;
|
|
|
+ mViewBinding.tvAgency.setText(bean.name);
|
|
|
+ queryCourse(true);
|
|
|
+ });
|
|
|
return;
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private List<QuerySubjectBean> subjectBeanList = new ArrayList<>();
|
|
|
|
|
|
- @Override
|
|
|
+ private void initCoursePop(View targetView, List<PopMenuBean> popList, PopupListWindow.PopupListListener listener) {
|
|
|
+ PopupListWindow popWindow = new PopupListWindow(getContext());
|
|
|
+ popWindow.showListPop(targetView, popList, position -> listener.onPopupListClick(position));
|
|
|
+ }
|
|
|
+
|
|
|
public void querySubjectItemSuccess(List<QuerySubjectBean> data) {
|
|
|
subjectBeanList.clear();
|
|
|
- subjectBeanList.add(new QuerySubjectBean("全部声部",0));
|
|
|
+ subjectBeanList.add(new QuerySubjectBean("全部声部", 0));
|
|
|
subjectBeanList.addAll(data);
|
|
|
}
|
|
|
|
|
|
private OptionsPickerView pvOptions;
|
|
|
+
|
|
|
private void selectSubject() {
|
|
|
- pvOptions = new OptionsPickerBuilder(getContext(), new OnOptionsSelectListener() {
|
|
|
- @Override
|
|
|
- public void onOptionsSelect(int options1, int options2, int options3, View v) {
|
|
|
- currentSubjectId=subjectBeanList.get(options1).id;
|
|
|
- mViewBinding.tvAgency.setText(subjectBeanList.get(options1).name);
|
|
|
- queryCourse(true);
|
|
|
- }
|
|
|
- })
|
|
|
- .setLayoutRes(R.layout.pickerview_address_layout, new CustomListener() {
|
|
|
- @Override
|
|
|
- public void customLayout(View v) {
|
|
|
- //自定义布局中的控件初始化及事件处理
|
|
|
- final TextView tvSubmit = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_finish);
|
|
|
- TextView ivCancel = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_cancel);
|
|
|
- tvSubmit.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- pvOptions.returnData();
|
|
|
- pvOptions.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
- ivCancel.setOnClickListener(new View.OnClickListener() {
|
|
|
- @Override
|
|
|
- public void onClick(View v) {
|
|
|
- pvOptions.dismiss();
|
|
|
- }
|
|
|
- });
|
|
|
+ if (subjectBeanList.size() == 0) {
|
|
|
+ subjectBeanList.add(new QuerySubjectBean("全部声部", 0));
|
|
|
+ }
|
|
|
+ pvOptions = new OptionsPickerBuilder(getContext(), (options1, options2, options3, v) -> {
|
|
|
+ currentSubjectId = subjectBeanList.get(options1).id;
|
|
|
+ mViewBinding.tvAgency.setText(subjectBeanList.get(options1).name);
|
|
|
+ queryCourse(true);
|
|
|
+ }).setLayoutRes(R.layout.pickerview_address_layout, v -> {
|
|
|
+ //自定义布局中的控件初始化及事件处理
|
|
|
+ final TextView tvSubmit = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_finish);
|
|
|
+ TextView ivCancel = (TextView) v.findViewById(com.cooleshow.base.R.id.tv_cancel);
|
|
|
+ tvSubmit.setOnClickListener(v12 -> {
|
|
|
+ pvOptions.returnData();
|
|
|
+ pvOptions.dismiss();
|
|
|
+ });
|
|
|
+ ivCancel.setOnClickListener(v1 -> pvOptions.dismiss());
|
|
|
|
|
|
- }
|
|
|
- })
|
|
|
- .isDialog(false)
|
|
|
- .build();
|
|
|
+ }).isDialog(false).build();
|
|
|
pvOptions.setPicker(subjectBeanList);
|
|
|
pvOptions.show();
|
|
|
|