fix: 防止重复导航崩溃 - 跳转前检查当前是否在homeFragment
HomeFragment的View不随导航销毁,快捷区点击事件仍会触发。 在非homeFragment时跳过导航。 Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -262,6 +262,10 @@ class HomeFragment : BaseFragment<FragmentHomeBinding>() {
|
|||||||
|
|
||||||
/** 跳转到任务列表(传 tableStatus 参数) */
|
/** 跳转到任务列表(传 tableStatus 参数) */
|
||||||
private fun navigateToTaskList(tableStatus: Int) {
|
private fun navigateToTaskList(tableStatus: Int) {
|
||||||
|
// 防止重复导航:只有当前在 homeFragment 时才跳转
|
||||||
|
val currentDest = findNavController().currentDestination?.id
|
||||||
|
if (currentDest != R.id.homeFragment) return
|
||||||
|
|
||||||
val bundle = bundleOf("tableStatus" to tableStatus)
|
val bundle = bundleOf("tableStatus" to tableStatus)
|
||||||
findNavController().navigate(R.id.action_home_to_taskList, bundle)
|
findNavController().navigate(R.id.action_home_to_taskList, bundle)
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user