Files
xqwatch/app/src/main/res/navigation/nav_main.xml
dongliang 1214ca92a4 fix: 解绑处理移到MainActivity,用全局action从任何页面跳转
HomeFragment在子页面时viewLifecycleOwner被销毁,collect停止,
收不到解绑消息。改为Activity级别处理+全局导航action,彻底解决。

Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
2026-05-11 10:26:29 +09:30

78 lines
3.2 KiB
XML
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
<?xml version="1.0" encoding="utf-8"?>
<navigation xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:id="@+id/nav_main"
app:startDestination="@id/splashFragment">
<!-- 全局 action解绑时从任何页面跳转到绑定页清空回退栈 -->
<action android:id="@+id/action_global_to_bind"
app:destination="@id/bindFragment"
app:popUpTo="@id/nav_main" app:popUpToInclusive="true" />
<!-- 启动分发页 -->
<fragment
android:id="@+id/splashFragment"
android:name="com.xiaoqu.watch.ui.common.SplashFragment"
android:label="启动">
<action android:id="@+id/action_splash_to_home"
app:destination="@id/homeFragment"
app:popUpTo="@id/splashFragment" app:popUpToInclusive="true" />
<action android:id="@+id/action_splash_to_bind"
app:destination="@id/bindFragment"
app:popUpTo="@id/splashFragment" app:popUpToInclusive="true" />
</fragment>
<!-- 首页 -->
<fragment
android:id="@+id/homeFragment"
android:name="com.xiaoqu.watch.ui.home.HomeFragment"
android:label="首页">
<action android:id="@+id/action_home_to_bind"
app:destination="@id/bindFragment"
app:popUpTo="@id/homeFragment" app:popUpToInclusive="true" />
<!-- 首页 → 任务列表 -->
<action android:id="@+id/action_home_to_taskList"
app:destination="@id/taskListFragment" />
<!-- 首页 → 任务详情通知横幅点击1个任务时直接跳详情 -->
<action android:id="@+id/action_home_to_taskDetail"
app:destination="@id/taskDetailFragment" />
</fragment>
<!-- 设备绑定页 -->
<fragment
android:id="@+id/bindFragment"
android:name="com.xiaoqu.watch.ui.bind.BindFragment"
android:label="设备绑定">
<action android:id="@+id/action_bind_to_home"
app:destination="@id/homeFragment"
app:popUpTo="@id/bindFragment" app:popUpToInclusive="true" />
</fragment>
<!-- 任务列表(接收 tableStatus 参数,可选 taskIds 过滤) -->
<fragment
android:id="@+id/taskListFragment"
android:name="com.xiaoqu.watch.ui.task.TaskListFragment"
android:label="任务列表">
<argument android:name="tableStatus" android:defaultValue="2" app:argType="integer" />
<argument android:name="taskIds" android:defaultValue="@null" app:argType="long[]" app:nullable="true" />
<!-- 任务列表 → 任务详情 -->
<action android:id="@+id/action_taskList_to_detail"
app:destination="@id/taskDetailFragment" />
</fragment>
<!-- 任务详情(接收 taskId 参数) -->
<fragment
android:id="@+id/taskDetailFragment"
android:name="com.xiaoqu.watch.ui.task.TaskDetailFragment"
android:label="任务详情">
<argument android:name="taskId" android:defaultValue="0L" app:argType="long" />
</fragment>
<!-- 设备信息 -->
<fragment
android:id="@+id/infoFragment"
android:name="com.xiaoqu.watch.ui.info.InfoFragment"
android:label="设备信息" />
</navigation>