riku
2022-02-18 d59d55575d913646b7a90fca651904ab889c6723
app/src/main/java/cn/flightfeather/thirdappmodule/module/task/TaskViewModel.kt
@@ -1,24 +1,17 @@
package cn.flightfeather.thirdappmodule.module.task
import android.arch.lifecycle.MutableLiveData
import android.widget.Toast
import cn.flightfeather.thirdappmodule.bean.entity.Domainitem
import cn.flightfeather.thirdappmodule.bean.entity.Subtask
import cn.flightfeather.thirdappmodule.bean.vo.ProblemDetailVo
import cn.flightfeather.thirdappmodule.bean.vo.TaskVo
import cn.flightfeather.thirdappmodule.common.net.ResultCallBack
import cn.flightfeather.thirdappmodule.httpservice.SubTaskService
import cn.flightfeather.thirdappmodule.httpservice.TaskService
import cn.flightfeather.thirdappmodule.module.base.BaseViewModel
import cn.flightfeather.thirdappmodule.repository.ProblemRepository
import cn.flightfeather.thirdappmodule.repository.SubTaskRepository
import cn.flightfeather.thirdappmodule.repository.TaskRepository
import cn.flightfeather.thirdappmodule.util.Constant
import cn.flightfeather.thirdappmodule.util.DateFormatter
import cn.flightfeather.thirdappmodule.util.Domain
import cn.flightfeather.thirdappmodule.util.UUIDGenerator
import com.ping.greendao.gen.ScenseDao
import okhttp3.ResponseBody
import java.util.*
import kotlin.collections.ArrayList
@@ -35,20 +28,25 @@
    private val taskRepository = TaskRepository()
    private val subTaskRepository = SubTaskRepository()
    private val problemRepository = ProblemRepository()
    private val allTopTaskList = ArrayList<TaskVo>()// 系统中所有总任务
    private val problemMap = mutableMapOf<String, MutableList<String>>()// 问题类型与具体问题
    /**临时任务功能与任务信息导出功能***************************************************************************/
    // 总任务类型
    val allTaskTypeList = MutableLiveData<ArrayList<Domainitem>>().apply { value = ArrayList() }
    // 当前筛选条件下的总任务
    val topTaskList = MutableLiveData<ArrayList<TaskVo>>().apply { value = ArrayList() }
    val allTopTaskList = ArrayList<TaskVo>()
    // 问题类型
    val problemTypeList = MutableLiveData<ArrayList<String>>().apply { value = ArrayList() }
    // 具体问题
    val problemDetailList = MutableLiveData<ArrayList<String>>().apply { value = ArrayList() }
    // 子任务id与名称
    val subTaskNameList = MutableLiveData<ArrayList<Pair<String, String>>>().apply { value = ArrayList() }
    /***********************************************************************************************************/
    val problemMap = mutableMapOf<String, MutableList<String>>()
    val subTaskList = MutableLiveData<ArrayList<Pair<String, String>>>().apply { value = ArrayList() }
    /**任务制订、任务提醒相关***********************************************************************************/
    /***********************************************************************************************************/
    fun getTaskType() {
        taskRepository.getTaskType(object : ResultCallBack<List<Domainitem>> {
@@ -176,11 +174,11 @@
        subTaskRepository.getByTopTaskAndDate(topTaskId,startTime,endTime, object : ResultCallBack<List<Subtask>> {
            override fun onSuccess(result: List<Subtask>?) {
                result?.let {
                    subTaskList.value?.clear()
                    subTaskNameList.value?.clear()
                    it.forEach {s ->
                        subTaskList.value?.add(Pair(s.stguid, s.name))
                        subTaskNameList.value?.add(Pair(s.stguid, s.name))
                    }
                    subTaskList.value = subTaskList.value
                    subTaskNameList.value = subTaskNameList.value
                }
            }