|
@@ -1,5 +1,6 @@
|
|
|
package com.cooleshow.teacher.ui.main
|
|
|
|
|
|
+import android.text.SpannableString
|
|
|
import android.text.TextUtils
|
|
|
import android.util.Log
|
|
|
import android.view.View
|
|
@@ -10,9 +11,11 @@ import com.cooleshow.base.router.RouterPath
|
|
|
import com.cooleshow.base.ui.fragment.BaseMVPFragment
|
|
|
import com.cooleshow.base.utils.GlideUtils.loadImage
|
|
|
import com.cooleshow.base.utils.TimeUtils
|
|
|
+import com.cooleshow.base.utils.UiUtils
|
|
|
import com.cooleshow.base.utils.Utils
|
|
|
import com.cooleshow.teacher.R
|
|
|
import com.cooleshow.teacher.bean.*
|
|
|
+import com.cooleshow.teacher.constants.CourseConstants
|
|
|
import com.cooleshow.teacher.constants.TeacherInfoConstants
|
|
|
import com.cooleshow.teacher.contract.HomeContract
|
|
|
import com.cooleshow.teacher.databinding.FragmentHomeLayoutBinding
|
|
@@ -211,17 +214,94 @@ class HomeFragment : BaseMVPFragment<FragmentHomeLayoutBinding, HomePresenter>()
|
|
|
|
|
|
override fun getHomeCountSuccess(data: HomeCountBean?) {
|
|
|
if (data != null) {
|
|
|
- mViewBinding.tvMineCourseCount.text = "本周剩余\n" + data.courseSchedule + "课时"
|
|
|
- mViewBinding.tvAfterClassHomeworkCount.text = "本周共" + data.courseHomework + "节课\n未布置作业"
|
|
|
- mViewBinding.tvAfterClassAssessCount.text =
|
|
|
- "剩余" + data.courseScheduleReplied + "节\n尚未评价"
|
|
|
- mViewBinding.tvMineMusicSheetCount.text = "共" + data.musicSheet + "支\n乐谱"
|
|
|
- mViewBinding.tvMineAssessCount.text = "本周收到\n" + data.studentReplied + "个评价"
|
|
|
- mViewBinding.tvMineIncomeCount.text = "本月收入\n" + data.decimal + "元"
|
|
|
- mViewBinding.tvMineKotofusaCount.text = "剩余\n" + data.pianoTime + "分钟"
|
|
|
+ if (data.courseSchedule == 0) {
|
|
|
+ mViewBinding.tvMineCourseCount.text = "本周剩余\n0 课时"
|
|
|
+ } else {
|
|
|
+ mViewBinding.tvMineCourseCount.text =
|
|
|
+ getRoomAuthorTextStyleSpan(
|
|
|
+ "本周剩余\n",
|
|
|
+ data.courseSchedule.toString() + " ",
|
|
|
+ "课时"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (data.courseHomework == 0) {
|
|
|
+ mViewBinding.tvAfterClassHomeworkCount.text = "本周共 0 节课\n未布置作业"
|
|
|
+ } else {
|
|
|
+ mViewBinding.tvAfterClassHomeworkCount.text =
|
|
|
+ getRoomAuthorTextStyleSpan(
|
|
|
+ "本周共",
|
|
|
+ " " + data.courseHomework + " ",
|
|
|
+ "节课\n未布置作业"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (data.courseScheduleReplied == 0) {
|
|
|
+ mViewBinding.tvAfterClassAssessCount.text = "剩余 0 节\n尚未评价"
|
|
|
+ } else {
|
|
|
+ mViewBinding.tvAfterClassAssessCount.text =
|
|
|
+ getRoomAuthorTextStyleSpan(
|
|
|
+ "剩余",
|
|
|
+ " " + data.courseScheduleReplied + " ",
|
|
|
+ "节\n尚未评价"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (data.musicSheet == 0) {
|
|
|
+ mViewBinding.tvMineMusicSheetCount.text = "共 0 支\n乐谱"
|
|
|
+ } else {
|
|
|
+ mViewBinding.tvMineMusicSheetCount.text =
|
|
|
+ getRoomAuthorTextStyleSpan(
|
|
|
+ "共",
|
|
|
+ " " + data.musicSheet + " ",
|
|
|
+ "支\n乐谱"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (data.studentReplied == 0) {
|
|
|
+ mViewBinding.tvMineAssessCount.text = "本周收到\n0 个评价"
|
|
|
+ } else {
|
|
|
+ mViewBinding.tvMineAssessCount.text =
|
|
|
+ getRoomAuthorTextStyleSpan(
|
|
|
+ "本周收到\n",
|
|
|
+ data.studentReplied.toString() + " ",
|
|
|
+ "个评价"
|
|
|
+ )
|
|
|
+
|
|
|
+ }
|
|
|
+ if (data.decimal == 0.00) {
|
|
|
+ mViewBinding.tvMineIncomeCount.text = "本月收入\n0.00 元"
|
|
|
+ } else {
|
|
|
+ mViewBinding.tvMineIncomeCount.text =
|
|
|
+ getRoomAuthorTextStyleSpan(
|
|
|
+ "本月收入\n",
|
|
|
+ data.decimal.toString() + " ",
|
|
|
+ "元"
|
|
|
+ )
|
|
|
+ }
|
|
|
+ if (data.pianoTime == 0) {
|
|
|
+ mViewBinding.tvMineKotofusaCount.text = "剩余\n0 分钟"
|
|
|
+ } else {
|
|
|
+ mViewBinding.tvMineKotofusaCount.text =
|
|
|
+ getRoomAuthorTextStyleSpan(
|
|
|
+ "剩余\n",
|
|
|
+ data.pianoTime.toString() + " ",
|
|
|
+ "分钟"
|
|
|
+ )
|
|
|
+ }
|
|
|
}
|
|
|
}
|
|
|
|
|
|
+ private fun getRoomAuthorTextStyleSpan(
|
|
|
+ firstText: String,
|
|
|
+ contentText: String,
|
|
|
+ lastText: String
|
|
|
+ ): SpannableString? {
|
|
|
+ return UiUtils.diffColorString(
|
|
|
+ firstText,
|
|
|
+ contentText,
|
|
|
+ lastText,
|
|
|
+ resources.getColor(com.cooleshow.base.R.color.color_999999),
|
|
|
+ resources.getColor(R.color.color_ff5160)
|
|
|
+ )
|
|
|
+ }
|
|
|
+
|
|
|
private var noticeId: Long = 0
|
|
|
override fun helpCenterContentListSuccess(data: HelpCenterContentBean?) {
|
|
|
|
|
@@ -251,25 +331,52 @@ class HomeFragment : BaseMVPFragment<FragmentHomeLayoutBinding, HomePresenter>()
|
|
|
override fun queryLiveAndVideoSuccess(bean: HomeLiveAndVideoBean?) {
|
|
|
val recentCourses = bean?.recentCourses
|
|
|
mViewBinding.clLive.setVisible(recentCourses != null)
|
|
|
- if(recentCourses != null){
|
|
|
+ if (recentCourses != null) {
|
|
|
mViewBinding.tvLiveTitle.setText(recentCourses.courseGroupName)
|
|
|
mViewBinding.tvLiveTime.setText(recentCourses.courseStartTime)
|
|
|
val currentTime = TimeUtils.date2String(Date(System.currentTimeMillis()), "yyyy-MM-dd")
|
|
|
- val startTime = TimeUtils.date2String(TimeUtils.getDate(recentCourses.courseStartTime), "yyyy-MM-dd")
|
|
|
+ val startTime = TimeUtils.date2String(
|
|
|
+ TimeUtils.getDate(recentCourses.courseStartTime),
|
|
|
+ "yyyy-MM-dd"
|
|
|
+ )
|
|
|
if (TextUtils.equals(currentTime, startTime)) {
|
|
|
- val timeText = TimeUtils.date2String(TimeUtils.getDate(recentCourses.courseStartTime), "HH:mm")
|
|
|
+ val timeText =
|
|
|
+ TimeUtils.date2String(TimeUtils.getDate(recentCourses.courseStartTime), "HH:mm")
|
|
|
mViewBinding.tvLiveTime.text = "今日 $timeText"
|
|
|
} else {
|
|
|
- mViewBinding.tvLiveTime.text = TimeUtils.date2String(TimeUtils.getDate(recentCourses.courseStartTime), "yyyy-MM-dd HH:mm")
|
|
|
+ mViewBinding.tvLiveTime.text = TimeUtils.date2String(
|
|
|
+ TimeUtils.getDate(recentCourses.courseStartTime),
|
|
|
+ "yyyy-MM-dd HH:mm"
|
|
|
+ )
|
|
|
}
|
|
|
mViewBinding.tvGoLive.setOnClickListener { v ->
|
|
|
- //进入直播
|
|
|
+ gotoCourseDetail(recentCourses)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+
|
|
|
+ /**
|
|
|
+ * 跳转直播课详情页面
|
|
|
+ *
|
|
|
+ * @param bean
|
|
|
+ */
|
|
|
+ private fun gotoCourseDetail(bean: HomeLiveAndVideoBean.RecentCoursesBean?) {
|
|
|
+ when (bean?.courseType) {
|
|
|
+ CourseConstants.LIVE_COURSE -> ARouter.getInstance()
|
|
|
+ .build(RouterPath.WebCenter.ACTIVITY_HTML)
|
|
|
+ .withString(WebConstants.WEB_URL, WebConstants.TEACHER_LIVE_DETAIL + "?groupId=" + bean.courseGroupId)
|
|
|
+ .navigation()
|
|
|
+ CourseConstants.OTHER_COURSE -> //陪练课
|
|
|
ARouter.getInstance().build(RouterPath.CourseCenter.SPARRING_COURSE_DETAIL)
|
|
|
- .withString(SparringCourseDetailActivity.COURSE_ID, recentCourses.courseId.toString())
|
|
|
- .withString(SparringCourseDetailActivity.COURSE_GROUP_ID, recentCourses.courseGroupId.toString())
|
|
|
- .withString(SparringCourseDetailActivity.STUDENT_ID, UserHelper.getUserId())
|
|
|
+ .withString(CourseConstants.COURSE_ID, bean.courseId.toString())
|
|
|
+ .withString(CourseConstants.COURSE_GROUP_ID, bean.courseGroupId.toString())
|
|
|
+ .withString(CourseConstants.STUDENT_ID,bean.studentId.toString())
|
|
|
+ .navigation()
|
|
|
+ CourseConstants.PIANO_ROOM_COURSE ->
|
|
|
+ //琴房课 跳转详情页
|
|
|
+ ARouter.getInstance().build(RouterPath.CourseCenter.PIANO_ROOM_COURSE_DETAIL)
|
|
|
+ .withString(CourseConstants.COURSE_ID, bean.courseId.toString())
|
|
|
.navigation()
|
|
|
- }
|
|
|
}
|
|
|
}
|
|
|
|