Pq 3 лет назад
Родитель
Сommit
3e087a3ba7

+ 18 - 5
BaseLibrary/src/main/java/com/cooleshow/base/utils/TimeUtils.java

@@ -40,9 +40,11 @@ public final class TimeUtils {
     private static SimpleDateFormat getDefaultFormat() {
         return getSafeDateFormat("yyyy-MM-dd HH:mm:ss");
     }
+
     /**
      * Checks whether the device is using Network Provided Time or not.
-     *  Useful in situations where you want to verify that the device has a correct time set, to avoid fraud, or if you want to prevent the user from messing with the time and abusing your "one-time" and "expiring" features. 
+     * Useful in situations where you want to verify that the device has a correct time set, to avoid fraud, or if you want to prevent the user from messing with the time and abusing your "one-time" and "expiring" features.
+     *
      * @return {@code true}: yes<br>{@code false}: no
      */
     public static boolean isUsingNetworkProvidedTime() {
@@ -52,7 +54,7 @@ public final class TimeUtils {
             return android.provider.Settings.System.getInt(Utils.getApp().getContentResolver(), android.provider.Settings.System.AUTO_TIME, 0) == 1;
         }
     }
-    
+
 
     @SuppressLint("SimpleDateFormat")
     public static SimpleDateFormat getSafeDateFormat(String pattern) {
@@ -977,6 +979,17 @@ public final class TimeUtils {
         return getDate(time, getDefaultFormat(), timeSpan, unit);
     }
 
+
+    public static Date getDate(String time) {
+        try {
+            Date parse = getDefaultFormat().parse(time);
+            return parse;
+        } catch (ParseException e) {
+            e.printStackTrace();
+        }
+        return getNowDate();
+    }
+
     /**
      * Return the date differ time span.
      *
@@ -1539,8 +1552,8 @@ public final class TimeUtils {
         return CHINESE_ZODIAC[year % 12];
     }
 
-    private static final int[]    ZODIAC_FLAGS = {20, 19, 21, 21, 21, 22, 23, 23, 23, 24, 23, 22};
-    private static final String[] ZODIAC       = {
+    private static final int[] ZODIAC_FLAGS = {20, 19, 21, 21, 21, 22, 23, 23, 23, 24, 23, 22};
+    private static final String[] ZODIAC = {
             "水瓶座", "双鱼座", "白羊座", "金牛座", "双子座", "巨蟹座",
             "狮子座", "处女座", "天秤座", "天蝎座", "射手座", "摩羯座"
     };
@@ -1635,7 +1648,7 @@ public final class TimeUtils {
 
     public static Date stringToDate(String strTime)
             throws ParseException {
-        SimpleDateFormat formatter=getSafeDateFormat("yyyy-MM-dd");
+        SimpleDateFormat formatter = getSafeDateFormat("yyyy-MM-dd");
         Date date = null;
         date = formatter.parse(strTime);
         return date;

+ 15 - 7
teacher/src/main/java/com/cooleshow/teacher/adapter/CourseTableListAdapter.kt

@@ -16,12 +16,15 @@ import com.cooleshow.teacher.bean.CourseTableDataBean
  */
 class CourseTableListAdapter(layoutResId: Int) :
     BaseQuickAdapter<CourseTableDataBean.StudentListBean?, BaseViewHolder>(layoutResId) {
-    val LIVE_COURSE = "LIVE_COURSE"
-    val OTHER_COURSE = "PRACTICE"
-    val NOT_START = "NOT_START"
-    val ING = "ING"
-    val COMPLETE = "COMPLETE"
-    val CANCEL = "CANCEL"
+    companion object {
+        const val LIVE_COURSE = "LIVE_COURSE"
+        const val OTHER_COURSE = "PRACTICE"
+        const val NOT_START = "NOT_START"
+        const val ING = "ING"
+        const val COMPLETE = "COMPLETE"
+        const val CANCEL = "CANCEL"
+    }
+
     override fun convert(
         baseViewHolder: BaseViewHolder,
         data: CourseTableDataBean.StudentListBean?
@@ -81,7 +84,12 @@ class CourseTableListAdapter(layoutResId: Int) :
             }
             COMPLETE -> {
                 //已完成
-                tvCourseStatusBt.setVisible(true)
+                if (TextUtils.equals(OTHER_COURSE, data?.courseType)) {
+                    tvCourseStatusBt.setVisible(true)
+                } else {
+                    //直播课隐藏
+                    tvCourseStatusBt.setVisible(false)
+                }
                 tvCourseStatusBt.text = "评价"
                 baseViewHolder.setText(R.id.tv_course_status, "已结束")
                 tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_normal);

+ 12 - 3
teacher/src/main/java/com/cooleshow/teacher/api/APIService.java

@@ -84,6 +84,16 @@ public interface APIService {
     Observable<BaseResponse<CourseTableDataBean>> getCourseSchedulesWithDate(@Body RequestBody body);
 
     /**
+     * 调课(陪练课调整时间)
+     *
+     * @param
+     * @return
+     */
+    @POST(TEACHER_GROUP + "courseSchedule/courseAdjust")
+    Observable<BaseResponse<Object>> updateCourseDate(@Body RequestBody body);
+
+
+    /**
      * 查询陪练课
      *
      * @param
@@ -99,8 +109,8 @@ public interface APIService {
      * @param
      * @return
      */
-    @GET(TEACHER_GROUP + "homework/detail/{courseId}")
-    Observable<BaseResponse<SparringCourseHomeworkBean>> getSparringCourseHomework(@Path("courseId") String courseId);
+    @GET(TEACHER_GROUP + "homework/detail/{courseId}/{studentId}")
+    Observable<BaseResponse<SparringCourseHomeworkBean>> getSparringCourseHomework(@Path("courseId") String courseId, @Path("studentId") String studentId);
 
 
     /**
@@ -523,7 +533,6 @@ public interface APIService {
     Observable<BaseResponse<HelpCenterContentBean>> helpCenterContentList(@Body RequestBody body);
 
     /**
-     *
      * @param body
      * @return
      */

+ 2 - 2
teacher/src/main/java/com/cooleshow/teacher/bean/CourseTableDataBean.java

@@ -52,11 +52,11 @@ public class CourseTableDataBean {
         public String startTime;
         public String userId;
         public int subjectId;
-        public int courseGoupId;
+        public String courseGoupId;
         public String avatar;
         public String courseType;
         public String subjectName;
-        public int courseId;
+        public String courseId;
         public String classDate;
         public String cover;
         public String payCount;

+ 4 - 0
teacher/src/main/java/com/cooleshow/teacher/contract/CourseTableContract.java

@@ -17,11 +17,15 @@ public interface CourseTableContract {
         void onGetCourseSchedulesWithDateSuccess(CourseTableDataBean courseTableDataBean);
 
         void onGetCourseDateByMonthError();
+
+        void onUpDateCourseDataSuccess();
     }
 
     interface Presenter {
         void getCourseScheduleDateByMonth(String month);
 
         void getCourseSchedulesWithDate(Date date);
+
+        void updateCourseTime(Date date, String courseId);
     }
 }

+ 1 - 1
teacher/src/main/java/com/cooleshow/teacher/contract/SparringCourseDetailContract.java

@@ -25,7 +25,7 @@ public interface SparringCourseDetailContract {
     }
 
     interface Presenter {
-        void getSparringCourseHomework(String courseId);
+        void getSparringCourseHomework(String courseId,String studentId);
 
         void getSparringCourseComment(String courseScheduleId, String courseGroupId, String studentId);
 

+ 2 - 2
teacher/src/main/java/com/cooleshow/teacher/presenter/course/SparringCourseDetailPresenter.java

@@ -18,11 +18,11 @@ import org.json.JSONObject;
 public class SparringCourseDetailPresenter extends BasePresenter<SparringCourseDetailContract.SparringCourseDetailView> implements SparringCourseDetailContract.Presenter {
 
     @Override
-    public void getSparringCourseHomework(String courseId) {
+    public void getSparringCourseHomework(String courseId,String studentId) {
         if (getView() != null) {
             getView().showLoading();
         }
-        addSubscribe(create(APIService.class).getSparringCourseHomework(courseId), new BaseObserver<SparringCourseHomeworkBean>(getView()) {
+        addSubscribe(create(APIService.class).getSparringCourseHomework(courseId,studentId), new BaseObserver<SparringCourseHomeworkBean>(getView()) {
             @Override
             protected void onSuccess(SparringCourseHomeworkBean data) {
                 if (getView() != null) {

+ 29 - 0
teacher/src/main/java/com/cooleshow/teacher/presenter/main/CourseTablePresenter.java

@@ -80,4 +80,33 @@ public class CourseTablePresenter extends BasePresenter<CourseTableContract.Cour
             }
         });
     }
+
+    /**
+     * 调课
+     *
+     * @param date
+     * @param courseId
+     */
+    @Override
+    public void updateCourseTime(Date date, String courseId) {
+        if (getView() != null) {
+            getView().showLoading();
+        }
+        JSONObject jsonObject = new JSONObject();
+        try {
+            jsonObject.putOpt("classDate", TimeUtils.date2String(date, TimeUtils.getSafeDateFormat("yyyy-MM-dd")));
+            jsonObject.putOpt("courseId", courseId);
+            jsonObject.putOpt("startTime", TimeUtils.date2String(date));
+        } catch (JSONException e) {
+            e.printStackTrace();
+        }
+        addSubscribe(create(APIService.class).updateCourseDate(RequestBodyUtil.convertToRequestBodyJson(jsonObject.toString())), new BaseObserver<Object>(getView()) {
+            @Override
+            protected void onSuccess(Object data) {
+                if (getView() != null) {
+                    getView().onUpDateCourseDataSuccess();
+                }
+            }
+        });
+    }
 }

+ 5 - 5
teacher/src/main/java/com/cooleshow/teacher/ui/course/SparringCourseDetailActivity.java

@@ -66,7 +66,7 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
 
     private void refresh() {
         if (presenter != null) {
-            presenter.getSparringCourseHomework(mCourseId);
+            presenter.getSparringCourseHomework(mCourseId, studentId);
             presenter.getSparringCourseComment(mCourseId, mCourseGroupId, studentId);
         }
     }
@@ -275,19 +275,19 @@ public class SparringCourseDetailActivity extends BaseMVPActivity<ActivitySparri
             mSetCommentDialog = new CourseSetCommentDialog(this);
             mSetCommentDialog.setOnSubmitClickListener(new CourseSetCommentDialog.OnSubmitClickListener() {
                 @Override
-                public void onSubmit(String content,int type) {
+                public void onSubmit(String content, int type) {
                     //提交
                     if (type == CourseSetCommentDialog.TYPE_SET_TEACHER_COMMENT) {
                         //提交老师点评
-                        presenter.submitSparringCourseComment(content,mCourseId,mCourseGroupId,studentId);
+                        presenter.submitSparringCourseComment(content, mCourseId, mCourseGroupId, studentId);
                     }
                     if (type == CourseSetCommentDialog.TYPE_SET_HOMEWORK) {
                         //提交布置作业
-                        presenter.submitSparringCourseHomework(content,mCourseId);
+                        presenter.submitSparringCourseHomework(content, mCourseId);
                     }
                     if (type == CourseSetCommentDialog.TYPE_SET_HOMEWORK_COMMENT) {
                         //提交作业点评
-                        presenter.submitSparringCourseHomeworkComment(content,mCourseId);
+                        presenter.submitSparringCourseHomeworkComment(content, mCourseId);
                     }
                 }
             });

+ 92 - 4
teacher/src/main/java/com/cooleshow/teacher/ui/main/CourseTableFragment.kt

@@ -1,5 +1,6 @@
 package com.cooleshow.teacher.ui.main
 
+import android.text.TextUtils
 import android.view.LayoutInflater
 import android.view.MotionEvent
 import android.view.View
@@ -7,11 +8,14 @@ import android.widget.ImageView
 import android.widget.TextView
 import androidx.recyclerview.widget.LinearLayoutManager
 import androidx.recyclerview.widget.RecyclerView
+import com.alibaba.android.arouter.launcher.ARouter
 import com.bigkoo.pickerview.builder.TimePickerBuilder
 import com.bigkoo.pickerview.listener.CustomListener
 import com.bigkoo.pickerview.listener.OnTimeSelectListener
 import com.bigkoo.pickerview.view.TimePickerView
 import com.chad.library.adapter.base.listener.OnItemClickListener
+import com.cooleshow.base.common.WebConstants
+import com.cooleshow.base.router.RouterPath
 import com.cooleshow.base.ui.fragment.BaseMVPFragment
 import com.cooleshow.base.utils.SizeUtils
 import com.cooleshow.base.utils.TimeUtils
@@ -23,6 +27,8 @@ import com.cooleshow.teacher.bean.CourseTableDataBean
 import com.cooleshow.teacher.contract.CourseTableContract
 import com.cooleshow.teacher.databinding.FragmentCourseTableLayoutBinding
 import com.cooleshow.teacher.presenter.main.CourseTablePresenter
+import com.cooleshow.teacher.ui.comment.CourseCommentDetailActivity
+import com.cooleshow.teacher.ui.course.SparringCourseDetailActivity
 import com.cooleshow.teacher.widgets.CalendarExpandDecoration
 import com.cooleshow.teacher.widgets.CalendarShrinkDecoration
 import com.haibin.calendarview.CalendarView
@@ -44,6 +50,7 @@ class CourseTableFragment :
     private lateinit var calendarShrinkDecoration: CalendarShrinkDecoration
     private lateinit var adapter: CourseTableListAdapter
     private lateinit var pvTime: TimePickerView
+    private lateinit var pvCourseTime: TimePickerView
     private lateinit var emptyView: EmptyViewLayout
     private lateinit var emptyText: TextView
     private lateinit var emptyIcon: ImageView
@@ -97,11 +104,47 @@ class CourseTableFragment :
             }
         })
         adapter.setOnItemClickListener(OnItemClickListener() { adapter, view, position ->
+            var data: CourseTableDataBean.StudentListBean =
+                adapter.data[position] as CourseTableDataBean.StudentListBean;
+            if (TextUtils.equals(CourseTableListAdapter.OTHER_COURSE, data?.courseType)) {
+                //陪练课
+                when (data?.status) {
+                    CourseTableListAdapter.NOT_START -> {
+                        //调课(调整时间)
+                        var targetDate: Date = TimeUtils.getDate(data.startTime)
+                        showCourseTimeSelectView(targetDate, data.courseId);
+                    }
+                    CourseTableListAdapter.ING -> {
+                        //进行中的
+                    }
+                    CourseTableListAdapter.COMPLETE -> {
+                        //评价
+                        ARouter.getInstance()
+                            .build(RouterPath.CommentCenter.TEACHER_COURSE_COMMENT_DETAIL)
+                            .withString(CourseCommentDetailActivity.COURSE_ID, data.courseId)
+                            .withString(
+                                CourseCommentDetailActivity.COURSE_GROUP_ID,
+                                data.courseGoupId
+                            )
+                            .withString(CourseCommentDetailActivity.STUDENT_ID, data.userId)
+                            .navigation()
+                    }
+                }
+            } else {
+                //直播课
+                ARouter.getInstance()
+                    .build(RouterPath.WebCenter.ACTIVITY_HTML)
+                    .withString(
+                        WebConstants.WEB_URL,
+                        WebConstants.TEACHER_LIVE_DETAIL + "?groupId=" + data.courseGoupId
+                    )
+                    .navigation()
+            }
         })
         mViewBinding.refreshLayout.setOnRefreshListener {
             queryCurrentDataCourse()
         }
-        mViewBinding.refreshLayout.isEnabled=false
+        mViewBinding.refreshLayout.isEnabled = false
     }
 
     override fun initData() {
@@ -145,6 +188,7 @@ class CourseTableFragment :
         setMontAndDay(year, month, day)
         queryCurrentDataCourse()
     }
+
     override fun onResume() {
         super.onResume()
         queryCurrentDataCourse()
@@ -178,13 +222,13 @@ class CourseTableFragment :
             recyclerView.removeItemDecoration(calendarExpandDecoration)
             if (recyclerView.itemDecorationCount == 0 || recyclerView.getItemDecorationAt(0) !is CalendarShrinkDecoration) {
                 recyclerView.addItemDecoration(calendarShrinkDecoration, 0)
-                mViewBinding.refreshLayout.isEnabled=false
+                mViewBinding.refreshLayout.isEnabled = false
             }
         } else {
             recyclerView.removeItemDecoration(calendarShrinkDecoration)
             if (recyclerView.itemDecorationCount == 0 || recyclerView.getItemDecorationAt(0) !is CalendarExpandDecoration) {
                 recyclerView.addItemDecoration(calendarExpandDecoration, 0)
-                mViewBinding.refreshLayout.isEnabled=true
+                mViewBinding.refreshLayout.isEnabled = true
             }
         }
     }
@@ -210,10 +254,18 @@ class CourseTableFragment :
             }
         }
     }
+
     override fun onGetCourseDateByMonthError() {
         mViewBinding.refreshLayout.finishRefresh()
     }
 
+    override fun onUpDateCourseDataSuccess() {
+        if (isDetached) {
+            return;
+        }
+        queryCurrentDataCourse();
+    }
+
     /**
      * 查询当天的课程
      */
@@ -249,6 +301,42 @@ class CourseTableFragment :
         }
     }
 
