DynamicFragmentNavigator

public final class DynamicFragmentNavigator extends Navigator, FragmentNavigator

Object
   ↳ Navigator
     ↳ FragmentNavigator
       ↳ DynamicFragmentNavigator

The Navigator that enables navigating to destinations within dynamic feature modules.

Summary

Nested types

DynamicFragmentNavigator.Destination

Destination for dynamic feature navigator.

Public fields

final boolean

Whether this Navigator is actively being used by a NavController.

Public constructors

DynamicFragmentNavigator(
    @NonNull Context context,
    @NonNull FragmentManager manager,
    int containerId,
    @NonNull DynamicInstallManager installManager
)

Public methods

@NonNull DynamicFragmentNavigator.Destination

Construct a new NavDestination associated with this Navigator.

void
navigate(
    @NonNull List<@NonNull NavBackStackEntry> entries,
    @Nullable NavOptions navOptions,
    @Nullable Navigator.Extras navigatorExtras
)

{@inheritDoc}

Inherited methods

From class FragmentNavigator
@NonNull Fragment
instantiateFragment(
    @NonNull Context context,
    @NonNull FragmentManager fragmentManager,
    @NonNull String className,
    @Nullable Bundle args
)

This method is deprecated. Set a custom {@link androidx.fragment.app.FragmentFactory} via {@link FragmentManager#setFragmentFactory(FragmentFactory)} to control instantiation of Fragments.

void

Restore any state previously saved in onSaveState.

@Nullable Bundle

Called to ask for a Bundle representing the Navigator's state.

void
popBackStack(@NonNull NavBackStackEntry popUpTo, boolean savedState)

{@inheritDoc}

From class Navigator
@Nullable NavDestination
navigate(
    @NonNull FragmentNavigator.Destination destination,
    @Nullable Bundle args,
    @Nullable NavOptions navOptions,
    @Nullable Navigator.Extras navigatorExtras
)

Navigate to a destination.

@CallSuper void

Indicator that this Navigator is actively being used by a NavController.

void

Informational callback indicating that the given backStackEntry has been affected by a NavOptions.shouldLaunchSingleTop operation.

boolean

Attempt to pop this navigator's back stack, performing the appropriate navigation.

Public fields

isAttached

@NonNull
public final boolean isAttached

Whether this Navigator is actively being used by a NavController.

This is set to true when onAttach is called.

Public constructors

DynamicFragmentNavigator

public final DynamicFragmentNavigator(
    @NonNull Context context,
    @NonNull FragmentManager manager,
    int containerId,
    @NonNull DynamicInstallManager installManager
)

Public methods

createDestination

@NonNull
public DynamicFragmentNavigator.Destination createDestination()

Construct a new NavDestination associated with this Navigator.

Any initialization of the destination should be done in the destination's constructor as it is not guaranteed that every destination will be created through this method.

Returns
DynamicFragmentNavigator.Destination

a new NavDestination

@NonNull
public void navigate(
    @NonNull List<@NonNull NavBackStackEntry> entries,
    @Nullable NavOptions navOptions,
    @Nullable Navigator.Extras navigatorExtras
)

{@inheritDoc}

This method should always call FragmentTransaction.setPrimaryNavigationFragment so that the Fragment associated with the new destination can be retrieved with FragmentManager.getPrimaryNavigationFragment.

Note that the default implementation commits the new Fragment asynchronously, so the new Fragment is not instantly available after this call completes.