...
|
...
|
@@ -2,6 +2,7 @@ package com.br_technology.securitytrain_master.ui.view.mine.fragment |
|
|
|
|
|
import android.annotation.SuppressLint
|
|
|
import android.content.Intent
|
|
|
import android.os.Bundle
|
|
|
import android.view.View
|
|
|
import com.br_technology.securitytrain_master.base.common.ConstantParamKey
|
|
|
import com.br_technology.securitytrain_master.base.common.ConstantType
|
...
|
...
|
@@ -10,6 +11,7 @@ import com.br_technology.securitytrain_master.ui.bean.* |
|
|
import com.br_technology.securitytrain_master.ui.view.home.activity.course.CourseDetailActivity
|
|
|
import com.br_technology.securitytrain_master.ui.view.home.activity.course.CoursePractiseActivity
|
|
|
import com.br_technology.securitytrain_master.ui.view.home.activity.course.TextDetailActivity
|
|
|
import com.br_technology.securitytrain_master.ui.view.home.event.StatusTypeEvent
|
|
|
import com.br_technology.securitytrain_master.ui.view.mine.adapter.CourseAdapter
|
|
|
import com.br_technology.securitytrain_master.ui.view.mine.adapter.TrainTestAdapter
|
|
|
import com.br_technology.securitytrain_master.ui.view.mine.viewmodel.ClassDutyCourseViewModel
|
...
|
...
|
@@ -17,6 +19,8 @@ import com.br_technology.securitytrain_master.util.TranslateUnit |
|
|
import com.br_technology.securitytrain_master.view.DialogMention
|
|
|
import com.br_technology.securitytrain_master.view.VerticalDecoration
|
|
|
import com.wjx.android.wanandroidmvvm.base.view.BaseLifeCycleFragment
|
|
|
import org.greenrobot.eventbus.EventBus
|
|
|
import org.greenrobot.eventbus.Subscribe
|
|
|
import java.text.SimpleDateFormat
|
|
|
import java.util.*
|
|
|
|
...
|
...
|
@@ -35,6 +39,33 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
var courseAdapter: CourseAdapter? = null
|
|
|
var trainTestAdapter: TrainTestAdapter? = null
|
|
|
var lessonBean: LessonList? = null
|
|
|
var status = 0
|
|
|
|
|
|
override fun onViewCreated(view: View, savedInstanceState: Bundle?) {
|
|
|
super.onViewCreated(view, savedInstanceState)
|
|
|
EventBus.getDefault().register(this)
|
|
|
}
|
|
|
|
|
|
override fun onDestroyView() {
|
|
|
EventBus.getDefault().unregister(this)
|
|
|
super.onDestroyView()
|
|
|
}
|
|
|
|
|
|
@Subscribe
|
|
|
fun statusChange(status: StatusTypeEvent) {
|
|
|
this.status = status.id
|
|
|
refreshData()
|
|
|
}
|
|
|
|
|
|
private fun boolData(boolean: Boolean) {
|
|
|
if (boolean) {
|
|
|
binding.layData.visibility = View.VISIBLE
|
|
|
binding.tvNoData.visibility = View.GONE
|
|
|
} else {
|
|
|
binding.layData.visibility = View.GONE
|
|
|
binding.tvNoData.visibility = View.VISIBLE
|
|
|
}
|
|
|
}
|
|
|
|
|
|
@SuppressLint("SetTextI18n")
|
|
|
override fun initDataObserver() {
|
...
|
...
|
@@ -48,16 +79,15 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
"已学课时:${lessonBean!!.lesson_class_user}/ ${lessonBean!!.lesson_class_count}"
|
|
|
}
|
|
|
val list = it.data.list
|
|
|
if (list.isNotEmpty()) {
|
|
|
if (page == 1) {
|
|
|
courseAdapter = CourseAdapter()
|
|
|
courseAdapter?.setListener(this)
|
|
|
courseAdapter?.setList(list)
|
|
|
binding.recyclerview.adapter = courseAdapter
|
|
|
boolData(list.isNotEmpty())
|
|
|
} else {
|
|
|
courseAdapter?.addData(list)
|
|
|
}
|
|
|
}
|
|
|
if (list.size < 10) {
|
|
|
courseAdapter?.loadMoreModule?.loadMoreEnd()
|
|
|
} else {
|
...
|
...
|
@@ -67,16 +97,15 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
mViewModel.listPractise.observe(this, {
|
|
|
binding.smartRefresh.isRefreshing = false
|
|
|
val list = it.data.list
|
|
|
if (list.isNotEmpty()) {
|
|
|
if (page == 1) {
|
|
|
trainTestAdapter = TrainTestAdapter()
|
|
|
trainTestAdapter?.setListener(this)
|
|
|
trainTestAdapter?.addData(transPracticeData(list))
|
|
|
binding.recyclerview.adapter = trainTestAdapter
|
|
|
boolData(list.isNotEmpty())
|
|
|
} else {
|
|
|
trainTestAdapter?.addData(transPracticeData(list))
|
|
|
}
|
|
|
}
|
|
|
if (list.size < 10) {
|
|
|
trainTestAdapter?.loadMoreModule?.loadMoreEnd()
|
|
|
} else {
|
...
|
...
|
@@ -86,16 +115,15 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
mViewModel.listExam.observe(this, {
|
|
|
binding.smartRefresh.isRefreshing = false
|
|
|
val list = it.data.list
|
|
|
if (list.isNotEmpty()) {
|
|
|
if (page == 1) {
|
|
|
trainTestAdapter = TrainTestAdapter()
|
|
|
trainTestAdapter?.setListener(this)
|
|
|
trainTestAdapter?.addData(transExamData(list))
|
|
|
binding.recyclerview.adapter = trainTestAdapter
|
|
|
boolData(list.isNotEmpty())
|
|
|
} else {
|
|
|
trainTestAdapter?.addData(transExamData(list))
|
|
|
}
|
|
|
}
|
|
|
if (list.size < 10) {
|
|
|
trainTestAdapter?.loadMoreModule?.loadMoreEnd()
|
|
|
} else {
|
...
|
...
|
@@ -106,9 +134,9 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
|
|
|
private fun getData() {
|
|
|
when (type) {
|
|
|
ConstantType.TYPE_CLASS_COURSE -> mViewModel.getTrainLessonList(0, page)
|
|
|
ConstantType.TYPE_CLASS_PRACTICE -> mViewModel.getTrainPractiseList(0, page)
|
|
|
ConstantType.TYPE_CLASS_EXAM -> mViewModel.getTrainExamList(0, page)
|
|
|
ConstantType.TYPE_CLASS_COURSE -> mViewModel.getTrainLessonList(status, page)
|
|
|
ConstantType.TYPE_CLASS_PRACTICE -> mViewModel.getTrainPractiseList(status, page)
|
|
|
ConstantType.TYPE_CLASS_EXAM -> mViewModel.getTrainExamList(status, page)
|
|
|
else -> {
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -179,6 +207,7 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
courseAdapter?.loadMoreModule?.setOnLoadMoreListener {
|
|
|
loadMore()
|
|
|
}
|
|
|
binding.tvNoData.text = "暂无课程"
|
|
|
}
|
|
|
else -> {
|
|
|
trainTestAdapter = TrainTestAdapter()
|
...
|
...
|
@@ -188,6 +217,11 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
courseAdapter?.loadMoreModule?.setOnLoadMoreListener {
|
|
|
loadMore()
|
|
|
}
|
|
|
if (ConstantType.TYPE_CLASS_PRACTICE == type) {
|
|
|
binding.tvNoData.text = "暂无练习"
|
|
|
} else {
|
|
|
binding.tvNoData.text = "暂无考试"
|
|
|
}
|
|
|
}
|
|
|
}
|
|
|
}
|
...
|
...
|
@@ -238,10 +272,12 @@ class ClassDutyCourseFragment(val type: Int) : |
|
|
if (bool) {
|
|
|
startNext(item)
|
|
|
} else {
|
|
|
dialogMention.show()
|
|
|
dialogMention.setListener {
|
|
|
startNext(item)
|
|
|
}
|
|
|
// dialogMention.show()
|
|
|
// dialogMention.setListener {
|
|
|
// startNext(item)
|
|
|
// }
|
|
|
// ios 不做跳转,保持一致
|
|
|
showTip("不在考试时间")
|
|
|
}
|
|
|
} else {
|
|
|
showTip("考试已结束")
|
...
|
...
|
|