FragmentController

open class FragmentController
kotlin.Any
   ↳ androidx.fragment.app.FragmentController

Provides integration points with a FragmentManager for a fragment host.

It is the responsibility of the host to take care of the Fragment's lifecycle. The methods provided by FragmentController are for that purpose.

Summary

Public methods
open Unit

Moves all Fragments managed by the controller's FragmentManager into the create state.

open Unit

Starts the loaders.

open Unit

Lets all Fragments managed by the controller's FragmentManager know the multi-window mode of the activity changed.

open Fragment?

Returns a fragment with the given identifier.

open Boolean

Sends an option item selection event to the Fragments managed by the controller's FragmentManager.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the stop state.

open MutableList<Fragment!>!

Returns the list of active fragments.

open Parcelable!

Saves the state for all Fragments.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the activity created state.

open MutableList<Fragment!>!

Returns a list of Fragments that have opted to retain their instance across configuration changes.

open Unit

Lets all Fragments managed by the controller's FragmentManager know their options menu has closed.

open Unit
dispatchPictureInPictureModeChanged(isInPictureInPictureMode: Boolean)

Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture mode of the activity changed.

open Unit
dumpLoaders(prefix: String!, fd: FileDescriptor!, writer: PrintWriter!, args: Array<String!>!)

Dumps the current state of the loaders.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the start state.

open Unit

Lets all Fragments managed by the controller's FragmentManager know a configuration change occurred.

open Boolean

Execute any pending actions for the Fragments managed by the controller's FragmentManager.

open Unit

Stops the loaders, optionally retaining their state.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the resume state.

open Unit
restoreLoaderNonConfig(loaderManagers: SimpleArrayMap!)

Restores the saved state for all LoaderManagers.

open Boolean

Lets all Fragments managed by the controller's FragmentManager know they should prepare their options menu for display.

open View!
onCreateView(parent: View!, name: String!, context: Context!, attrs: AttributeSet!)

Instantiates a Fragment's view.

open Int

Returns the number of active fragments.

open Unit

Lets all Fragments managed by the controller's FragmentManager know the device is in a low memory condition.

open SimpleArrayMap!

Returns a list of LoaderManagers that have opted to retain their instance across configuration changes.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the pause state.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the destroy view state.

open Unit

Moves all Fragments managed by the controller's FragmentManager into the destroy state.

open LoaderManager!

Returns a LoaderManager.

open FragmentManagerNonConfig!

Returns a nested tree of Fragments that have opted to retain their instance across configuration changes.

open Unit

Retains the state of each of the loaders.

open Boolean

Lets all Fragments managed by the controller's FragmentManager know they should create an options menu.

open Unit

open Unit

Lets the loaders know the host is ready to receive notifications.

open Unit
restoreAllState(state: Parcelable!, nonConfigList: MutableList<Fragment!>!)

Restores the saved state for all Fragments.

open Unit

Restores the saved state for all Fragments.

open FragmentManager!

Returns a FragmentManager for this controller.

open Unit
attachHost(parent: Fragment!)

Attaches the host to the FragmentManager for this controller.

open Unit

Destroys the loaders and, if their state is not being retained, removes them.

open Unit

Marks the fragment state as unsaved.

open Boolean

Sends a context item selection event to the Fragments managed by the controller's FragmentManager.

open static FragmentController!

Returns a FragmentController.

Public methods

dispatchCreate

open fun dispatchCreate(): Unit

Moves all Fragments managed by the controller's FragmentManager into the create state.

Call when Fragments should be created.

See Also

  • Fragment#onCreate(Bundle)

doLoaderStart

open fun doLoaderStart(): Unit

Starts the loaders.

dispatchMultiWindowModeChanged

open fun dispatchMultiWindowModeChanged(isInMultiWindowMode: Boolean): Unit

Lets all Fragments managed by the controller's FragmentManager know the multi-window mode of the activity changed.

Call when the multi-window mode of the activity changed.

findFragmentByWho

open fun findFragmentByWho(who: String!): Fragment?

Returns a fragment with the given identifier.

dispatchOptionsItemSelected

open fun dispatchOptionsItemSelected(item: MenuItem!): Boolean

Sends an option item selection event to the Fragments managed by the controller's FragmentManager. Once the event has been consumed, no additional handling will be performed.

Call immediately after an options menu item has been selected

Return
Boolean: true if the options menu selection event was consumed

dispatchStop

open fun dispatchStop(): Unit

Moves all Fragments managed by the controller's FragmentManager into the stop state.

Call when Fragments should be stopped.

getActiveFragments

open fun getActiveFragments(actives: MutableList<Fragment!>!): MutableList<Fragment!>!

Returns the list of active fragments.

saveAllState

open fun saveAllState(): Parcelable!

Saves the state for all Fragments.

dispatchActivityCreated

open fun dispatchActivityCreated(): Unit

Moves all Fragments managed by the controller's FragmentManager into the activity created state.

Call when Fragments should be informed their host has been created.

See Also

  • Fragment#onActivityCreated(Bundle)

retainNonConfig

open fun retainNonConfig(): MutableList<Fragment!>!

Returns a list of Fragments that have opted to retain their instance across configuration changes.

dispatchOptionsMenuClosed

open fun dispatchOptionsMenuClosed(menu: Menu!): Unit

Lets all Fragments managed by the controller's FragmentManager know their options menu has closed.

Call immediately after closing the Fragment's options menu.

dispatchPictureInPictureModeChanged

open fun dispatchPictureInPictureModeChanged(isInPictureInPictureMode: Boolean): Unit

Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture mode of the activity changed.

Call when the picture-in-picture mode of the activity changed.

