Fixed
Status Update
Comments
so...@gmail.com <so...@gmail.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit bade7af890d31f0f4a4b094ff1fd475b24fff95c
Author: jbwoods <jbwoods@google.com>
Date: Mon Feb 25 15:49:05 2019
Fix typo in ActivityNavigator
Both popEnterAnim and popExitAnim were getting the intent extra intended
for popEnterAnim in the applyPopAnimationsToPendingTransition method. Made
popExitAnim get the proper extra.
Test: ran nav test app
BUG: 126237567
Change-Id: Iecdcdd62695f66e1a66eeb5ec84df09c1faaff24
M navigation/runtime/src/main/java/androidx/navigation/ActivityNavigator.java
https://android-review.googlesource.com/912259
https://goto.google.com/android-sha1/bade7af890d31f0f4a4b094ff1fd475b24fff95c
Branch: androidx-master-dev
commit bade7af890d31f0f4a4b094ff1fd475b24fff95c
Author: jbwoods <jbwoods@google.com>
Date: Mon Feb 25 15:49:05 2019
Fix typo in ActivityNavigator
Both popEnterAnim and popExitAnim were getting the intent extra intended
for popEnterAnim in the applyPopAnimationsToPendingTransition method. Made
popExitAnim get the proper extra.
Test: ran nav test app
BUG: 126237567
Change-Id: Iecdcdd62695f66e1a66eeb5ec84df09c1faaff24
M navigation/runtime/src/main/java/androidx/navigation/ActivityNavigator.java
il...@google.com <il...@google.com> #3
Fixed for Navigation 1.0.0-rc02
il...@google.com <il...@google.com>
il...@google.com <il...@google.com> #4
This allows you to solve your problem by:
- Adding your Toolbar to Fragment B
- Call:
toolbar.setupWithNavController(innerNavController, AppBarConfiguration(setOf()) {
findNavController().navigateUp()
})
By using an empty set of top level destinations, the Up button will always appear. When the innerNavController is on its own start destination, the fallback will be called, allowing you to pass the navigateUp() call to the outer NavController. The reason the Toolbar in your FragmentB is the right place to do this is so that it has a reference to both your inner NavController and a reference to your outer NavController.
This will be available in 1.0.0-alpha09.
See also the related issue for activities:
ka...@gmail.com <ka...@gmail.com> #5
Re #4 - In my use case I have single activity and single (global) toolbar setup with it. So it doesn't make sense for my application to add additional toolbar for my nested fragments. I just want to work them with existing activity's toolbar. I would like to use nested fragments to use ViewModels shared with parentFragment. Can you consider supporting my use case?
Description
Version used: 1.0.0-alpha08
Devices/Android versions reproduced on:
Assuming:
- Main Activity has a NavHostFragment, which navigates between Fragment A & Fragment B
- Main activity handles going back with onSupportNavigateUp
- Fragment B has it's own NavHostFragment, which navigated between InnerFragmentB1 & InnerFragmentB2
- Parent NavHostFragment navigates from A -> B (which starts with B1)
- Sub NavHostFragment navigates from B1 -> B2
- Press up: Sub NavHostFragment returns to B1
- Press up: Parent NavHostFragment returns from B to A
What's the proper way of handling these types of situations where we'd like the back button to handle backing out of Inner Fragments first and then Outer Fragments after?
Details here:
Sample Code: