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.model.event.InspectionEvent
|
import cn.flightfeather.thirdappmodule.model.event.ProblemEvent
|
import kotlinx.android.synthetic.main.dialog_problem_list.*
|
import org.greenrobot.eventbus.EventBus
|
import org.greenrobot.eventbus.Subscribe
|
import org.greenrobot.eventbus.ThreadMode
|
|
/**
|
* @author riku
|
* Date: 2019/8/1
|
* 整改清单
|
*/
|
class MenuChangeActivity : BaseProblemListActivity() {
|
|
override var viewHolderType: Int = ProblemListAdapter.PROBLEM_LIST
|
|
override var type: Int = InspectionDetailActivity.PROBLEM_CHANGE
|
|
var totalProblemCount = 0
|
|
override fun onCreate(savedInstanceState: Bundle?) {
|
super.onCreate(savedInstanceState)
|
|
viewModel.problemList.observe(this, Observer {
|
it?.let {
|
rv_dialog_problem_list_main.adapter?.notifyDataSetChanged()
|
|
val t1 = "共${it.size}个问题"
|
tv_executors.text = t1
|
|
var changed = 0
|
it.forEach {p ->
|
if (p.ischanged) changed++
|
}
|
val t2 = "${changed}已整改"
|
tv_start_time.text = t2
|
|
totalProblemCount = it.size
|
}
|
})
|
|
viewModel.getProblems(inspection?.guid)
|
}
|
|
@Subscribe(threadMode = ThreadMode.BACKGROUND)
|
fun onUpdateChange(problemEvent: ProblemEvent) {
|
if (problemEvent.type == InspectionDetailActivity.PROBLEM_CHANGE) {
|
inspection?.apply {
|
changednum = changednum?.plus(1) ?: 1
|
|
if (changednum == totalProblemCount) {
|
ischanged = true
|
}
|
viewModel.getProblems(guid)
|
EventBus.getDefault().post(InspectionEvent(this))
|
}
|
}
|
}
|
}
|