|
@@ -1,17 +1,23 @@
|
|
package com.cooleshow.teacher.ui.course;
|
|
package com.cooleshow.teacher.ui.course;
|
|
|
|
|
|
import android.view.View;
|
|
import android.view.View;
|
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
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.TimeUtils;
|
|
import com.cooleshow.base.utils.TimeUtils;
|
|
import com.cooleshow.teacher.R;
|
|
import com.cooleshow.teacher.R;
|
|
|
|
+import com.cooleshow.teacher.adapter.LiveCourseListAdapter;
|
|
import com.cooleshow.teacher.adapter.SparringCourseListAdapter;
|
|
import com.cooleshow.teacher.adapter.SparringCourseListAdapter;
|
|
|
|
+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;
|
|
|
|
+import com.cooleshow.teacher.contract.LiveCourseContract;
|
|
import com.cooleshow.teacher.contract.SparringCourseContract;
|
|
import com.cooleshow.teacher.contract.SparringCourseContract;
|
|
|
|
+import com.cooleshow.teacher.databinding.FragmentLiveCourseLayoutBinding;
|
|
import com.cooleshow.teacher.databinding.FragmentSparringCourseLayoutBinding;
|
|
import com.cooleshow.teacher.databinding.FragmentSparringCourseLayoutBinding;
|
|
|
|
+import com.cooleshow.teacher.presenter.course.LiveCoursePresenter;
|
|
import com.cooleshow.teacher.presenter.course.SparringCoursePresenter;
|
|
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;
|
|
@@ -22,26 +28,29 @@ import androidx.recyclerview.widget.LinearLayoutManager;
|
|
/**
|
|
/**
|
|
* Author by pq, Date on 2022/4/25.
|
|
* Author by pq, Date on 2022/4/25.
|
|
*/
|
|
*/
|
|
-public class LiveCourseFragment extends BaseMVPFragment<FragmentSparringCourseLayoutBinding, SparringCoursePresenter> implements SparringCourseContract.SparringCourseView {
|
|
|
|
|
|
+public class LiveCourseFragment extends BaseMVPFragment<FragmentLiveCourseLayoutBinding, LiveCoursePresenter> implements LiveCourseContract.LiveCourseView {
|
|
private String currentCourseFilterStatus = CourseFilterConstants.COURSE_FILTER_ALL;
|
|
private String currentCourseFilterStatus = CourseFilterConstants.COURSE_FILTER_ALL;
|
|
private String currentFilterDate;
|
|
private String currentFilterDate;
|
|
private int currentSubjectId;
|
|
private int currentSubjectId;
|
|
private int currentPage;
|
|
private int currentPage;
|
|
- private SparringCourseListAdapter mAdapter;
|
|
|
|
|
|
+ private LiveCourseListAdapter mAdapter;
|
|
|
|
+ private View mEmptyView;
|
|
|
|
+ private TextView mTvEmptyTip;
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected FragmentSparringCourseLayoutBinding getLayoutView() {
|
|
|
|
- return FragmentSparringCourseLayoutBinding.inflate(getLayoutInflater());
|
|
|
|
|
|
+ protected FragmentLiveCourseLayoutBinding getLayoutView() {
|
|
|
|
+ return FragmentLiveCourseLayoutBinding.inflate(getLayoutInflater());
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- protected SparringCoursePresenter createPresenter() {
|
|
|
|
- return new SparringCoursePresenter();
|
|
|
|
|
|
+ protected LiveCoursePresenter createPresenter() {
|
|
|
|
+ return new LiveCoursePresenter();
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
protected void initView(View rootView) {
|
|
protected void initView(View rootView) {
|
|
buildDefaultFilter();
|
|
buildDefaultFilter();
|
|
|
|
+ mViewBinding.tvTime.setText(currentFilterDate);
|
|
}
|
|
}
|
|
|
|
|
|
private void buildDefaultFilter() {
|
|
private void buildDefaultFilter() {
|
|
@@ -61,7 +70,7 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentSparringCourseLa
|
|
}
|
|
}
|
|
});
|
|
});
|
|
|
|
|
|
- mAdapter = new SparringCourseListAdapter(R.layout.item_sparring_course_list_layout);
|
|
|
|
|
|
+ mAdapter = new LiveCourseListAdapter(R.layout.item_live_course_list_layout);
|
|
mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
mAdapter.getLoadMoreModule().setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
@Override
|
|
@Override
|
|
public void onLoadMore() {
|
|
public void onLoadMore() {
|
|
@@ -72,31 +81,32 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentSparringCourseLa
|
|
});
|
|
});
|
|
mViewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
|
mViewBinding.recyclerView.setLayoutManager(new LinearLayoutManager(requireContext()));
|
|
mViewBinding.recyclerView.setAdapter(mAdapter);
|
|
mViewBinding.recyclerView.setAdapter(mAdapter);
|
|
|
|
+ queryCourse();
|
|
}
|
|
}
|
|
|
|
|
|
private void queryCourse() {
|
|
private void queryCourse() {
|
|
//根据默认筛选条件查询
|
|
//根据默认筛选条件查询
|
|
- LogUtils.i("pq","currentFilterDate:"+currentFilterDate);
|
|
|
|
- LogUtils.i("pq","currentCourseFilterStatus:"+currentCourseFilterStatus);
|
|
|
|
- LogUtils.i("pq","currentSubjectId:"+currentSubjectId);
|
|
|
|
- LogUtils.i("pq","currentPage:"+currentPage);
|
|
|
|
- presenter.querySparringCourse(currentFilterDate, currentCourseFilterStatus, currentSubjectId, currentPage);
|
|
|
|
|
|
+ LogUtils.i("pq", "currentFilterDate:" + currentFilterDate);
|
|
|
|
+ LogUtils.i("pq", "currentCourseFilterStatus:" + currentCourseFilterStatus);
|
|
|
|
+ LogUtils.i("pq", "currentSubjectId:" + currentSubjectId);
|
|
|
|
+ LogUtils.i("pq", "currentPage:" + currentPage);
|
|
|
|
+ presenter.queryLiveCourse(currentFilterDate, currentCourseFilterStatus, currentSubjectId, currentPage);
|
|
}
|
|
}
|
|
|
|
|
|
@Override
|
|
@Override
|
|
- public void onGetSparringCourseSuccess(int page, SparringCourseListBean sparringCourseBean) {
|
|
|
|
|
|
+ public void onGetLiveCourseSuccess(int page, LiveCourseListBean liveCourseListBean) {
|
|
if (isDetached()) {
|
|
if (isDetached()) {
|
|
return;
|
|
return;
|
|
}
|
|
}
|
|
- if (sparringCourseBean != null) {
|
|
|
|
- if (page != 1) {
|
|
|
|
|
|
+ if (liveCourseListBean != null) {
|
|
|
|
+ if (page == 1) {
|
|
//第一页
|
|
//第一页
|
|
mViewBinding.refreshLayout.finishRefresh();
|
|
mViewBinding.refreshLayout.finishRefresh();
|
|
if (mAdapter != null) {
|
|
if (mAdapter != null) {
|
|
- if (sparringCourseBean.rows != null && sparringCourseBean.rows.size() > 0) {
|
|
|
|
|
|
+ if (liveCourseListBean.rows != null && liveCourseListBean.rows.size() > 0) {
|
|
mAdapter.getData().clear();
|
|
mAdapter.getData().clear();
|
|
mAdapter.notifyDataSetChanged();
|
|
mAdapter.notifyDataSetChanged();
|
|
- mAdapter.setNewInstance(sparringCourseBean.rows);
|
|
|
|
|
|
+ mAdapter.setNewInstance(liveCourseListBean.rows);
|
|
} else {
|
|
} else {
|
|
showEmptyView();
|
|
showEmptyView();
|
|
}
|
|
}
|
|
@@ -104,9 +114,9 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentSparringCourseLa
|
|
} else {
|
|
} else {
|
|
//加载更多
|
|
//加载更多
|
|
if (mAdapter != null) {
|
|
if (mAdapter != null) {
|
|
- mAdapter.getLoadMoreModule().loadMoreComplete();
|
|
|
|
- if (sparringCourseBean.rows != null && sparringCourseBean.rows.size() > 0) {
|
|
|
|
- mAdapter.addData(sparringCourseBean.rows);
|
|
|
|
|
|
+ if (liveCourseListBean.rows != null && liveCourseListBean.rows.size() > 0) {
|
|
|
|
+ mAdapter.getLoadMoreModule().loadMoreComplete();
|
|
|
|
+ mAdapter.addData(liveCourseListBean.rows);
|
|
} else {
|
|
} else {
|
|
mAdapter.getLoadMoreModule().loadMoreEnd();
|
|
mAdapter.getLoadMoreModule().loadMoreEnd();
|
|
}
|
|
}
|
|
@@ -121,6 +131,11 @@ public class LiveCourseFragment extends BaseMVPFragment<FragmentSparringCourseLa
|
|
}
|
|
}
|
|
|
|
|
|
private void showEmptyView() {
|
|
private void showEmptyView() {
|
|
-
|
|
|
|
|
|
+ if (mEmptyView == null) {
|
|
|
|
+ mEmptyView = getLayoutInflater().inflate(com.cooleshow.base.R.layout.empty_layout, mAdapter.getEmptyLayout(), false);
|
|
|
|
+ mTvEmptyTip = mEmptyView.findViewById(com.cooleshow.base.R.id.tv_empty_tip);
|
|
|
|
+ }
|
|
|
|
+ mTvEmptyTip.setText("暂无数据");
|
|
|
|
+ mAdapter.setEmptyView(mEmptyView);
|
|
}
|
|
}
|
|
}
|
|
}
|