|
@@ -1,25 +1,57 @@
|
|
|
package com.cooleshow.student.ui.course;
|
|
|
|
|
|
+import android.graphics.Color;
|
|
|
+import android.text.TextUtils;
|
|
|
import android.view.View;
|
|
|
+import android.widget.TextView;
|
|
|
|
|
|
+import com.bigkoo.pickerview.builder.OptionsPickerBuilder;
|
|
|
+import com.bigkoo.pickerview.listener.OnDismissListener;
|
|
|
+import com.bigkoo.pickerview.view.OptionsPickerView;
|
|
|
+import com.cooleshow.base.bean.DataSortBean;
|
|
|
+import com.cooleshow.base.constanst.Constants;
|
|
|
+import com.cooleshow.base.constanst.DataSortType;
|
|
|
import com.cooleshow.base.ui.fragment.BaseMVPFragment;
|
|
|
+import com.cooleshow.base.utils.LOG;
|
|
|
+import com.cooleshow.base.utils.UiUtils;
|
|
|
+import com.cooleshow.base.widgets.CommonSortView;
|
|
|
+import com.cooleshow.base.widgets.EmptyViewLayout;
|
|
|
+import com.cooleshow.student.R;
|
|
|
+import com.cooleshow.student.adapter.VIPCourseCourseListAdapter;
|
|
|
+import com.cooleshow.student.bean.AppointCourseTeacherListBean;
|
|
|
import com.cooleshow.student.bean.QuerySubjectBean;
|
|
|
import com.cooleshow.student.contract.InterestCorrectionCourseListContract;
|
|
|
import com.cooleshow.student.databinding.FgInterestCorrectionCourseListLayoutBinding;
|
|
|
import com.cooleshow.student.databinding.FgVipCustomCourseListLayoutBinding;
|
|
|
import com.cooleshow.student.presenter.course.InterestCorrectionCourseListPresenter;
|
|
|
import com.cooleshow.student.presenter.course.VIPCustomCourseListPresenter;
|
|
|
+import com.cooleshow.usercenter.helper.UserHelper;
|
|
|
+import com.scwang.smart.refresh.footer.ClassicsFooter;
|
|
|
+import com.scwang.smart.refresh.layout.api.RefreshLayout;
|
|
|
+import com.scwang.smart.refresh.layout.listener.OnRefreshListener;
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
import java.util.List;
|
|
|
|
|
|
+import androidx.annotation.NonNull;
|
|
|
+import androidx.recyclerview.widget.LinearLayoutManager;
|
|
|
+
|
|
|
/**
|
|
|
* Author by pq, Date on 2024/11/13.
|
|
|
* 趣纠课约课
|
|
|
*/
|
|
|
-public class InterestCorrectionCourseListFragment extends BaseMVPFragment<FgInterestCorrectionCourseListLayoutBinding, InterestCorrectionCourseListPresenter> implements InterestCorrectionCourseListContract.View {
|
|
|
+public class InterestCorrectionCourseListFragment extends BaseMVPFragment<FgInterestCorrectionCourseListLayoutBinding, InterestCorrectionCourseListPresenter> implements InterestCorrectionCourseListContract.View, View.OnClickListener {
|
|
|
private List<QuerySubjectBean> subjectBeanList = new ArrayList<>();
|
|
|
-
|
|
|
+ private OptionsPickerView pvOptions;
|
|
|
+ private int currentSelectSubjectPosition = -1;
|
|
|
+ private String currentSubjectId;
|
|
|
+ private String sortField;
|
|
|
+ private String sortRule;
|
|
|
+ private boolean isRecentFreeTime;
|
|
|
+ private String searchCondition;
|
|
|
+ private int currentPage = 1;
|
|
|
+ private VIPCourseCourseListAdapter mAdapter;
|
|
|
+ private boolean hasNext = true;
|
|
|
|
|
|
public static InterestCorrectionCourseListFragment newInstance() {
|
|
|
InterestCorrectionCourseListFragment fragment = new InterestCorrectionCourseListFragment();
|
|
@@ -31,13 +63,73 @@ public class InterestCorrectionCourseListFragment extends BaseMVPFragment<FgInte
|
|
|
return FgInterestCorrectionCourseListLayoutBinding.inflate(getLayoutInflater());
|
|
|
}
|
|
|
|
|
|
+
|
|
|
@Override
|
|
|
protected void initView(View rootView) {
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initData() {
|
|
|
+ currentSubjectId = UserHelper.getSubjectId();
|
|
|
+ String subjectName = UserHelper.getSubjectName();
|
|
|
+ mViewBinding.tvFilter.setText(subjectName);
|
|
|
+
|
|
|
+ initListener();
|
|
|
+ DataSortBean dataSortBean = new DataSortBean(DataSortType.RECENT_FREE_TIME);
|
|
|
+ DataSortBean dataSortBean2 = new DataSortBean(DataSortType.HAS_COURSE);
|
|
|
+ DataSortBean dataSortBean3 = new DataSortBean(DataSortType.COURSE_PRICE);
|
|
|
+ DataSortBean dataSortBean4 = new DataSortBean(DataSortType.COURSE_MARK);
|
|
|
+ ArrayList<DataSortBean> list = new ArrayList();
|
|
|
+ list.add(dataSortBean);
|
|
|
+ list.add(dataSortBean2);
|
|
|
+ list.add(dataSortBean3);
|
|
|
+ list.add(dataSortBean4);
|
|
|
+ mViewBinding.sortView.setData(list);
|
|
|
+
|
|
|
+ mAdapter = new VIPCourseCourseListAdapter();
|
|
|
+ EmptyViewLayout emptyViewLayout = new EmptyViewLayout(getContext());
|
|
|
+ emptyViewLayout.setContent(com.cooleshow.base.R.drawable.icon_empty_course, "暂无课程");
|
|
|
+ mViewBinding.recyclerViewList.setLayoutManager(new LinearLayoutManager(getContext()));
|
|
|
+ mViewBinding.recyclerViewList.setAdapter(mAdapter);
|
|
|
+ mAdapter.setEmptyView(emptyViewLayout);
|
|
|
+
|
|
|
+ getData(true);
|
|
|
+ }
|
|
|
+
|
|
|
+ private void initListener() {
|
|
|
+ mViewBinding.tvFilter.setOnClickListener(this);
|
|
|
+ mViewBinding.tvSearch.setOnClickListener(this);
|
|
|
+ mViewBinding.refreshLayout.setRefreshFooter(new ClassicsFooter(getContext()).setDrawableSize(20));
|
|
|
+ mViewBinding.refreshLayout.setOnRefreshListener(new OnRefreshListener() {
|
|
|
+ @Override
|
|
|
+ public void onRefresh(@NonNull RefreshLayout refreshLayout) {
|
|
|
+ currentPage = 1;
|
|
|
+ getData(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ mViewBinding.refreshLayout.setOnLoadMoreListener(new com.scwang.smart.refresh.layout.listener.OnLoadMoreListener() {
|
|
|
+ @Override
|
|
|
+ public void onLoadMore(@NonNull RefreshLayout refreshLayout) {
|
|
|
+ //上拉加载
|
|
|
+ if (hasNext) {
|
|
|
+ currentPage++;
|
|
|
+ getData(false);
|
|
|
+ } else {
|
|
|
+ mViewBinding.refreshLayout.finishLoadMoreWithNoMoreData();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
+ mViewBinding.sortView.setEventListener(new CommonSortView.OnEventListener() {
|
|
|
+ @Override
|
|
|
+ public void onFilterResult(boolean isRecentFreeTime, String sortField, String sortRule) {
|
|
|
+ InterestCorrectionCourseListFragment.this.isRecentFreeTime = isRecentFreeTime;
|
|
|
+ InterestCorrectionCourseListFragment.this.sortField = sortField;
|
|
|
+ InterestCorrectionCourseListFragment.this.sortRule = sortRule;
|
|
|
+ currentPage = 1;
|
|
|
+ getData(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
|
|
|
}
|
|
|
|
|
@@ -46,10 +138,135 @@ public class InterestCorrectionCourseListFragment extends BaseMVPFragment<FgInte
|
|
|
return new InterestCorrectionCourseListPresenter();
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onClick(View v) {
|
|
|
+ int id = v.getId();
|
|
|
+ if (id == R.id.tv_filter) {
|
|
|
+ selectSubjectType();
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (id == R.id.tv_search) {
|
|
|
+ currentPage = 1;
|
|
|
+ searchCondition = mViewBinding.etTargetName.getText().toString().trim();
|
|
|
+ getData(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ private void selectSubjectType() {
|
|
|
+ if (subjectBeanList.size() == 0) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (pvOptions == null) {
|
|
|
+ pvOptions = new OptionsPickerBuilder(getContext(), (options1, options2, options3, v) -> {
|
|
|
+ this.currentSelectSubjectPosition = options1;
|
|
|
+ QuerySubjectBean subjectBean = subjectBeanList.get(options1);
|
|
|
+ this.currentSubjectId = subjectBean.getId();
|
|
|
+ mViewBinding.tvFilter.setText(subjectBean.getPickerViewText());
|
|
|
+ currentPage = 1;
|
|
|
+ getData(false);
|
|
|
+ }).setLayoutRes(com.cooleshow.base.R.layout.pickerview_select_options_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());
|
|
|
+
|
|
|
+ }).setTextColorOut(getResources().getColor(com.cooleshow.base.R.color.color_aaaaaa))
|
|
|
+ .setDividerColor(Color.TRANSPARENT)
|
|
|
+ .setBgColor(Color.TRANSPARENT).isDialog(false).build();
|
|
|
+ pvOptions.setOnDismissListener(new OnDismissListener() {
|
|
|
+ @Override
|
|
|
+ public void onDismiss(Object o) {
|
|
|
+ UiUtils.refreshFilterTextStyle(false, mViewBinding.tvFilter);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onShow() {
|
|
|
+ UiUtils.refreshFilterTextStyle(true, mViewBinding.tvFilter);
|
|
|
+ }
|
|
|
+ });
|
|
|
+ }
|
|
|
+ pvOptions.setPicker(subjectBeanList);
|
|
|
+ if (currentSelectSubjectPosition != -1 && currentSelectSubjectPosition < subjectBeanList.size()) {
|
|
|
+ pvOptions.setSelectOptions(currentSelectSubjectPosition);
|
|
|
+ }
|
|
|
+ pvOptions.show();
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void getData(boolean isShowLoading) {
|
|
|
+ if (currentPage == 1) {
|
|
|
+ mViewBinding.refreshLayout.resetNoMoreData();
|
|
|
+ }
|
|
|
+ presenter.queryCourseTeachers(isShowLoading, currentSubjectId, sortField, sortRule, searchCondition, isRecentFreeTime, currentPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onGetTeacherListSuccess(int page, AppointCourseTeacherListBean dataList) {
|
|
|
+ if (isDetached()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LOG.i("pq", "interest queryGroupNoticeSuccess:" + 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();
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ }
|
|
|
+
|
|
|
+ private void checkHasNext(int dataSize) {
|
|
|
+ hasNext = dataSize >= Constants.DEFAULT_DATA_SIZE;
|
|
|
+ }
|
|
|
+
|
|
|
public void querySubjectItemSuccess(List<QuerySubjectBean> data) {
|
|
|
subjectBeanList.clear();
|
|
|
- subjectBeanList.add(new QuerySubjectBean("全部声部", 0));
|
|
|
subjectBeanList.addAll(data);
|
|
|
+ String subjectId = UserHelper.getSubjectId();
|
|
|
+ for (int i = 0; i < data.size(); i++) {
|
|
|
+ QuerySubjectBean querySubjectBean = data.get(i);
|
|
|
+ if (TextUtils.equals(subjectId, querySubjectBean.getId())) {
|
|
|
+ currentSelectSubjectPosition = i;
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
+ @Override
|
|
|
+ public void onGetTeacherListError(int page) {
|
|
|
+ if (isDetached()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (page == 1) {
|
|
|
+ mViewBinding.refreshLayout.finishRefresh();
|
|
|
+ } else {
|
|
|
+ if (mAdapter != null) {
|
|
|
+ currentPage--;
|
|
|
+ mViewBinding.refreshLayout.finishLoadMore(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|