From 0e870a0d919a28a45084a7df5f662afbfd7e086d Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 15 十二月 2020 14:44:28 +0800
Subject: [PATCH] DownloadAndSetImageTask和SetImageTask两个类由于在子线程执行,会经常出现activity关闭后继续执行导致报错崩溃问题,修复此bug
---
app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraViewModel.kt | 40 ++++++++++++++++++++++++++++------------
1 files changed, 28 insertions(+), 12 deletions(-)
diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraViewModel.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraViewModel.kt
index eae0b61..8d93bcd 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraViewModel.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuCameraViewModel.kt
@@ -3,6 +3,7 @@
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
@@ -16,27 +17,42 @@
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>> {
- override fun onSuccess(result: ArrayList<Mediafile>?) {
- result?.let {
- mediaFileList.value?.run {
- clear()
- addAll(it)
+ dataSet.forEach {p ->
+ inspectionRepository.getMediaFile(inspectionId, p.first.value, object : ResultCallBack<ArrayList<Mediafile>> {
+ override fun onSuccess(result: ArrayList<Mediafile>?) {
+ result?.let {
+ p.second.value?.run {
+ clear()
+ add(0, Mediafile())//鍦ㄥ垪琛ㄥご娣诲姞鍥剧墖鎷嶆憚鎸夐挳
+ addAll(it)
+ }
+ p.second.value = p.second.value
}
- mediaFileList.value = mediaFileList.value
}
- }
- override fun onFailure() {
+ override fun onFailure() {
- }
+ }
- })
+ })
+ }
}
/**
--
Gitblit v1.9.3