F
- a class of the fragment which is under control by this class.public class SupportFragmentController<F extends android.support.v4.app.Fragment> extends ComponentController<SupportFragmentController<F>,F>
FragmentController provides low-level APIs to control fragment’s lifecycle.
Using FragmentController directly from your tests is strongly discouraged. You have to call all the lifecycle callback methods (create, start, …) in the same manner as the Android framework by yourself otherwise you’ll see fidelity issues. Consider using androidx.fragment.app.testing.FragmentScenario
instead, which provides higher-level, streamlined APIs to control the lifecycle and it works with instrumentation tests too.
attached, component, intent, myself, shadowMainLooper
Modifier | Constructor and Description |
---|---|
protected |
SupportFragmentController(F fragment,
Class<? extends android.support.v4.app.FragmentActivity> activityClass) |
protected |
SupportFragmentController(F fragment,
Class<? extends android.support.v4.app.FragmentActivity> activityClass,
Intent intent) |
Modifier and Type | Method and Description |
---|---|
SupportFragmentController<F> |
create() |
SupportFragmentController<F> |
create(Bundle bundle)
Creates the activity with
Bundle and adds the fragment to it. |
SupportFragmentController<F> |
create(int contentViewId,
Bundle bundle)
Creates the activity with
Bundle and adds the fragment to the view with ID contentViewId . |
SupportFragmentController<F> |
destroy() |
static <F extends android.support.v4.app.Fragment> |
of(F fragment) |
static <F extends android.support.v4.app.Fragment> |
of(F fragment,
Class<? extends android.support.v4.app.FragmentActivity> activityClass) |
static <F extends android.support.v4.app.Fragment> |
of(F fragment,
Class<? extends android.support.v4.app.FragmentActivity> activityClass,
Intent intent) |
SupportFragmentController<F> |
pause() |
SupportFragmentController<F> |
postCreate(Bundle bundle) |
SupportFragmentController<F> |
resume() |
SupportFragmentController<F> |
saveInstanceState(Bundle outState) |
static <F extends android.support.v4.app.Fragment> |
setupFragment(F fragment)
Sets up the given fragment by attaching it to an activity, calling its onCreate() through onResume() lifecycle methods, and then making it visible.
|
static <F extends android.support.v4.app.Fragment> |
setupFragment(F fragment,
Class<? extends android.support.v4.app.FragmentActivity> fragmentActivityClass)
Sets up the given fragment by attaching it to an activity, calling its onCreate() through onResume() lifecycle methods, and then making it visible.
|
static <F extends android.support.v4.app.Fragment> |
setupFragment(F fragment,
Class<? extends android.support.v4.app.FragmentActivity> fragmentActivityClass,
Bundle bundle)
Sets up the given fragment by attaching it to an activity created with the given bundle, calling its onCreate() through onResume() lifecycle methods, and then making it visible.
|
static <F extends android.support.v4.app.Fragment> |
setupFragment(F fragment,
Class<? extends android.support.v4.app.FragmentActivity> fragmentActivityClass,
int containerViewId,
Bundle bundle)
Sets up the given fragment by attaching it to an activity created with the given bundle and container id, calling its onCreate() through onResume() lifecycle methods, and then making it visible.
|
SupportFragmentController<F> |
start() |
SupportFragmentController<F> |
stop() |
SupportFragmentController<F> |
visible() |
get, getIntent, invokeWhilePaused
protected SupportFragmentController(F fragment, Class<? extends android.support.v4.app.FragmentActivity> activityClass)
protected SupportFragmentController(F fragment, Class<? extends android.support.v4.app.FragmentActivity> activityClass, Intent intent)
public static <F extends android.support.v4.app.Fragment> SupportFragmentController<F> of(F fragment)
public static <F extends android.support.v4.app.Fragment> SupportFragmentController<F> of(F fragment, Class<? extends android.support.v4.app.FragmentActivity> activityClass)
public static <F extends android.support.v4.app.Fragment> SupportFragmentController<F> of(F fragment, Class<? extends android.support.v4.app.FragmentActivity> activityClass, Intent intent)
public static <F extends android.support.v4.app.Fragment> F setupFragment(F fragment)
Sets up the given fragment by attaching it to an activity, calling its onCreate() through onResume() lifecycle methods, and then making it visible. Note that the fragment will be added to the view with ID 1.
public static <F extends android.support.v4.app.Fragment> F setupFragment(F fragment, Class<? extends android.support.v4.app.FragmentActivity> fragmentActivityClass)
Sets up the given fragment by attaching it to an activity, calling its onCreate() through onResume() lifecycle methods, and then making it visible. Note that the fragment will be added to the view with ID 1.
public static <F extends android.support.v4.app.Fragment> F setupFragment(F fragment, Class<? extends android.support.v4.app.FragmentActivity> fragmentActivityClass, Bundle bundle)
Sets up the given fragment by attaching it to an activity created with the given bundle, calling its onCreate() through onResume() lifecycle methods, and then making it visible. Note that the fragment will be added to the view with ID 1.
public static <F extends android.support.v4.app.Fragment> F setupFragment(F fragment, Class<? extends android.support.v4.app.FragmentActivity> fragmentActivityClass, int containerViewId, Bundle bundle)
Sets up the given fragment by attaching it to an activity created with the given bundle and container id, calling its onCreate() through onResume() lifecycle methods, and then making it visible.
public SupportFragmentController<F> create(int contentViewId, Bundle bundle)
Creates the activity with Bundle
and adds the fragment to the view with ID contentViewId
.
public SupportFragmentController<F> create(Bundle bundle)
Creates the activity with Bundle
and adds the fragment to it. Note that the fragment will be added to the view with ID 1.
public SupportFragmentController<F> create()
create
in class ComponentController<SupportFragmentController<F extends android.support.v4.app.Fragment>,F extends android.support.v4.app.Fragment>
public SupportFragmentController<F> postCreate(Bundle bundle)
public SupportFragmentController<F> destroy()
destroy
in class ComponentController<SupportFragmentController<F extends android.support.v4.app.Fragment>,F extends android.support.v4.app.Fragment>
public SupportFragmentController<F> start()
public SupportFragmentController<F> resume()
public SupportFragmentController<F> pause()
public SupportFragmentController<F> stop()
public SupportFragmentController<F> visible()
public SupportFragmentController<F> saveInstanceState(Bundle outState)