作者 杨谦

...刷新课程

@@ -44,6 +44,7 @@ open class LessonVideo( @@ -44,6 +44,7 @@ open class LessonVideo(
44 open class LessonClazz( 44 open class LessonClazz(
45 var id: Int, 45 var id: Int,
46 var name: String, 46 var name: String,
  47 + var lesson_id: String,
47 var lessonclassdetail: List<LessonClassDetail> 48 var lessonclassdetail: List<LessonClassDetail>
48 ) : Serializable 49 ) : Serializable
49 50
@@ -304,9 +304,9 @@ class CourseDetailActivity @@ -304,9 +304,9 @@ class CourseDetailActivity
304 mViewModel.offLessonDetail(it.mLessonId.toInt()) 304 mViewModel.offLessonDetail(it.mLessonId.toInt())
305 } 305 }
306 } 306 }
307 - if (it.type != TYPE_COURSE_DETAIL_ITEM_OFF && !it.isFinished) {  
308 - showDialogId()  
309 - } 307 +// if (it.type != TYPE_COURSE_DETAIL_ITEM_OFF && !it.isFinished) {
  308 +// showDialogId()
  309 +// }
310 } 310 }
311 }) 311 })
312 } 312 }
@@ -4,10 +4,12 @@ import android.text.TextUtils @@ -4,10 +4,12 @@ import android.text.TextUtils
4 import com.br_technology.securitytrain_master.base.common.ConstantParamKey 4 import com.br_technology.securitytrain_master.base.common.ConstantParamKey
5 import com.br_technology.securitytrain_master.databinding.ActivityVideoDetailBinding 5 import com.br_technology.securitytrain_master.databinding.ActivityVideoDetailBinding
6 import com.br_technology.securitytrain_master.ui.bean.CourseParam 6 import com.br_technology.securitytrain_master.ui.bean.CourseParam
  7 +import com.br_technology.securitytrain_master.ui.view.home.event.VideoClassChange
7 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.VideoDetailViewModel 8 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.VideoDetailViewModel
8 import com.br_technology.securitytrain_master.view.MyVideoPlayer 9 import com.br_technology.securitytrain_master.view.MyVideoPlayer
9 import com.shuyu.gsyvideoplayer.GSYVideoManager 10 import com.shuyu.gsyvideoplayer.GSYVideoManager
10 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity 11 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleActivity
  12 +import org.greenrobot.eventbus.EventBus
11 import java.math.BigDecimal 13 import java.math.BigDecimal
12 14
13 /** 15 /**
@@ -47,6 +49,8 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity @@ -47,6 +49,8 @@ class VideoDetailActivity : BaseLifeCycleActivity<VideoDetailViewModel, Activity
47 } 49 }
48 if (!isPause && isFinish) { 50 if (!isPause && isFinish) {
49 binding.videoPlayer.setCantTouch(true) 51 binding.videoPlayer.setCantTouch(true)
  52 + EventBus.getDefault()
  53 + .post(VideoClassChange(mViewModel.courseParam.value?.mLessonId ?: "", true))
50 } 54 }
51 } 55 }
52 } 56 }
@@ -12,3 +12,5 @@ class StatusTypeEvent(var id: Int, var name: String) @@ -12,3 +12,5 @@ class StatusTypeEvent(var id: Int, var name: String)
12 class TransType(var id: Int) 12 class TransType(var id: Int)
13 13
14 class CheckFace() 14 class CheckFace()
  15 +
  16 +class VideoClassChange(var lessonId: String, var isFinish: Boolean)
@@ -18,8 +18,11 @@ import com.br_technology.securitytrain_master.ui.view.home.activity.course.Locat @@ -18,8 +18,11 @@ import com.br_technology.securitytrain_master.ui.view.home.activity.course.Locat
18 import com.br_technology.securitytrain_master.ui.view.home.activity.course.VideoDetailActivity 18 import com.br_technology.securitytrain_master.ui.view.home.activity.course.VideoDetailActivity
19 import com.br_technology.securitytrain_master.ui.view.home.adapter.CourseDetailListAdapter 19 import com.br_technology.securitytrain_master.ui.view.home.adapter.CourseDetailListAdapter
20 import com.br_technology.securitytrain_master.ui.view.home.adapter.IItemClick 20 import com.br_technology.securitytrain_master.ui.view.home.adapter.IItemClick
  21 +import com.br_technology.securitytrain_master.ui.view.home.event.VideoClassChange
21 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CourseListViewModel 22 import com.br_technology.securitytrain_master.ui.view.home.viewmodel.CourseListViewModel
22 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment 23 import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
  24 +import org.greenrobot.eventbus.EventBus
  25 +import org.greenrobot.eventbus.Subscribe
23 26
24 /** 27 /**
25 * Time: 7/30/2021 16:08 28 * Time: 7/30/2021 16:08
@@ -33,9 +36,35 @@ class CourseListFragment(var courseData: TrainCourseData, var tranClassId: Strin @@ -33,9 +36,35 @@ class CourseListFragment(var courseData: TrainCourseData, var tranClassId: Strin
33 36
34 override fun initData() { 37 override fun initData() {
35 super.initData() 38 super.initData()
  39 + EventBus.getDefault().register(this)
36 transData() 40 transData()
37 } 41 }
38 42
  43 + override fun onDestroyView() {
  44 + EventBus.getDefault().unregister(this)
  45 + super.onDestroyView()
  46 + }
  47 +
  48 + @Subscribe
  49 + fun refreshItem(search: VideoClassChange) {
  50 + if (courseData.getTypeData() == TYPE_COURSE_DETAIL_ITEM_VIDEO) {
  51 + val adapter = binding.recyclerview.adapter
  52 + if (adapter != null) {
  53 + courseData.lessonBean?.apply {
  54 + for ((index, p) in class_list.withIndex()) {
  55 + if (p.lesson_id == search.lessonId) {
  56 + if (p.lessonclassdetail.isNotEmpty()){
  57 + p.lessonclassdetail[0].is_complete = 1
  58 + }
  59 + adapter.notifyItemChanged(index)
  60 + break
  61 + }
  62 + }
  63 + }
  64 + }
  65 + }
  66 + }
  67 +
39 private fun transData() { 68 private fun transData() {
40 val dataList = mutableListOf<TrainCourseDetailItem>() 69 val dataList = mutableListOf<TrainCourseDetailItem>()
41 when (courseData.getTypeData()) { 70 when (courseData.getTypeData()) {
@@ -90,7 +119,10 @@ class CourseListFragment(var courseData: TrainCourseData, var tranClassId: Strin @@ -90,7 +119,10 @@ class CourseListFragment(var courseData: TrainCourseData, var tranClassId: Strin
90 startActivity( 119 startActivity(
91 Intent(activity, VideoDetailActivity::class.java) 120 Intent(activity, VideoDetailActivity::class.java)
92 .putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url) 121 .putExtra(COMMON_URL, item.lessonVideoNormalChild?.video_url)
93 - .putExtra(LESSON_ID, item.lessonVideoNormalChild?.lesson_id?.toInt()) 122 + .putExtra(
  123 + LESSON_ID,
  124 + item.lessonVideoNormalChild?.lesson_id?.toInt()
  125 + )
94 .putExtra( 126 .putExtra(
95 COURSE_BEAN, 127 COURSE_BEAN,
96 (activity as CourseDetailActivity).getCourseBean() 128 (activity as CourseDetailActivity).getCourseBean()