|
@@ -13,6 +13,7 @@ import com.cooleshow.base.utils.TimeUtils
|
|
|
import com.cooleshow.base.utils.UiUtils
|
|
|
import com.cooleshow.teacher.R
|
|
|
import com.cooleshow.teacher.bean.CourseTableDataBean
|
|
|
+import com.cooleshow.teacher.helper.CourseHelper
|
|
|
import kotlin.math.abs
|
|
|
|
|
|
/**
|
|
@@ -104,7 +105,7 @@ class CourseTableListAdapter(layoutResId: Int) :
|
|
|
R.id.tv_course_status,
|
|
|
context.resources.getColor(com.cooleshow.base.R.color.color_ff802c)
|
|
|
)
|
|
|
- if (isCanShowEnterBt(data)) {
|
|
|
+ if (CourseHelper.isCanShowEnterBt(configBean,data.courseType,data.startTime)) {
|
|
|
tvCourseStatusBt.setVisible(true)
|
|
|
tvCourseStatusBt.text = "进入教室"
|
|
|
tvCourseStatusBt.setBackgroundResource(R.drawable.shape_course_status_ing);
|
|
@@ -164,44 +165,6 @@ class CourseTableListAdapter(layoutResId: Int) :
|
|
|
}
|
|
|
}
|
|
|
|
|
|
- private fun isCanShowEnterBt(data: CourseTableDataBean.StudentListBean): Boolean {
|
|
|
- if (configBean == null) {
|
|
|
- return false;
|
|
|
- }
|
|
|
- when (data.courseType) {
|
|
|
- VIP_COURSE -> {
|
|
|
- return isLessThanTargetTime(configBean!!.vipStartTime, data.startTime);
|
|
|
- }
|
|
|
-
|
|
|
- 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;
|
|
|
}
|