FragmentScenarioKt
public final class FragmentScenarioKt
Summary
Public methods |
|
|---|---|
static final @NonNull FragmentScenario<@NonNull F> |
<F extends Fragment> launchFragment(Launches a Fragment with given arguments hosted by an empty |
static final @NonNull FragmentScenario<@NonNull F> |
<F extends Fragment> launchFragment(Launches a Fragment with given arguments hosted by an empty |
static final @NonNull FragmentScenario<@NonNull F> |
<F extends Fragment> launchFragmentInContainer(Launches a Fragment in the Activity's root view container |
static final @NonNull FragmentScenario<@NonNull F> |
<F extends Fragment> launchFragmentInContainer(Launches a Fragment in the Activity's root view container |
static final @NonNull T |
<F extends Fragment, T extends Object> withFragment(Run |
Public methods
launchFragment
public static final @NonNull FragmentScenario<@NonNull F> <F extends Fragment> launchFragment(
Bundle fragmentArgs,
@StyleRes int themeResId,
@NonNull 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 |
@NonNull Lifecycle.State initialState |
the initial |
FragmentFactory factory |
a fragment factory to use or null to use default factory |
launchFragment
public static final @NonNull FragmentScenario<@NonNull F> <F extends Fragment> launchFragment(
Bundle fragmentArgs,
@StyleRes int themeResId,
@NonNull Lifecycle.State initialState,
@NonNull Function0<@NonNull 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.
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 |
@NonNull Lifecycle.State initialState |
the initial |
@NonNull Function0<@NonNull F> instantiate |
method which will be used to instantiate the Fragment. |
launchFragmentInContainer
public static final @NonNull FragmentScenario<@NonNull F> <F extends Fragment> launchFragmentInContainer(
Bundle fragmentArgs,
@StyleRes int themeResId,
@NonNull 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.
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 |
@NonNull Lifecycle.State initialState |
the initial |
FragmentFactory factory |
a fragment factory to use or null to use default factory |
launchFragmentInContainer
public static final @NonNull FragmentScenario<@NonNull F> <F extends Fragment> launchFragmentInContainer(
Bundle fragmentArgs,
@StyleRes int themeResId,
@NonNull Lifecycle.State initialState,
@NonNull Function0<@NonNull 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.
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 |
@NonNull Lifecycle.State initialState |
the initial |
@NonNull Function0<@NonNull F> instantiate |
method which will be used to instantiate the Fragment. This is a simplification of the |
withFragment
public static final @NonNull T <F extends Fragment, T extends Object> withFragment(
@NonNull FragmentScenario<@NonNull F> receiver,
@NonNull Function1<@NonNull F, @NonNull T> block
)
Run block using FragmentScenario.onFragment, returning the result of the block.
If any exceptions are raised while running block, they are rethrown.