In our user requirement we have a flow like this.
I have searched the following:
https://developer.android.com/guide/navigation/navigation-principles
Circular Reference with Nested Nav Graphs
But nothing can help...
What I have done?
Currently I split 2 graph and add duplicate Fragment C in Graph2. Also, I change the graph start destination to Fragment C in graph 1 programmatically only I clicked from graph2. This is an ugly solution But I have no idea how to solve this issue.
My question is : Is there any way to do it rather making a duplicate destination and changing the start destination?
Graph 1:
<include app:graph="@navigation/graph2" />
<dialog
android:id="@+id/fragmentA"
android:label="Fragment A"
tools:layout="@layout/fragmentA"/>
<dialog
android:id="@+id/fragmentB"
android:label="Fragment B"
tools:layout="@layout/fragmentB">
<action
android:id="@+id/NavigateToGraph2"
app:destination="@id/graph2">
</dialog>
<dialog
android:id="@+id/fragmentC"
android:label="Fragment C"
tools:layout="@layout/fragmentC"/>
<dialog
android:id="@+id/fragmentD"
android:label="Fragment D"
tools:layout="@layout/fragmentD"/>
<dialog
android:id="@+id/fragmentE"
android:label="Fragment E"
tools:layout="@layout/fragmentE"/>
Graph 2
<dialog
android:id="@+id/fragmentF"
android:label="Fragment F"
tools:layout="@layout/fragmentF"/>
<dialog
android:id="@+id/fragmentG"
android:label="Fragment G"
tools:layout="@layout/fragmentG"/>
<dialog
android:id="@+id/fragmentC"
android:label="Fragment C"
tools:layout="@layout/fragmentC"/>
from Android Navigation Component: How to solve the circular navigation with nested graph?
No comments:
Post a Comment