fix: TaskListFragment NFC 打卡 TODO 填充
TaskListFragment 有两处"开启打卡"按钮留的 TODO(普通任务+巡检任务), 补充为调用 nfcTaskManager.startTaskPunch()。 打卡成功后刷新当前任务详情。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -17,6 +17,7 @@ import com.xiaoqu.watch.databinding.FragmentTaskListBinding
|
|||||||
import com.xiaoqu.watch.network.ApiResult
|
import com.xiaoqu.watch.network.ApiResult
|
||||||
import com.xiaoqu.watch.network.api.TaskApi
|
import com.xiaoqu.watch.network.api.TaskApi
|
||||||
import com.xiaoqu.watch.network.safeApiCall
|
import com.xiaoqu.watch.network.safeApiCall
|
||||||
|
import com.xiaoqu.watch.service.manager.NfcTaskManager
|
||||||
import com.xiaoqu.watch.ui.common.BaseFragment
|
import com.xiaoqu.watch.ui.common.BaseFragment
|
||||||
import com.xiaoqu.watch.ui.widget.QuTipDialog
|
import com.xiaoqu.watch.ui.widget.QuTipDialog
|
||||||
import dagger.hilt.android.AndroidEntryPoint
|
import dagger.hilt.android.AndroidEntryPoint
|
||||||
@@ -38,6 +39,7 @@ import kotlin.math.abs
|
|||||||
class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
||||||
|
|
||||||
@Inject lateinit var taskApi: TaskApi
|
@Inject lateinit var taskApi: TaskApi
|
||||||
|
@Inject lateinit var nfcTaskManager: NfcTaskManager
|
||||||
|
|
||||||
/** 任务 ID 列表(queryTaskIds 返回) */
|
/** 任务 ID 列表(queryTaskIds 返回) */
|
||||||
private var taskList: List<TaskItem> = emptyList()
|
private var taskList: List<TaskItem> = emptyList()
|
||||||
@@ -391,14 +393,11 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
|||||||
5 -> {
|
5 -> {
|
||||||
when (detail.status) {
|
when (detail.status) {
|
||||||
4 -> {
|
4 -> {
|
||||||
// 巡检进行中 → NFC 打卡(不是确认完成)
|
// 巡检进行中 → NFC 打卡
|
||||||
btn.text = "开启打卡"
|
btn.text = "开启打卡"
|
||||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_orange)
|
btn.setBackgroundResource(R.drawable.bg_foot_btn_orange)
|
||||||
btn.setTextColor(requireContext().getColor(R.color.background))
|
btn.setTextColor(requireContext().getColor(R.color.background))
|
||||||
btn.setOnClickListener {
|
btn.setOnClickListener { startNfcPunch(detail.id, btn) }
|
||||||
// TODO: NFC 打卡流程
|
|
||||||
Timber.d("巡检 NFC 打卡(后续实现)")
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
else -> showBackButton(btn)
|
else -> showBackButton(btn)
|
||||||
}
|
}
|
||||||
@@ -435,10 +434,7 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
|||||||
btn.text = "开启打卡"
|
btn.text = "开启打卡"
|
||||||
btn.setBackgroundResource(R.drawable.bg_foot_btn_orange)
|
btn.setBackgroundResource(R.drawable.bg_foot_btn_orange)
|
||||||
btn.setTextColor(requireContext().getColor(R.color.background))
|
btn.setTextColor(requireContext().getColor(R.color.background))
|
||||||
btn.setOnClickListener {
|
btn.setOnClickListener { startNfcPunch(detail.id, btn) }
|
||||||
// TODO: NFC 打卡流程
|
|
||||||
Timber.d("NFC 打卡(后续实现)")
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
// 无场景 → 绿色「确认打卡」→ 直接确认
|
// 无场景 → 绿色「确认打卡」→ 直接确认
|
||||||
btn.text = "确认打卡"
|
btn.text = "确认打卡"
|
||||||
@@ -447,6 +443,39 @@ class TaskListFragment : BaseFragment<FragmentTaskListBinding>() {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/** NFC 任务打卡(有场景打卡 / 巡检打卡) */
|
||||||
|
private fun startNfcPunch(taskId: Long, btn: android.widget.TextView) {
|
||||||
|
// 切换到扫描状态
|
||||||
|
btn.text = "贴近信标..."
|
||||||
|
btn.isEnabled = false
|
||||||
|
btn.setBackgroundResource(R.drawable.bg_foot_btn_grey)
|
||||||
|
|
||||||
|
nfcTaskManager.startTaskPunch(taskId) { success, message ->
|
||||||
|
if (success) {
|
||||||
|
tipDialog.show(
|
||||||
|
status = QuTipDialog.Status.SUCCESS,
|
||||||
|
title = "打卡成功",
|
||||||
|
back = false, step = 1, countdown = 2
|
||||||
|
)
|
||||||
|
// 刷新当前任务详情
|
||||||
|
fetchCurrentDetail()
|
||||||
|
} else {
|
||||||
|
if (message != "超时") {
|
||||||
|
tipDialog.show(
|
||||||
|
status = QuTipDialog.Status.ERROR,
|
||||||
|
title = "打卡失败",
|
||||||
|
desc = message,
|
||||||
|
back = false, step = 0, countdown = 3
|
||||||
|
)
|
||||||
|
}
|
||||||
|
// 恢复按钮
|
||||||
|
btn.text = "开启打卡"
|
||||||
|
btn.isEnabled = true
|
||||||
|
btn.setBackgroundResource(R.drawable.bg_foot_btn_orange)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/** 设置完成任务按钮(状态4) */
|
/** 设置完成任务按钮(状态4) */
|
||||||
private fun setupCompleteButton(btn: android.widget.TextView, detail: TaskDetail) {
|
private fun setupCompleteButton(btn: android.widget.TextView, detail: TaskDetail) {
|
||||||
btn.text = "完成任务"
|
btn.text = "完成任务"
|
||||||
|
|||||||
Reference in New Issue
Block a user