FragmentScenarioKt

public final class FragmentScenarioKt


Summary

Public methods

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragment(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    FragmentFactory factory
)

This method is deprecated. Superseded by launchFragment that takes an initialState

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragment(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Function0<F> instantiate
)

This method is deprecated. Superseded by launchFragment that takes an initialState

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragment(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Lifecycle.State initialState,
    FragmentFactory factory
)

Launches a Fragment with given arguments hosted by an empty FragmentActivity using given FragmentFactory and waits for it to reach initialState.

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragment(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Lifecycle.State initialState,
    Function0<F> instantiate
)

Launches a Fragment with given arguments hosted by an empty FragmentActivity using instantiate to create the Fragment and waits for it to reach initialState.

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragmentInContainer(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    FragmentFactory factory
)

This method is deprecated. Superseded by launchFragmentInContainer that takes an initialState

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragmentInContainer(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Function0<F> instantiate
)

This method is deprecated. Superseded by launchFragmentInContainer that takes an initialState

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragmentInContainer(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Lifecycle.State initialState,
    FragmentFactory factory
)

Launches a Fragment in the Activity's root view container android.R.id.content, with given arguments hosted by an empty FragmentActivity and waits for it to reach initialState.

static final @NonNull FragmentScenario<@NonNull F>
<F extends Fragment> launchFragmentInContainer(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Lifecycle.State initialState,
    Function0<F> instantiate
)

Launches a Fragment in the Activity's root view container android.R.id.content, with given arguments hosted by an empty FragmentActivity using instantiate to create the Fragment and waits for it to reach initialState.

static final @NonNull T
<F extends Fragment, T extends Object> FragmentScenarioKt.withFragment(
    FragmentScenario<F> receiver,
    @ExtensionFunctionType Function1<F, T> block
)

Run block using FragmentScenario.onFragment, returning the result of the block.

Public methods

launchFragment

public static final @NonNull FragmentScenario<@NonNull F> <F extends Fragment> launchFragment(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    FragmentFactory factory
)

launchFragment

public static final @NonNull FragmentScenario<@NonNull F> <F extends Fragment> launchFragment(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Function0<F> instantiate
)

launchFragment

public static final @NonNull FragmentScenario<@NonNull F> <F extends Fragment> launchFragment(
    Bundle fragmentArgs,
    @StyleRes int themeResId,
    Lifecycle.State initialState,
    FragmentFactory factory
)

Launches a Fragment with given arguments hosted by an empty FragmentActivity using given FragmentFactory and waits for it to reach initialState.

This method cannot be called from the main thread.

Parameters
Bundle fragmentArgs

a bundle to passed into fragment

@StyleRes int themeResId

a style resource id to be set to the host activity's theme

Lifecycle.State initialState

the initial Lifecycle.State. This must be one of Lifecycle.State.CREATED, Lifecycle.State.STARTED, or Lifecycle.State.RESUMED.

FragmentFactory factory

a fragment factory to use or null to use default factory