+    private fun showCourseTimeSelectView(targetTime: Date, courseId: String) {
+        //正确设置方式 原因:注意事项有说明
+        if (!::pvCourseTime.isInitialized) {
+            pvCourseTime = TimePickerBuilder(
+                requireContext(),
+                OnTimeSelectListener { date: Date?, v: View? ->  //选中事件回调
+                    presenter.updateCourseTime(date, courseId);
+                }).setLayoutRes(com.cooleshow.base.R.layout.pickerview_default_layout,
+                CustomListener { v -> //自定义布局中的控件初始化及事件处理
+                    val tvSubmit =
+                        v.findViewById<View>(com.cooleshow.base.R.id.tv_finish) as TextView
+                    val ivCancel =
+                        v.findViewById<View>(com.cooleshow.base.R.id.tv_cancel) as TextView
+                    tvSubmit.setOnClickListener {
+                        pvCourseTime.returnData()
+                        pvCourseTime.dismiss()
+                    }
+                    ivCancel.setOnClickListener { pvCourseTime.dismiss() }
+                })
+                .setLineSpacingMultiplier(2.5f)
+                .setType(booleanArrayOf(true, true, true, true, true, true)) // 默认全部显示
+                .isCyclic(true) //是否循环滚动
+                .setOutSideCancelable(true) //点击屏幕,点在控件外部范围时,是否取消显示
+                .setTextColorCenter(resources.getColor(com.cooleshow.base.R.color.color_1a1a1a)) //设置选中项的颜色
+                .isDialog(false) //是否显示为对话框样式
+                .setLabel("年", "月", "日", "时", "分", "秒")
+                .build()
+        }
+        var calendar = Calendar.getInstance();
+        calendar.time = targetTime
+        pvCourseTime.setDate(calendar)
+        if (!pvCourseTime.isShowing) {
+            pvCourseTime.show()
+        }
+    }
+
     /**
      * 显示日期选择view
      */
@@ -282,7 +370,7 @@ class CourseTableFragment :
 //            .setRangDate(null, endDate) //起始终止年月日设定
 //            .setDate(endDate)
                 .isDialog(false) //是否显示为对话框样式
-                .setLabel("年", "月", "日", "", "", "")
+                .setLabel("年", "月", "日", "", "", "")
                 .build()
         }
         var calendar = Calendar.getInstance();