|
@@ -9,9 +9,11 @@ import com.chad.library.adapter.base.BaseQuickAdapter
|
|
|
import com.chad.library.adapter.base.viewholder.BaseViewHolder
|
|
|
import com.cooleshow.base.ext.setVisible
|
|
|
import com.cooleshow.base.utils.GlideUtils
|
|
|
+import com.cooleshow.base.utils.TimeUtils
|
|
|
import com.cooleshow.base.utils.UiUtils
|
|
|
import com.cooleshow.teacher.R
|
|
|
import com.cooleshow.teacher.bean.CourseTableDataBean
|
|
|
+import kotlin.math.abs
|
|
|
|
|
|
/**
|
|
|
* Author by pq, Date on 2022/4/21.
|
|
@@ -28,6 +30,8 @@ class CourseTableListAdapter(layoutResId: Int) :
|
|
|
const val CANCEL = "CANCEL"
|
|
|
}
|
|
|
|
|
|
+ var configBean: CourseTableDataBean.SysConfigBean? = null;
|
|
|
+
|
|
|
init {
|
|
|
addChildClickViewIds(R.id.tv_course_status_bt)
|
|
|
addChildClickViewIds(R.id.iv_go_chat)
|
|
@@ -44,7 +48,7 @@ class CourseTableListAdapter(layoutResId: Int) :
|
|
|
val tvBuyNum = baseViewHolder.getView<TextView>(R.id.tv_buy_num)
|
|
|
val tvCourseStatusBt = baseViewHolder.getView<TextView>(R.id.tv_course_status_bt)
|
|
|
//开始时间
|
|
|
- tvTime.text = UiUtils.getCourseTimeString(data?.startTime,data?.endTime);
|
|
|
+ tvTime.text = UiUtils.getCourseTimeString(data?.startTime, data?.endTime);
|
|
|
//title
|
|
|
baseViewHolder.setText(R.id.tv_title, data?.name);
|
|
|
//subjectName
|
|
@@ -77,28 +81,39 @@ class CourseTableListAdapter(layoutResId: Int) :
|
|
|
when (data?.status) {
|
|
|
NOT_START -> {
|
|
|
//未开始
|
|
|
- if (TextUtils.equals(OTHER_COURSE, data?.courseType)) {
|
|
|
+ if (isCanShowEnterBt(data)) {
|
|
|
tvCourseStatusBt.setVisible(true)
|
|
|
+ tvCourseStatusBt.text = "进入教室"
|
|
|
+ tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_ing);
|
|
|
+ tvCourseStatusBt.setTextColor(context.resources.getColor(R.color.white))
|
|
|
} else {
|
|
|
//直播课隐藏
|
|
|
tvCourseStatusBt.setVisible(false)
|
|
|
}
|
|
|
baseViewHolder.setText(R.id.tv_course_status, "未开始")
|
|
|
- baseViewHolder.setTextColor(R.id.tv_course_status, context.resources.getColor(com.cooleshow.base.R.color.color_ff802c))
|
|
|
+ baseViewHolder.setTextColor(
|
|
|
+ R.id.tv_course_status,
|
|
|
+ context.resources.getColor(com.cooleshow.base.R.color.color_ff802c)
|
|
|
+ )
|
|
|
tvCourseStatusBt.text = "调课"
|
|
|
tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_normal);
|
|
|
tvCourseStatusBt.setTextColor(context.resources.getColor(com.cooleshow.base.R.color.color_2dc7aa))
|
|
|
}
|
|
|
+
|
|
|
ING -> {
|
|
|
//进行中
|
|
|
tvCourseStatusBt.setVisible(true)
|
|
|
tvCourseStatusBt.text = "进入教室"
|
|
|
baseViewHolder.setText(R.id.tv_course_status, "进行中")
|
|
|
- baseViewHolder.setTextColor(R.id.tv_course_status, context.resources.getColor(com.cooleshow.base.R.color.color_2dc7aa))
|
|
|
+ baseViewHolder.setTextColor(
|
|
|
+ R.id.tv_course_status,
|
|
|
+ context.resources.getColor(com.cooleshow.base.R.color.color_2dc7aa)
|
|
|
+ )
|
|
|
tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_ing);
|
|
|
tvCourseStatusBt.setTextColor(context.resources.getColor(R.color.white))
|
|
|
|
|
|
}
|
|
|
+
|
|
|
COMPLETE -> {
|
|
|
//已完成
|
|
|
if (TextUtils.equals(OTHER_COURSE, data?.courseType)) {
|
|
@@ -113,10 +128,51 @@ class CourseTableListAdapter(layoutResId: Int) :
|
|
|
tvCourseStatusBt.text = "已评价"
|
|
|
}
|
|
|
baseViewHolder.setText(R.id.tv_course_status, "已结束")
|
|
|
- baseViewHolder.setTextColor(R.id.tv_course_status, context.resources.getColor(com.cooleshow.base.R.color.color_999999))
|
|
|
+ baseViewHolder.setTextColor(
|
|
|
+ R.id.tv_course_status,
|
|
|
+ context.resources.getColor(com.cooleshow.base.R.color.color_999999)
|
|
|
+ )
|
|
|
tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_normal);
|
|
|
tvCourseStatusBt.setTextColor(context.resources.getColor(com.cooleshow.base.R.color.color_2dc7aa))
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
+
|
|
|
+ private fun isCanShowEnterBt(data: CourseTableDataBean.StudentListBean): Boolean {
|
|
|
+ if (configBean == null) {
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+ when (data.courseType) {
|
|
|
+ OTHER_COURSE -> {
|
|
|
+ return isLessThanTargetTime(configBean!!.practiceStartTime, data.startTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ LIVE_COURSE -> {
|
|
|
+ return isLessThanTargetTime(configBean!!.liveStartTime, data.startTime);
|
|
|
+ }
|
|
|
+
|
|
|
+ PIANO_ROOM_COURSE -> {
|
|
|
+ return isLessThanTargetTime(configBean!!.pianoStartTime, data.startTime);
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ private fun isLessThanTargetTime(targetMinutes: String, startTime: String): Boolean {
|
|
|
+ try {
|
|
|
+ var time = TimeUtils.string2Date(startTime).time;
|
|
|
+ var cTime = System.currentTimeMillis();
|
|
|
+ var limitMinutes = targetMinutes.toLong()
|
|
|
+ if (abs(time - cTime) < limitMinutes * 60 * 1000) {
|
|
|
+ return true;
|
|
|
+ }
|
|
|
+ } catch (e: Exception) {
|
|
|
+ e.printStackTrace()
|
|
|
+ }
|
|
|
+ return false;
|
|
|
+ }
|
|
|
+
|
|
|
+ fun setConfigData(sysConfig: CourseTableDataBean.SysConfigBean?) {
|
|
|
+ this.configBean = sysConfig;
|
|
|
+ }
|
|
|
}
|