From 29c6cb0031e3d1aac2e326b3a83fa78bcd380890 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 21 十二月 2020 10:57:07 +0800
Subject: [PATCH] 1. 修改巡查界面刚进入快速点击巡查功能按钮导致崩溃问题; 2. 修复技防措施的地址记录信息有加号的问题

---
 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