| | |
| | | package cn.flightfeather.thirdapp.module.inspection |
| | | |
| | | import android.arch.lifecycle.MutableLiveData |
| | | import cn.flightfeather.thirdapp.bean.LastSubtaskPack |
| | | import cn.flightfeather.thirdapp.bean.Subtask |
| | | import cn.flightfeather.thirdapp.bean.vo.LastSubtaskPack |
| | | import cn.flightfeather.thirdapp.bean.entity.Subtask |
| | | import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo |
| | | import cn.flightfeather.thirdapp.common.net.ResultCallBack |
| | | import cn.flightfeather.thirdapp.common.net.ResultCallBack2 |
| | | import cn.flightfeather.thirdapp.model.event.ProblemEvent |
| | | import cn.flightfeather.thirdapp.module.base.BaseViewModel |
| | | import cn.flightfeather.thirdapp.repository.InspectionRepository |
| | | import cn.flightfeather.thirdapp.repository.ProblemRepository |
| | | import cn.flightfeather.thirdapp.util.DateFormatter |
| | | import org.greenrobot.eventbus.EventBus |
| | | import org.jetbrains.anko.toast |
| | | |
| | | /** |
| | | * @author riku |
| | |
| | | class BaseProblemListViewModel : BaseViewModel() { |
| | | |
| | | private val inspectionRepository = InspectionRepository() |
| | | private val problemRepository = ProblemRepository() |
| | | |
| | | var problemList = MutableLiveData<ArrayList<ProblemlistVo>>().apply { value = ArrayList() } |
| | | |
| | |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 删除问题 |
| | | */ |
| | | fun deleteProblem(position: Int, s: () -> Unit) { |
| | | problemList.value?.get(position)?.let { |
| | | problemRepository.deleteProblem(it.guid ?: "", object : ResultCallBack2<Int> { |
| | | override fun onSuccess(result: Int?, message: String) { |
| | | if (result != null) { |
| | | EventBus.getDefault().post(ProblemEvent(it.voToEntity(), InspectionDetailActivity.PROBLEM_DELETE)) |
| | | s() |
| | | } |
| | | } |
| | | |
| | | override fun onFailure(message: String) { |
| | | application.toast(message) |
| | | } |
| | | }) |
| | | } |
| | | } |
| | | } |