4

When postponing a fragment's enter transition when using Navigation Architecture the "home" fragment in the graph is visible for a microsecond. After googling a bit, the docs tell me to set setReorderingAllowed(true) on the fragmentManager to optimize this flow. However, the docs do not use the Navigation Architecture Component.

Will setReorderingAllowed(true) and how can I achieve it when using Navigation Architecture Component?

Dambakk
  • 595
  • 4
  • 20
  • You can set some properties on NavHostFragment's childFragmentManager. Is that what you need? – Vít Kapitola Aug 24 '20 at 10:23
  • Thanks, but noo, I don't find the setReorderingAllowed method there or in any of its properties. – Dambakk Aug 24 '20 at 10:47
  • 1
    Maybe some kind of hack [like this](https://github.com/android/architecture-components-samples/issues/495#issuecomment-488364003) should help. No other ideas. – Vít Kapitola Aug 24 '20 at 11:14
  • 2
    Thanks! Actually, one of the other comments in that thread helped me! I already had the `postponeEnterTransition` and `startPosponedEnterTransition` calls there, but calling them on the parent fragment fixed my issue! Ref this comment: https://github.com/android/architecture-components-samples/issues/495#issuecomment-530279938 Again, thanks! – Dambakk Aug 24 '20 at 11:54

1 Answers1

2

setReorderingAllowed(true) is set automatically when using naivate(). See FragmentNavigator implementation:

    public NavDestination navigate(@NonNull Destination destination, @Nullable Bundle args,
            @Nullable NavOptions navOptions, @Nullable Navigator.Extras navigatorExtras) {

        // OTHER CODE
        // OTHER CODE

        ft.setReorderingAllowed(true);
        ft.commit();
        // The commit succeeded, update our view of the world
        if (isAdded) {
            mBackStack.add(destId);
            return destination;
        } else {
            return null;
        }
    }
A1m
  • 2,897
  • 2
  • 24
  • 39