|
@@ -7,26 +7,47 @@ 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.VIPCustomCourseListContract;
|
|
|
import com.cooleshow.student.databinding.FgVipCustomCourseListLayoutBinding;
|
|
|
import com.cooleshow.student.presenter.course.VIPCustomCourseListPresenter;
|
|
|
+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.
|
|
|
* VIP定制课约课
|
|
|
*/
|
|
|
-public class VIPCustomCourseListFragment extends BaseMVPFragment<FgVipCustomCourseListLayoutBinding, VIPCustomCourseListPresenter> implements View.OnClickListener {
|
|
|
+public class VIPCustomCourseListFragment extends BaseMVPFragment<FgVipCustomCourseListLayoutBinding, VIPCustomCourseListPresenter> implements View.OnClickListener, VIPCustomCourseListContract.VIPCustomCourseView {
|
|
|
private List<QuerySubjectBean> subjectList = new ArrayList<>();
|
|
|
private OptionsPickerView pvOptions;
|
|
|
private int currentSelectSubjectPosition = -1;
|
|
|
private String currentSubjectId;
|
|
|
- private int currentPage =1;
|
|
|
+ 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 VIPCustomCourseListFragment newInstance() {
|
|
|
VIPCustomCourseListFragment fragment = new VIPCustomCourseListFragment();
|
|
@@ -40,16 +61,67 @@ public class VIPCustomCourseListFragment extends BaseMVPFragment<FgVipCustomCour
|
|
|
|
|
|
@Override
|
|
|
protected void initView(View rootView) {
|
|
|
-
|
|
|
}
|
|
|
|
|
|
@Override
|
|
|
protected void initData() {
|
|
|
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(){
|
|
|
+ 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) {
|
|
|
+ VIPCustomCourseListFragment.this.isRecentFreeTime = isRecentFreeTime;
|
|
|
+ VIPCustomCourseListFragment.this.sortField = sortField;
|
|
|
+ VIPCustomCourseListFragment.this.sortRule = sortRule;
|
|
|
+ currentPage = 1;
|
|
|
+ getData(false);
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
}
|
|
|
|
|
|
@Override
|
|
@@ -66,24 +138,29 @@ public class VIPCustomCourseListFragment extends BaseMVPFragment<FgVipCustomCour
|
|
|
@Override
|
|
|
public void onClick(View v) {
|
|
|
int id = v.getId();
|
|
|
- if(id == R.id.tv_filter){
|
|
|
+ if (id == R.id.tv_filter) {
|
|
|
selectSubjectType();
|
|
|
return;
|
|
|
}
|
|
|
+ if (id == R.id.tv_search) {
|
|
|
+ searchCondition = mViewBinding.etTargetName.getText().toString().trim();
|
|
|
+ getData(false);
|
|
|
+ return;
|
|
|
+ }
|
|
|
}
|
|
|
|
|
|
private void selectSubjectType() {
|
|
|
- if (subjectList.size() <= 0) {
|
|
|
+ if (subjectList.size() == 0) {
|
|
|
return;
|
|
|
}
|
|
|
- if(pvOptions == null){
|
|
|
+ if (pvOptions == null) {
|
|
|
pvOptions = new OptionsPickerBuilder(getContext(), (options1, options2, options3, v) -> {
|
|
|
this.currentSelectSubjectPosition = options1;
|
|
|
QuerySubjectBean subjectBean = subjectList.get(options1);
|
|
|
this.currentSubjectId = subjectBean.getId();
|
|
|
mViewBinding.tvFilter.setText(subjectBean.getPickerViewText());
|
|
|
currentPage = 1;
|
|
|
- getData(true);
|
|
|
+ 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);
|
|
@@ -118,6 +195,59 @@ public class VIPCustomCourseListFragment extends BaseMVPFragment<FgVipCustomCour
|
|
|
}
|
|
|
|
|
|
private void getData(boolean isShowLoading) {
|
|
|
+ presenter.queryCourseTeachers(isShowLoading, currentSubjectId, sortField, sortRule, searchCondition, isRecentFreeTime, currentPage);
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onGetTeacherListSuccess(int page, AppointCourseTeacherListBean dataList) {
|
|
|
+ if (isDetached()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ LOG.i("pq", "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;
|
|
|
+ }
|
|
|
+
|
|
|
+ @Override
|
|
|
+ public void onGetTeacherListError(int page) {
|
|
|
+ if (isDetached()) {
|
|
|
+ return;
|
|
|
+ }
|
|
|
+ if (page == 1) {
|
|
|
+ mViewBinding.refreshLayout.finishRefresh();
|
|
|
+ } else {
|
|
|
+ if (mAdapter != null) {
|
|
|
+ currentPage--;
|
|
|
+ mViewBinding.refreshLayout.finishLoadMore(false);
|
|
|
+ }
|
|
|
+ }
|
|
|
}
|
|
|
}
|