package cn.flightfeather.thirdapp.module.inspection
|
|
import android.arch.lifecycle.MutableLiveData
|
import cn.flightfeather.thirdapp.bean.Mediafile
|
import cn.flightfeather.thirdapp.common.net.ResultCallBack
|
import cn.flightfeather.thirdapp.module.base.BaseViewModel
|
import cn.flightfeather.thirdapp.repository.InspectionRepository
|
import cn.flightfeather.thirdapp.repository.ProblemRepository
|
|
/**
|
* @author riku
|
* Date: 2019/8/2
|
*/
|
class MenuCameraViewModel : BaseViewModel() {
|
|
private val inspectionRepository = InspectionRepository()
|
private val problemRepository = ProblemRepository()
|
|
val mediaFileList = MutableLiveData<ArrayList<Mediafile>>().apply { value = ArrayList() }
|
/**
|
* 获取任意拍照图片
|
*/
|
fun getMediaFile(inspectionId: String) {
|
inspectionRepository.getMediaFile(inspectionId, BUSINESS_TYPE_CAMERA, object : ResultCallBack<ArrayList<Mediafile>> {
|
override fun onSuccess(result: ArrayList<Mediafile>?) {
|
result?.let {
|
mediaFileList.value?.run {
|
clear()
|
addAll(it)
|
}
|
mediaFileList.value = mediaFileList.value
|
}
|
}
|
|
override fun onFailure() {
|
|
}
|
|
})
|
}
|
|
/**
|
* 新增本地多媒体文件记录
|
*/
|
fun putMediaFile(mediaFile: Mediafile) {
|
problemRepository.putMediaFileLocal(mediaFile, object : ResultCallBack<Int> {
|
override fun onSuccess(result: Int?) {
|
|
}
|
|
override fun onFailure() {
|
|
}
|
|
})
|
}
|
}
|