From 979d9cff22806f213b420452ab4a68fcbaf021b6 Mon Sep 17 00:00:00 2001
From: riku <risaku@163.com>
Date: 星期一, 31 五月 2021 17:43:49 +0800
Subject: [PATCH] 1. 修复多项可能引起空指针崩溃的bug; 2. 新建子任务时默认执行人员从全体人员改为当前用户; 3. 新建子任务时默认执行时间强制固定为总任务对应的时段内,确保子任务执行时间不会超出总任务范围。

---
 app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt |   59 ++++++++++++++++++++++++++++++++++++++---------------------
 1 files changed, 38 insertions(+), 21 deletions(-)

diff --git a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt
index c72805a..2767749 100644
--- a/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt
+++ b/app/src/main/java/cn/flightfeather/thirdapp/module/inspection/MenuProblemUpdateActivity.kt
@@ -6,9 +6,9 @@
 import android.os.Environment
 import android.view.View
 import android.widget.AdapterView
-import cn.flightfeather.thirdapp.bean.Domainitem
-import cn.flightfeather.thirdapp.bean.Mediafile
-import cn.flightfeather.thirdapp.bean.Problemtype
+import cn.flightfeather.thirdapp.bean.entity.Domainitem
+import cn.flightfeather.thirdapp.bean.entity.Mediafile
+import cn.flightfeather.thirdapp.bean.entity.Problemtype
 import cn.flightfeather.thirdapp.bean.vo.ProblemlistVo
 import cn.flightfeather.thirdapp.module.base.VIEW_PHOTO
 import kotlinx.android.synthetic.main.dialog_take_evidence.*
@@ -63,10 +63,13 @@
             VIEW_PHOTO -> {
                 //鏌ョ湅涓存椂鎷嶆憚鍥剧墖鍙互鍒犻櫎
                 data?.getIntExtra("position", -1)?.let {
-                    if (it > -1) {
-                        viewModel.mediaFileList.value?.get(it)?.let {m ->
+                    val size = viewModel.mediaFileList.value?.size ?: 0
+                    if (it > -1 && it < size) {
+                        viewModel.mediaFileList.value?.get(it)?.let { m ->
                             deleteMediaFileList.add(m)
                         }
+                    } else {
+                        toast("瑕佸垹闄ょ殑鍥剧墖涓嶅瓨鍦�")
                     }
                 }
             }
@@ -76,6 +79,36 @@
     override fun getExtra() {
         super.getExtra()
         problemVo = intent.getSerializableExtra("problemlistVo") as ProblemlistVo
+    }
+
+    override fun onSuggestionLoaded() {
+        super.onSuggestionLoaded()
+        if (problemVo != null && viewModel.suggestionList.value?.isNotEmpty() == true) {
+            //鏁存敼寤鸿
+            var advice = problemVo!!.advise
+            var getSuggestion = false
+            for (i in viewModel.suggestionList.value?.indices ?: 0..0) {
+                val s = viewModel.suggestionList.value?.get(i)
+                if (s != null && advice.contains(s)) {
+                    advice = advice.replace(s, "")
+                    sp_take_evidence_select_suggestion.setSelection(i)
+                    getSuggestion = true
+                    break
+                }
+            }
+            //鏁存敼寤鸿澶囨敞
+            if (getSuggestion) {
+                var suggestionRemark = advice.removeRange(0, 1)//鍒犻櫎绗竴涓瓧绗︼紝鎷彿鈥滐紙鈥�
+                suggestionRemark = suggestionRemark.dropLast(1)//鍒犻櫎鏈�鍚庝竴涓瓧绗︼紝鎷彿鈥滐級鈥�
+                et_take_evidence_suggestion.setText(suggestionRemark)
+            }
+        }
+        sp_take_evidence_select_problem_type.onItemSelectedListener = object : AdapterView.OnItemSelectedListener {
+            override fun onNothingSelected(parent: AdapterView<*>?) = Unit
+            override fun onItemSelected(parent: AdapterView<*>?, view: View?, position: Int, id: Long) {
+                onProblemTypeSelected(position)
+            }
+        }
     }
 
     override fun initObserver() {
@@ -131,22 +164,6 @@
                     locationRemark = locationRemark.dropLast(1)//鍒犻櫎鏈�鍚庝竴涓瓧绗︼紝鎷彿鈥滐級鈥�
                 }
                 et_take_evidence_location.setText(locationRemark)
-
-                //鏁存敼寤鸿
-                var advice = problemVo!!.advise
-                var suggestion = ""
-                for (i in viewModel.suggestionList.value?.indices ?: 0..0) {
-                    val s = viewModel.suggestionList.value?.get(i)
-                    if (s != null && advice.contains(s)) {
-                        advice = advice.replace(s, "")
-                        sp_take_evidence_select_suggestion.setSelection(i)
-                        break
-                    }
-                }
-                //鏁存敼寤鸿澶囨敞
-                var suggestionRemark = advice.removeRange(0, 1)//鍒犻櫎绗竴涓瓧绗︼紝鎷彿鈥滐紙鈥�
-                suggestionRemark = suggestionRemark.dropLast(1)//鍒犻櫎鏈�鍚庝竴涓瓧绗︼紝鎷彿鈥滐級鈥�
-                et_take_evidence_suggestion.setText(suggestionRemark)
             }
         })
 

--
Gitblit v1.9.3