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:
  • Method Details

    • createController

      @Nonnull public static FragmentController createController(@Nonnull FragmentHostCallback<?> callbacks)
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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:
    • 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