Issue
I'm using Navigation Component to navigate in my app. I'm working with tree structure and I'm navigating users node by node -> Node == NodeFragment
. But now I'm struggling with back navigation to particular node.
E.g.: Image navigation stack with look like this A -> B -> C -> D
when user wants to navigate from node D
directly to node B
I want to popup fragment C, D
and go directly to B
?
E.g.: You can imagine something like navigating trough folder structure where you are navigation the same fragment again and again. And then you want to go back to particular folder which is not parent of the current one.
But I don't know ho to achieve it with Navigation Component. For navigation I'm using self action. Thanks in advance.
<fragment
android:id="@+id/nodeFragment"
android:name="com.example.NodeFragment">
<action
android:id="@+id/action_chatbotBuilderChildrenFragment_self2"
app:destination="@id/nodeFragment" />
</fragment>
Solution
So I found some kind of workaround solution which is pretty simple. It seems that calling NavController.navigateUp()
multiple times in sort period of time works just fine. I'm not sure if this is the right solution but it solves my issues.
I was also supprise that even my fragment transition wasn't break after call NavController.navigateUp()
multiple times.
Code example:
repeat(numberOfPopUps) {
findNavController().navigateUp()
}
Answered By - Jan Maděra
0 comments:
Post a Comment
Note: Only a member of this blog may post a comment.