dumpLoaders

open fun dumpLoaders(prefix: String!, fd: FileDescriptor!, writer: PrintWriter!, args: Array<String!>!): Unit

Dumps the current state of the loaders.

dispatchStart

open fun dispatchStart(): Unit

Moves all Fragments managed by the controller's FragmentManager into the start state.

Call when Fragments should be started.

dispatchConfigurationChanged

open fun dispatchConfigurationChanged(newConfig: Configuration!): Unit

Lets all Fragments managed by the controller's FragmentManager know a configuration change occurred.

Call when there is a configuration change.

execPendingActions

open fun execPendingActions(): Boolean

Execute any pending actions for the Fragments managed by the controller's FragmentManager.

Call when queued actions can be performed [eg when the Fragment moves into a start or resume state].

Return
Boolean: true if queued actions were performed

doLoaderStop

open fun doLoaderStop(retain: Boolean): Unit

Stops the loaders, optionally retaining their state. This is useful for keeping the loader state across configuration changes.

Parameters
retain Boolean: When true, the loaders aren't stopped, but, their instances are retained in a started state

dispatchResume

open fun dispatchResume(): Unit

Moves all Fragments managed by the controller's FragmentManager into the resume state.

Call when Fragments should be resumed.

restoreLoaderNonConfig

open fun restoreLoaderNonConfig(loaderManagers: SimpleArrayMap!): Unit

Restores the saved state for all LoaderManagers. The given LoaderManager list are LoaderManager instances retained across configuration changes.

dispatchPrepareOptionsMenu

open fun dispatchPrepareOptionsMenu(menu: Menu!): Boolean

Lets all Fragments managed by the controller's FragmentManager know they should prepare their options menu for display.

Call immediately before displaying the Fragment's options menu.

Return
Boolean: true if the options menu contains items to display

onCreateView

open fun onCreateView(parent: View!, name: String!, context: Context!, attrs: AttributeSet!): View!

Instantiates a Fragment's view.

Parameters
parent View!: The parent that the created view will be placed in; note that this may be null.
name View!: Tag name to be inflated.
context View!: The context the view is being created in.
attrs View!: Inflation attributes as specified in XML file.
Return
View!: view the newly created view

getActiveFragmentsCount

open fun getActiveFragmentsCount(): Int

Returns the number of active fragments.

dispatchLowMemory

open fun dispatchLowMemory(): Unit

Lets all Fragments managed by the controller's FragmentManager know the device is in a low memory condition.

Call when the device is low on memory and Fragment's should trim their memory usage.

retainLoaderNonConfig

open fun retainLoaderNonConfig(): SimpleArrayMap!

Returns a list of LoaderManagers that have opted to retain their instance across configuration changes.

dispatchPause

open fun dispatchPause(): Unit

Moves all Fragments managed by the controller's FragmentManager into the pause state.

Call when Fragments should be paused.

dispatchDestroyView

open fun dispatchDestroyView(): Unit

Moves all Fragments managed by the controller's FragmentManager into the destroy view state.

Call when the Fragment's views should be destroyed.

dispatchDestroy

open fun dispatchDestroy(): Unit

Moves all Fragments managed by the controller's FragmentManager into the destroy state.

Call when Fragments should be destroyed.

getSupportLoaderManager

open fun getSupportLoaderManager(): LoaderManager!

Returns a LoaderManager.

See Also

  • LoaderManager#getInstance

retainNestedNonConfig

open fun retainNestedNonConfig(): FragmentManagerNonConfig!

Returns a nested tree of Fragments that have opted to retain their instance across configuration changes.

doLoaderRetain

open fun doLoaderRetain(): Unit

Retains the state of each of the loaders.

dispatchCreateOptionsMenu

open fun dispatchCreateOptionsMenu(menu: Menu!, inflater: MenuInflater!): Boolean

Lets all Fragments managed by the controller's FragmentManager know they should create an options menu.

Call when the Fragment should create an options menu.

Return
Boolean: true if the options menu contains items to display

dispatchReallyStop

open fun dispatchReallyStop(): Unit

reportLoaderStart

open fun reportLoaderStart(): Unit

Lets the loaders know the host is ready to receive notifications.

restoreAllState

open fun restoreAllState(state: Parcelable!, nonConfigList: MutableList<Fragment!>!): Unit

Restores the saved state for all Fragments. The given Fragment list are Fragment instances retained across configuration changes.

restoreAllState

open fun restoreAllState(state: Parcelable!, nonConfig: FragmentManagerNonConfig!): Unit

Restores the saved state for all Fragments. The given FragmentManagerNonConfig are Fragment instances retained across configuration changes, including nested fragments

getSupportFragmentManager

open fun getSupportFragmentManager(): FragmentManager!

Returns a FragmentManager for this controller.

attachHost

open fun attachHost(parent: Fragment!): Unit

Attaches the host to the FragmentManager for this controller. The host must be attached before the FragmentManager can be used to manage Fragments.

doLoaderDestroy

open fun doLoaderDestroy(): Unit

Destroys the loaders and, if their state is not being retained, removes them.

noteStateNotSaved

open fun noteStateNotSaved(): Unit

Marks the fragment state as unsaved. This allows for "state loss" detection.

dispatchContextItemSelected

open fun dispatchContextItemSelected(item: MenuItem!): Boolean

Sends a context item selection event to the Fragments managed by the controller's FragmentManager. Once the event has been consumed, no additional handling will be performed.

Call immediately after an options menu item has been selected

Return
Boolean: true if the context menu selection event was consumed

createController

open static fun createController(callbacks: FragmentHostCallback<*>!): FragmentController!

Returns a FragmentController.