| | |
| | | import android.view.View |
| | | import android.view.animation.AnimationUtils |
| | | import android.widget.* |
| | | import cn.flightfeather.thirdapp.CommonApplication |
| | | import cn.flightfeather.thirdapp.R |
| | | import cn.flightfeather.thirdapp.adapter.AllRecyclerViewAdapter |
| | | import cn.flightfeather.thirdapp.bean.entity.Scense |
| | |
| | | val tvExecDate = findViewById<TextView>(R.id.tv_exec_date).apply { |
| | | text = DateFormatter.dateFormat.format(viewModel.todayTask.starttime) |
| | | } |
| | | |
| | | // fixme: 2021/5/31 初始任务执行者默认为当前用户 |
| | | val ids = viewModel.selectedTopTask?.executorguids?.split(Constant.CONNECTOR) |
| | | val userNames = viewModel.selectedTopTask?.executorusernames?.split(Constant.CONNECTOR) |
| | | val realNames = viewModel.selectedTopTask?.executorrealnames?.split(Constant.CONNECTOR) |
| | | var size = ids?.size |
| | | size = when { |
| | | userNames?.size!! > size ?: 0 -> userNames.size |
| | | realNames?.size!! > size ?: 0 -> realNames.size |
| | | else -> size |
| | | } |
| | | val mCheckedArray = BooleanArray(size ?: 0) |
| | | |
| | | val id = StringBuilder() |
| | | val userName = StringBuilder() |
| | | val realName = StringBuilder() |
| | | for (i in ids?.indices ?: 0..0) { |
| | | if (CommonApplication.getInstance().currentUser.guid == ids?.get(i)) { |
| | | mCheckedArray[i] = true |
| | | if (id.isNotEmpty()) { |
| | | id.append(Constant.CONNECTOR) |
| | | userName.append(Constant.CONNECTOR) |
| | | realName.append(Constant.CONNECTOR) |
| | | } |
| | | id.append(ids?.get(i)) |
| | | userName.append(userNames?.get(i)) |
| | | realName.append(realNames?.get(i)) |
| | | } else { |
| | | mCheckedArray[i] = false |
| | | } |
| | | } |
| | | |
| | | val tvTaskExecutors = findViewById<TextView>(R.id.tv_task_executors).apply { |
| | | text = viewModel.selectedTopTask?.executorrealnames?.replace(Constant.CONNECTOR, Constant.CONNECTOR_FOR_VIEW) |
| | | text = realName.toString().replace(Constant.CONNECTOR, Constant.CONNECTOR_FOR_VIEW) |
| | | } |
| | | viewModel.subTaskExecutor.apply { |
| | | this.executorGuids = viewModel.selectedTopTask?.executorguids |
| | | this.executorUserNames = viewModel.selectedTopTask?.executorusernames |
| | | this.executorRealNames = viewModel.selectedTopTask?.executorrealnames |
| | | this.executorGuids = ids.toString() |
| | | this.executorUserNames = userName.toString() |
| | | this.executorRealNames = realName.toString() |
| | | } |
| | | findViewById<LinearLayout>(R.id.ll_exec_date).setOnClickListener{ |
| | | showDatePickerDialog(tvExecDate) |
| | | } |
| | | findViewById<LinearLayout>(R.id.ll_task_executors).setOnClickListener{ |
| | | showExecutorsDialog(tvTaskExecutors) |
| | | showExecutorsDialog(tvTaskExecutors, mCheckedArray) |
| | | } |
| | | } |
| | | |
| | |
| | | /** |
| | | * 显示任务执行者多选对话框 |
| | | */ |
| | | private fun showExecutorsDialog(t: TextView) { |
| | | private fun showExecutorsDialog(t: TextView, mCheckedArray: BooleanArray) { |
| | | // 设置默认选中的选项,全为false默认均未选中 |
| | | val executorGuids = viewModel.selectedTopTask?.executorguids?.split(Constant.CONNECTOR) |
| | | val executorUNames = viewModel.selectedTopTask?.executorusernames?.split(Constant.CONNECTOR)?.toTypedArray() |
| | | val executorRNames = viewModel.selectedTopTask?.executorrealnames?.split(Constant.CONNECTOR)?.toTypedArray() |
| | | |
| | | var size = executorGuids?.size |
| | | size = when { |
| | | executorUNames?.size!! > size ?: 0 -> executorUNames.size |
| | | executorRNames?.size!! > size ?: 0 -> executorRNames.size |
| | | else -> size |
| | | } |
| | | val mCheckedArray = BooleanArray(size ?: 0) |
| | | for (i in mCheckedArray.indices) { |
| | | mCheckedArray[i] = true |
| | | } |
| | | |
| | | val multiChoiceDialog = AlertDialog.Builder(this) |
| | | multiChoiceDialog.setTitle("选择任务执行者") |