Fixed
Status Update
Comments
il...@google.com <il...@google.com>
il...@google.com <il...@google.com>
ap...@google.com <ap...@google.com> #2
Project: platform/frameworks/support
Branch: androidx-master-dev
commit 88fc53038eb76bea8e2b040f84d14919f02941d7
Author: Ian Lake <ilake@google.com>
Date: Fri Feb 01 14:25:13 2019
Add documentation around FragmentNavigation + primary nav
Provide more clear guidance and documentation around
the interactions between FragmentNavigator behavior and
the FragmentManager's primary navigation Fragment,
specifically calling out that the currently displayed
Fragment should be available through the
getPrimaryNavigationFragment() API, but that operations
can (and will, by default) be asynchronous.
Test: docs only
BUG: 119800853
Change-Id: I594461ae5c7203f3f47b2278ea611688a93e9c74
M navigation/fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java
https://android-review.googlesource.com/892740
https://goto.google.com/android-sha1/88fc53038eb76bea8e2b040f84d14919f02941d7
Branch: androidx-master-dev
commit 88fc53038eb76bea8e2b040f84d14919f02941d7
Author: Ian Lake <ilake@google.com>
Date: Fri Feb 01 14:25:13 2019
Add documentation around FragmentNavigation + primary nav
Provide more clear guidance and documentation around
the interactions between FragmentNavigator behavior and
the FragmentManager's primary navigation Fragment,
specifically calling out that the currently displayed
Fragment should be available through the
getPrimaryNavigationFragment() API, but that operations
can (and will, by default) be asynchronous.
Test: docs only
BUG: 119800853
Change-Id: I594461ae5c7203f3f47b2278ea611688a93e9c74
M navigation/fragment/src/main/java/androidx/navigation/fragment/FragmentNavigator.java
il...@google.com <il...@google.com> #3
We've decided to be more explicit in our documentation that getting the current Fragment from getPrimaryNavigationFragment() is indeed the supported pattern, rather than offer an explicit API for this functionality as part of Navigation.
[Deleted User] <[Deleted User]> #4
Great ! Thanks for that !
dd...@gmail.com <dd...@gmail.com> #5
Hi,
Where i can find this info?
any links?
Thanks
Where i can find this info?
any links?
Thanks
il...@google.com <il...@google.com> #7
The current Fragment from FragmentNavigator's perspective can be retrieved by calling
with the FragmentManager passed to this FragmentNavigator. FragmentManager.getPrimaryNavigationFragment()
Note that the default implementation does Fragment transactions asynchronously, so the current Fragment will not be available immediately (i.e., in callbacks to
NavController.OnDestinationChangedListener
).
mr...@gmail.com <mr...@gmail.com> #8
It doesn't work when used in navController.addOnDestinationChangedListener....
Being able to set a simple tag in nav graph, or just some api call to get the current fragment and some kind of name, tag is knowere to be found.
Also you should keep in mind obfuscation.
Being able to set a simple tag in nav graph, or just some api call to get the current fragment and some kind of name, tag is knowere to be found.
Also you should keep in mind obfuscation.
co...@gmail.com <co...@gmail.com> #9
Isn't it a bit overreaching to expect that whatever Fragment the "current Fragment" is has a List in it that can be scrolled to the top? Wouldn't a scrollToTop mechanism that necessitates a certain type of Fragment to be (previously) focused be better delivered with an Activity callback or eventbus pattern?
What is the "current Fragment" if not the primaryNavigationFragment when multiple Fragments exist on the screen at the same time? What if I want to navigate within a nested Fragment? So at the very least if a change is to be made here it would need to "provide an easy way to access currently displayed fragments" (plural fragments)
Also if there are problems with the state of the Fragment when using getPrimaryNavigationFragment, using FragmentManager.FragmentLifecycleCallbacks would seem a better fit, no?
What is the "current Fragment" if not the primaryNavigationFragment when multiple Fragments exist on the screen at the same time? What if I want to navigate within a nested Fragment? So at the very least if a change is to be made here it would need to "provide an easy way to access currently displayed fragments" (plural fragments)
Also if there are problems with the state of the Fragment when using getPrimaryNavigationFragment, using FragmentManager.FragmentLifecycleCallbacks would seem a better fit, no?
Description
Version used: 1.0.0-alpha07
It would be great if we can have an easy way to access the currently displayed fragment. As far as I know today the only way to get it is to access to primaryNavigationFragment from the navigation fragment's childFragmentManager.
A common use case is when you have a bottom navigation and on item resselected you want to scroll on top of your list. Youtube and many apps using bottom navigation implement a scrollToTop function.
Code required to do it with primaryNavigationFragment isn't complex or ugly, but there is no documentation neither about that on
I'm afraid this "hack" could stop working after a navigation component lib update.
So if it's not relevant in an api perspective to have a method for that, could we have a status/documentation about the primaryNavigationFragment usage ?