| | |
| | | import android.arch.lifecycle.MutableLiveData |
| | | import cn.flightfeather.thirdapp.bean.Mediafile |
| | | import cn.flightfeather.thirdapp.common.net.ResultCallBack |
| | | import cn.flightfeather.thirdapp.model.enumreation.MediaFileType |
| | | import cn.flightfeather.thirdapp.module.base.BaseViewModel |
| | | import cn.flightfeather.thirdapp.repository.InspectionRepository |
| | | import cn.flightfeather.thirdapp.repository.ProblemRepository |
| | |
| | | private val inspectionRepository = InspectionRepository() |
| | | private val problemRepository = ProblemRepository() |
| | | |
| | | val mediaFileList = MutableLiveData<ArrayList<Mediafile>>().apply { value = ArrayList() } |
| | | //常规记录图片 |
| | | val routineRecordList = MutableLiveData<ArrayList<Mediafile>>().apply { value = ArrayList() } |
| | | //铭牌图片 |
| | | val nameplateList = MutableLiveData<ArrayList<Mediafile>>().apply { value = ArrayList() } |
| | | //监测设备图片 |
| | | val monitorDeviceList = MutableLiveData<ArrayList<Mediafile>>().apply { value = ArrayList() } |
| | | |
| | | private val dataSet = listOf( |
| | | Pair(MediaFileType.RoutineRecord, routineRecordList), |
| | | Pair(MediaFileType.Nameplate, nameplateList), |
| | | Pair(MediaFileType.MonitorDevice, monitorDeviceList) |
| | | ) |
| | | |
| | | /** |
| | | * 获取任意拍照图片 |
| | | */ |
| | | fun getMediaFile(inspectionId: String) { |
| | | inspectionRepository.getMediaFile(inspectionId, BUSINESS_TYPE_CAMERA, object : ResultCallBack<ArrayList<Mediafile>> { |
| | | dataSet.forEach {p -> |
| | | inspectionRepository.getMediaFile(inspectionId, p.first.value, object : ResultCallBack<ArrayList<Mediafile>> { |
| | | override fun onSuccess(result: ArrayList<Mediafile>?) { |
| | | result?.let { |
| | | mediaFileList.value?.run { |
| | | p.second.value?.run { |
| | | clear() |
| | | add(0, Mediafile())//在列表头添加图片拍摄按钮 |
| | | addAll(it) |
| | | } |
| | | mediaFileList.value = mediaFileList.value |
| | | p.second.value = p.second.value |
| | | } |
| | | } |
| | | |
| | |
| | | |
| | | }) |
| | | } |
| | | } |
| | | |
| | | /** |
| | | * 新增本地多媒体文件记录 |