package cn.flightfeather.thirdappmodule.module.inspection
|
|
import android.arch.lifecycle.Observer
|
import android.os.Bundle
|
import cn.flightfeather.thirdappmodule.adapter.ProblemListAdapter
|
import cn.flightfeather.thirdappmodule.bean.vo.ProblemlistVo
|
import cn.flightfeather.thirdappmodule.model.event.InspectionEvent
|
import cn.flightfeather.thirdappmodule.model.event.ProblemEvent
|
import cn.flightfeather.thirdappmodule.util.Constant
|
import cn.flightfeather.thirdappmodule.util.DateFormatter
|
import kotlinx.android.synthetic.main.dialog_problem_list.*
|
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.ThreadMode
|
import java.util.*
|
|
/**
|
* @author riku
|
* Date: 2019/8/1
|
* 问题复核activity
|
*/
|
class MenuRecheckActivity : BaseProblemListActivity() {
|
override var viewHolderType: Int = ProblemListAdapter.RECHECK_LIST
|
|
override var type: Int = InspectionDetailActivity.PROBLEM_RECHECK
|
|
var totalProblemCount = 0
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
super.onCreate(savedInstanceState)
|
|
viewModel.subTaskPack.observe(this, Observer {
|
it?.let {
|
val changedList = ArrayList<ProblemlistVo>()
|
var rechecked = 0
|
it.problemlistVo?.forEach {p ->
|
if (p.ischanged) {
|
changedList.add(p)
|
}
|
if (p.isrechecked) {
|
rechecked++
|
}
|
}
|
|
|
viewModel.problemList.value?.run {
|
clear()
|
addAll(it.problemlistVo ?: emptyList())
|
removeAll(changedList)
|
rv_dialog_problem_list_main.adapter?.notifyDataSetChanged()
|
}
|
|
val t1 = it.subtaskVo?.executorrealtimes?.replace(Constant.CONNECTOR, Constant.CONNECTOR_FOR_VIEW)
|
val t2 = it.subtaskVo?.executionstarttime?.let { time -> DateFormatter.dateTimeFormat.format(time)}
|
|
val t11 = "${if (t1 != null) t1 + "\n" else ""} 共${viewModel.problemList.value?.size ?: 0}个问题"
|
val t22 = "${if (t2 != null) t2 + "\n" else ""} ${rechecked}个已复核"
|
|
totalProblemCount = viewModel.problemList.value?.size ?: 0
|
|
tv_executors.text = t11
|
tv_start_time.text = t22
|
}
|
})
|
|
viewModel.getLastProblems(subTaskSelected)
|
}
|
|
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
fun onUpdateRecheck(problemEvent: ProblemEvent) {
|
if (problemEvent.type == InspectionDetailActivity.PROBLEM_RECHECK) {
|
inspection?.apply {
|
recheckcount = recheckcount?.plus(1) ?: 1
|
|
if (recheckcount == totalProblemCount) {
|
isrechecked = true
|
}
|
|
EventBus.getDefault().post(InspectionEvent(this))
|
}
|
}
|
}
|
}
|