Package icyllis.modernui.fragment

# Class FragmentController

java.lang.Object
icyllis.modernui.fragment.FragmentController

public final class FragmentController extends Object
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.

See Also:
  - `createController(FragmentHostCallback)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `attachHost(Fragment parent)`
  Attaches the host to the FragmentManager for this controller.
  `static FragmentController`
  `createController(FragmentHostCallback<?> callbacks)`
  Returns a `FragmentController`.
  `void`
  `dispatchActivityCreated()`
  Moves all Fragments managed by the controller's FragmentManager into the activity created state.
  `void`
  `dispatchCreate()`
  Moves all Fragments managed by the controller's FragmentManager into the create state.
  `void`
  `dispatchDestroy()`
  Moves Fragments managed by the controller's FragmentManager into the destroy state.
  `void`
  `dispatchDestroyView()`
  Moves all Fragments managed by the controller's FragmentManager into the destroy view state.
  `void`
  `dispatchPause()`
  Moves all Fragments managed by the controller's FragmentManager into the pause state.
  `void`
  `dispatchResume()`
  Moves all Fragments managed by the controller's FragmentManager into the resume state.
  `void`
  `dispatchStart()`
  Moves all Fragments managed by the controller's FragmentManager into the start state.
  `void`
  `dispatchStop()`
  Moves all Fragments managed by the controller's FragmentManager into the stop state.
  `boolean`
  `execPendingActions()`
  Execute any pending actions for the Fragments managed by the controller's FragmentManager.
  `Fragment`
  `findFragmentByWho(String who)`
  Returns a fragment with the given identifier.
  `int`
  `getActiveFragmentCount()`
  Returns the number of active fragments.
  `List<Fragment>`
  `getActiveFragments()`
  Returns the list of active fragments.
  `FragmentManager`
  `getFragmentManager()`
  Returns a `FragmentManager` for this controller.
  `void`
  `noteStateNotSaved()`
  Marks the fragment state as unsaved.

  ### Methods inherited from class java.lang.Object

  `clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait`

- ## Method Details

  - ### createController

    @Nonnull public static FragmentController createController(@Nonnull FragmentHostCallback<?> callbacks)
    Returns a `FragmentController`.

  - ### getFragmentManager

    @Nonnull public FragmentManager getFragmentManager()
    Returns a `FragmentManager` for this controller.

  - ### findFragmentByWho

    @Nullable public Fragment findFragmentByWho(@Nonnull String who)
    Returns a fragment with the given identifier.

  - ### getActiveFragmentCount

    public int getActiveFragmentCount()
    Returns the number of active fragments.

  - ### getActiveFragments

    @Nonnull public List<Fragment> getActiveFragments()
    Returns the list of active fragments.

  - ### attachHost

    public void attachHost(@Nullable Fragment parent)
    Attaches the host to the FragmentManager for this controller. The host must be attached before the FragmentManager can be used to manage Fragments.

  - ### noteStateNotSaved

    public void noteStateNotSaved()
    Marks the fragment state as unsaved. This allows for "state loss" detection.

  - ### dispatchCreate

    public void dispatchCreate()
    Moves all Fragments managed by the controller's FragmentManager into the create state.

    Call when Fragments should be created.

    See Also:
      - `Fragment.onCreate(DataSet)`

  - ### dispatchActivityCreated

    public void dispatchActivityCreated()
    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.

  - ### dispatchStart

    public void dispatchStart()
    Moves all Fragments managed by the controller's FragmentManager into the start state.

    Call when Fragments should be started.

    See Also:
      - `Fragment.onStart()`

  - ### dispatchResume

    public void dispatchResume()
    Moves all Fragments managed by the controller's FragmentManager into the resume state.

    Call when Fragments should be resumed.

    See Also:
      - `Fragment.onResume()`

  - ### dispatchPause

    public void dispatchPause()
    Moves all Fragments managed by the controller's FragmentManager into the pause state.

    Call when Fragments should be paused.

    See Also:
      - `Fragment.onPause()`

  - ### dispatchStop

    public void dispatchStop()
    Moves all Fragments managed by the controller's FragmentManager into the stop state.

    Call when Fragments should be stopped.

    See Also:
      - `Fragment.onStop()`

  - ### dispatchDestroyView

    public void dispatchDestroyView()
    Moves all Fragments managed by the controller's FragmentManager into the destroy view state.

    Call when the Fragment's views should be destroyed.

    See Also:
      - `Fragment.onDestroyView()`

  - ### dispatchDestroy

    public void dispatchDestroy()
    Moves Fragments managed by the controller's FragmentManager into the destroy state.

    If the `FragmentHostCallback` is an instance of `ViewModelStoreOwner`, then retained Fragments and any other non configuration state such as any `ViewModel` attached to Fragments will only be destroyed if `ViewModelStore.clear()` is called prior to this method.

    Call when Fragments should be destroyed.

    See Also:
      - `Fragment.onDestroy()`

  - ### execPendingActions

    public boolean execPendingActions()
    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].

    Returns:
      `true` if queued actions were performed