From a5d862051462a5fcc2717b405896a6d424002e54 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期二, 22 十二月 2020 15:43:06 +0800
Subject: [PATCH] 1. 调整了数控实体的存储位置; 2. 新增数据表“媒体文件类型别名表”; 3. 修改任意拍模块,将图片分类改为根据场景类型动态生成,同时新增修改分类别名功能; 4. 优化子任务选择界面的任务排序方式,按照“待开始”、“执行中”、“未执行”的顺序进行排序;

---
 app/src/main/java/cn/flightfeather/thirdapp/module/inspection/BaseProblemListViewModel.kt |   30 ++++++++++++++++++++++++++++--
 1 files changed, 28 insertions(+), 2 deletions(-)

diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/BaseProblemListViewModel.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/BaseProblemListViewModel.kt
index 0deceaa..3fc957d 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/BaseProblemListViewModel.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/BaseProblemListViewModel.kt
@@ -1,13 +1,18 @@
 package cn.flightfeather.thirdapp.module.inspection
 
 import android.arch.lifecycle.MutableLiveData
-import cn.flightfeather.thirdapp.bean.LastSubtaskPack
-import cn.flightfeather.thirdapp.bean.Subtask
+import cn.flightfeather.thirdapp.bean.vo.LastSubtaskPack
+import cn.flightfeather.thirdapp.bean.entity.Subtask
 import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo
 import cn.flightfeather.thirdapp.common.net.ResultCallBack
+import cn.flightfeather.thirdapp.common.net.ResultCallBack2
+import cn.flightfeather.thirdapp.model.event.ProblemEvent
 import cn.flightfeather.thirdapp.module.base.BaseViewModel
 import cn.flightfeather.thirdapp.repository.InspectionRepository
+import cn.flightfeather.thirdapp.repository.ProblemRepository
 import cn.flightfeather.thirdapp.util.DateFormatter
+import org.greenrobot.eventbus.EventBus
+import org.jetbrains.anko.toast
 
 /**
  * @author riku
@@ -16,6 +21,7 @@
 class BaseProblemListViewModel : BaseViewModel() {
 
     private val inspectionRepository = InspectionRepository()
+    private val problemRepository = ProblemRepository()
 
     var problemList = MutableLiveData<ArrayList<ProblemlistVo>>().apply { value = ArrayList() }
 
@@ -67,4 +73,24 @@
             })
         }
     }
+
+    /**
+     * 鍒犻櫎闂
+     */
+    fun deleteProblem(position: Int, s: () -> Unit) {
+        problemList.value?.get(position)?.let {
+            problemRepository.deleteProblem(it.guid ?: "", object : ResultCallBack2<Int> {
+                override fun onSuccess(result: Int?, message: String) {
+                    if (result != null) {
+                        EventBus.getDefault().post(ProblemEvent(it.voToEntity(), InspectionDetailActivity.PROBLEM_DELETE))
+                        s()
+                    }
+                }
+
+                override fun onFailure(message: String) {
+                    application.toast(message)
+                }
+            })
+        }
+    }
 }
\ No newline at end of file

--
Gitblit v1.9.3