|
@@ -0,0 +1,253 @@
|
|
|
|
+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.PianoCourseGroupAdapter;
|
|
|
|
+import com.cooleshow.teacher.adapter.VIPCourseAdapter;
|
|
|
|
+import com.cooleshow.teacher.bean.QuerySubjectBean;
|
|
|
|
+import com.cooleshow.teacher.bean.VIPCourseGroupListBean;
|
|
|
|
+import com.cooleshow.teacher.contract.InterestCourseGroupContract;
|
|
|
|
+import com.cooleshow.teacher.contract.PianoCourseGroupContract;
|
|
|
|
+import com.cooleshow.teacher.databinding.FgInterestCourseLayoutBinding;
|
|
|
|
+import com.cooleshow.teacher.databinding.FgPianoCourseGroupLayoutBinding;
|
|
|
|
+import com.cooleshow.teacher.presenter.course.InterestCourseGroupPresenter;
|
|
|
|
+import com.cooleshow.teacher.presenter.course.PianoCourseGroupPresenter;
|
|
|
|
+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;
|
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
|
+
|
|
|
|
+/**
|
|
|
|
+ * Author by pq, Date on 2022/5/9.
|
|
|
|
+ * 我的课程-趣纠课课程组
|
|
|
|
+ */
|
|
|
|
+public class PianoCourseGroupFragment extends BaseMVPFragment<FgPianoCourseGroupLayoutBinding, PianoCourseGroupPresenter> implements PianoCourseGroupContract.View, View.OnClickListener {
|
|
|
|
+ private List<IFilterViewData> subjectBeanList = new ArrayList<>();//声部筛选
|
|
|
|
+ private PianoCourseGroupAdapter 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 PianoCourseGroupAdapter();
|
|
|
|
+ EmptyViewLayout mEmptyView = new EmptyViewLayout(getContext());
|
|
|
|
+ mEmptyView.setContent(com.cooleshow.base.R.drawable.icon_empty_course, "暂无课程");
|
|
|
|
+ mAdapter.setEmptyView(mEmptyView);
|
|
|
|
+ mViewBinding.recyclerViewList.setAdapter(mAdapter);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected void initData() {
|
|
|
|
+ CourseGroupStatusType[] values = CourseGroupStatusType.values();
|
|
|
|
+ List<CourseGroupStatusType> courseGroupStatusTypes = Arrays.asList(values);
|
|
|
|
+ statusList = new ArrayList<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) {
|
|
|
|
+ currentPage = 1;
|
|
|
|
+ getData(false);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ mViewBinding.refreshLayout.setOnLoadMoreListener(new OnLoadMoreListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
|
|
|
+ //上拉加载
|
|
|
|
+ if (hasNext) {
|
|
|
|
+ currentPage++;
|
|
|
|
+ getData(false);
|
|
|
|
+ } else {
|
|
|
|
+ mViewBinding.refreshLayout.finishLoadMoreWithNoMoreData();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+
|
|
|
|
+ mAdapter.setOnItemClickListener(new OnItemClickListener() {
|
|
|
|
+ @Override
|
|
|
|
+ public void onItemClick(@NonNull BaseQuickAdapter<?, ?> adapter, @NonNull View view, int position) {
|
|
|
|
+ //课程详情页
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ private void getData(boolean isLoading) {
|
|
|
|
+ if (currentPage == 1) {
|
|
|
|
+ mViewBinding.refreshLayout.resetNoMoreData();
|
|
|
|
+ }
|
|
|
|
+ presenter.queryInterestCourseGroup(isLoading, status, currentSubjectId, searchCondition, currentPage);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected FgPianoCourseGroupLayoutBinding getLayoutView() {
|
|
|
|
+ return FgPianoCourseGroupLayoutBinding.inflate(getLayoutInflater());
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ protected PianoCourseGroupPresenter createPresenter() {
|
|
|
|
+ return new PianoCourseGroupPresenter();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @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;
|
|
|
|
+ PianoCourseGroupFragment.this.status = obj;
|
|
|
|
+ PianoCourseGroupFragment.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);
|
|
|
|
+ }
|
|
|
|
+ });
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onResume() {
|
|
|
|
+ super.onResume();
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+
|
|
|
|
+ private void checkHasNext(int dataSize) {
|
|
|
|
+ hasNext = dataSize >= Constants.DEFAULT_DATA_SIZE;
|
|
|
|
+ mViewBinding.refreshLayout.setNoMoreData(!hasNext);
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onGetCourseGroupSuccess(int page, VIPCourseGroupListBean dataList) {
|
|
|
|
+ if (isDetached()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ LOG.i("pq", "onGetCourseGroupSuccess:" + dataList);
|
|
|
|
+ if (dataList != null) {
|
|
|
|
+ if (page == 1) {
|
|
|
|
+ //第一页
|
|
|
|
+ mViewBinding.refreshLayout.finishRefresh();
|
|
|
|
+ if (mAdapter != null) {
|
|
|
|
+ mAdapter.getData().clear();
|
|
|
|
+ mAdapter.notifyDataSetChanged();
|
|
|
|
+ if (dataList.getRows() != null && dataList.getRows().size() > 0) {
|
|
|
|
+ checkHasNext(dataList.getRows().size());
|
|
|
|
+ mAdapter.setNewInstance(dataList.getRows());
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ } else {
|
|
|
|
+ //加载更多
|
|
|
|
+ if (mAdapter != null) {
|
|
|
|
+ if (dataList.getRows() != null && dataList.getRows().size() > 0) {
|
|
|
|
+ mViewBinding.refreshLayout.finishLoadMore();
|
|
|
|
+ checkHasNext(dataList.getRows().size());
|
|
|
|
+ mAdapter.addData(dataList.getRows());
|
|
|
|
+ } else {
|
|
|
|
+ mViewBinding.refreshLayout.finishLoadMoreWithNoMoreData();
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ @Override
|
|
|
|
+ public void onGetCourseGroupError(int page) {
|
|
|
|
+ if (isDetached()) {
|
|
|
|
+ return;
|
|
|
|
+ }
|
|
|
|
+ if (page == 1) {
|
|
|
|
+ mViewBinding.refreshLayout.finishRefresh();
|
|
|
|
+ } else {
|
|
|
|
+ if (mAdapter != null) {
|
|
|
|
+ currentPage--;
|
|
|
|
+ mViewBinding.refreshLayout.finishLoadMore(false);
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+ }
|
|
|
|
+
|
|
|
|
+ public void querySubjectItemSuccess(List<QuerySubjectBean> data) {
|
|
|
|
+ subjectBeanList.clear();
|
|
|
|
+ subjectBeanList.add(new QuerySubjectBean("全部", 0));
|
|
|
|
+ subjectBeanList.addAll(data);
|
|
|
|
+ }
|
|
|
|
+}
|