Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to set `setReorderingAllowed` when using Navigation Architechture?

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?

like image 975
Dambakk Avatar asked Sep 12 '25 14:09

Dambakk


1 Answers

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;
        }
    }
like image 110
A1m Avatar answered Sep 14 '25 05:09

A1m