From e234a15b428267997c903a4ed42536c5d9f14a1f Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 10 十一月 2025 13:10:42 +0800
Subject: [PATCH] 2025.11.10 1. 新增巡查场景历史详情相关数据逻辑; 2. 新增工地施工阶段修改界面;
---
app/src/main/java/cn/flightfeather/thirdappmodule/module/inspection/MenuCameraViewModel.kt | 102 +++++++++++++++++++++++++-------------------------
1 files changed, 51 insertions(+), 51 deletions(-)
diff --git a/app/src/main/java/cn/flightfeather/thirdappmodule/module/inspection/MenuCameraViewModel.kt b/app/src/main/java/cn/flightfeather/thirdappmodule/module/inspection/MenuCameraViewModel.kt
index 9b6d8fc..8cdb4f5 100644
--- a/app/src/main/java/cn/flightfeather/thirdappmodule/module/inspection/MenuCameraViewModel.kt
+++ b/app/src/main/java/cn/flightfeather/thirdappmodule/module/inspection/MenuCameraViewModel.kt
@@ -26,7 +26,7 @@
private val inspectionRepository = InspectionRepository()
private val problemRepository = ProblemRepository()
- private val commonRepository = CommonRepository()
+ private val commonRepository = CommonRepository.instance
//甯歌璁板綍鍥剧墖
val routineRecordList = MutableLiveData<ArrayList<Mediafile>>().apply { value = ArrayList() }
@@ -38,12 +38,6 @@
val fileList = MutableLiveData<MutableList<MediaData>>().apply { value = mutableListOf() }
private var loadedCount = 0
- private val dataSet = listOf(
- Pair(MediaFileType.RoutineRecord, routineRecordList),
- Pair(MediaFileType.Nameplate, nameplateList),
- Pair(MediaFileType.MonitorDevice, monitorDeviceList)
- )
-
/**
* 鑾峰彇浠绘剰鎷嶇収鍥剧墖
*/
@@ -52,19 +46,19 @@
override fun onSuccess(types: List<MediaFileType>?) {
fileList.value?.clear()
loadedCount = 0
- types?.forEachWithIndex { i, type ->
- inspectionRepository.getMediaFile(inspectionId, type.value, object : ResultCallBack<ArrayList<Mediafile>> {
+ types?.forEach { t ->
+ inspectionRepository.getMediaFile(inspectionId, t.value, object : ResultCallBack<ArrayList<Mediafile>> {
override fun onSuccess(result: ArrayList<Mediafile>?) {
- commonRepository.getAlias(sceneTypeId, type, object : ResultCallBack<String> {
+ commonRepository.getAlias(sceneTypeId, t.value, object : ResultCallBack<String> {
override fun onSuccess(alias: String?) {
result?.let {
fileList.value?.add(MediaData().apply {
- this.type = type
+ this.type = t
this.alias = if (alias.isNullOrBlank()) null else alias
dataList = it
dataList.add(0, Mediafile())
})
- onMediaFileGet(types.size, sceneTypeId)
+ onMediaFileGet(types.size, types)
}
}
@@ -85,11 +79,6 @@
}
})
-
-
- dataSet.forEach { p ->
-
- }
}
/**
@@ -121,43 +110,54 @@
})
}
- private fun onMediaFileGet(total: Int, sceneTypeId: Int) {
+ /**
+ * 灏嗕换鎰忔媿鐨勭粨鏋滄寜鐓х粰瀹氱殑鍒嗙被椤哄簭鎺掑垪
+ */
+ private fun onMediaFileGet(total: Int, types: List<MediaFileType>) {
loadedCount++
+ // 褰撴瘡绉嶇被鍨嬬殑鏁版嵁閮借幏鍙栧畬姣曞悗锛岃繘琛岄噸鎺掑簭鎿嶄綔
if (loadedCount == total) {
- val list = fileList.value?.sortedBy {
- it.type?.value
- }?.toMutableList() ?: mutableListOf()
- if (sceneTypeId == SceneType.Construction.value
- || sceneTypeId == SceneType.Wharf.value
- || sceneTypeId == SceneType.MixingPlant.value
- || sceneTypeId == SceneType.StorageYard.value) {
- fileList.value?.clear()
- for (i in list.indices) {
- if (list[i].type == MediaFileType.RoutineRecord) {
- fileList.value?.add(list[i])
- list.removeAt(i)
- break
- }
- }
- for (i in list.indices) {
- if (list[i].type == MediaFileType.MonitorDevice) {
- fileList.value?.add(list[i])
- list.removeAt(i)
- break
- }
- }
- for (i in list.indices) {
- if (list[i].type == MediaFileType.Nameplate) {
- fileList.value?.add(list[i])
- list.removeAt(i)
- break
- }
- }
- fileList.value?.addAll(list)
- fileList.value = fileList.value
- } else {
- fileList.value = list
+ val tempList = mutableListOf<MediaData>()
+ types.forEach { t ->
+ fileList.value?.find { it.type?.value == t.value }?.let { tempList.add(it) }
}
+ fileList.value = tempList
+
+// val list = fileList.value?.sortedBy {
+// it.type?.value
+// }?.toMutableList() ?: mutableListOf()
+
+// if (sceneTypeId == SceneType.Construction.value
+// || sceneTypeId == SceneType.Wharf.value
+// || sceneTypeId == SceneType.MixingPlant.value
+// || sceneTypeId == SceneType.StorageYard.value) {
+// fileList.value?.clear()
+// for (i in list.indices) {
+// if (list[i].type == MediaFileType.RoutineRecord) {
+// fileList.value?.add(list[i])
+// list.removeAt(i)
+// break
+// }
+// }
+// for (i in list.indices) {
+// if (list[i].type == MediaFileType.MonitorDevice) {
+// fileList.value?.add(list[i])
+// list.removeAt(i)
+// break
+// }
+// }
+// for (i in list.indices) {
+// if (list[i].type == MediaFileType.Nameplate) {
+// fileList.value?.add(list[i])
+// list.removeAt(i)
+// break
+// }
+// }
+// fileList.value?.addAll(list)
+// fileList.value = fileList.value
+// } else {
+// fileList.value = list
+// }
}
}
--
Gitblit v1.9.3