Fixed
Status Update
Comments
il...@google.com <il...@google.com>
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #2
Navigation is built with Support Library Fragments so has no access to the FragmentFactory itself. I think we can make some minor changes to FragmentNavigator to make it easy for developers who are using Navigation 1.0 and Fragments 1.1.0 together to call through to their FragmentFactory.
Once Navigation switches to AndroidX (post 1.0), we'll use FragmentFactory directly.
Once Navigation switches to AndroidX (post 1.0), we'll use FragmentFactory directly.
ma...@gmail.com <ma...@gmail.com> #3
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 1b215f0d93828286782776b9a12d2387097947f9
Author: Ian Lake <ilake@google.com>
Date: Sun Nov 25 21:45:56 2018
Move Fragment creation to FragmentNavigator
Provide an instantiateFragment() method on
FragmentNavigator which serves as the
centralized place to instantiate new
Fragment instances for FragmentNavigator.
Besides moving this business logic out of
the dumb POJO FragmentNavigator.Destination,
this also provides a future extension point
for integrating in FragmentFactory.
Test: existing tests passes, testapp still works
BUG: 119054429
Change-Id: If60471a704ef77bc35b30838e152a31cde8bc235
M navigation/fragment/ktx/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilderTest.kt
M navigation/fragment/ktx/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt
M navigation/fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorTest.kt
M navigation/fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java
https://android-review.googlesource.com/835682
https://goto.google.com/android-sha1/1b215f0d93828286782776b9a12d2387097947f9
Branch: androidx-master-dev
commit 1b215f0d93828286782776b9a12d2387097947f9
Author: Ian Lake <ilake@google.com>
Date: Sun Nov 25 21:45:56 2018
Move Fragment creation to FragmentNavigator
Provide an instantiateFragment() method on
FragmentNavigator which serves as the
centralized place to instantiate new
Fragment instances for FragmentNavigator.
Besides moving this business logic out of
the dumb POJO FragmentNavigator.Destination,
this also provides a future extension point
for integrating in FragmentFactory.
Test: existing tests passes, testapp still works
BUG: 119054429
Change-Id: If60471a704ef77bc35b30838e152a31cde8bc235
M navigation/fragment/ktx/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilderTest.kt
M navigation/fragment/ktx/src/main/java/androidx/navigation/fragment/FragmentNavigatorDestinationBuilder.kt
M navigation/fragment/src/androidTest/java/androidx/navigation/fragment/FragmentNavigatorTest.kt
M navigation/fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java
Description
Version used: 1.0.0-alpha09
Devices/Android versions reproduced on: Nexus 5X
Sample: attached
Screen recording: attached
As you can see in the attached sample, I have a simple application with one Activity that has a NavHostFragment and a BottomNavigationView. The navigation graph contains 3 fragment destinations(fragments A, B and C) which are also the menu items for the BottomNavigationView. Fragment C has a drawer layout that contains another NavHostFragment and a NavigationView. This inner NavHostFragment has its own navigation graph with another 3 fragments: D(start destination), E, and F.
Steps to reproduce:
1) Open app
2) Open Fragment C which implicitly opens Fragment D(start destination for that NavHostFragment)
3) From the drawer open Fragment E
4) Click on Fragment B from BottomNavigationView
5) Press back
Observe that Fragment D is opened and that the Fragment B is still the selected item from the BottomNavigationView.
My expected behavior is that the inner NavHostFragment stack is cleared by step 4 and the back button will navigate the user to the start destination of the outer NavHostFragment(Fragment A).
Strange behavior can also be observed if you click on A or C destinations at step 4.
I'm looking forward to your reply.
Thanks!