Package icyllis.modernui.fragment

# Class FragmentHostCallback<E>

java.lang.Object
icyllis.modernui.fragment.FragmentHostCallback<E>

Type Parameters:
  `E` - the type of object that's currently hosting the fragments. An instance of this class must be returned by `onGetHost()`.

public abstract class FragmentHostCallback<E> extends Object
Integration points with the Fragment host.

Fragments may be hosted by any object. In order to host fragments, implement `FragmentHostCallback`, overriding the methods applicable to the host.

FragmentManager changes its behavior based on what optional interfaces your FragmentHostCallback implements. This includes the following:

- `FragmentOnAttachListener`: Removes the need to manually call `FragmentManager.addFragmentOnAttachListener(icyllis.modernui.fragment.FragmentOnAttachListener)` from your host in order to receive `FragmentOnAttachListener.onAttachFragment(icyllis.modernui.fragment.FragmentManager, icyllis.modernui.fragment.Fragment)` callbacks for the `FragmentController.getFragmentManager()`.
- `OnBackPressedDispatcherOwner`: Removes the need to manually call `FragmentManager.popBackStackImmediate()` when handling the system back button.

- ## Constructor Summary

  Constructors
  Constructor
  Description
  `FragmentHostCallback(Context context, Handler handler)`

- ## Method Summary

  Modifier and Type
  Method
  Description
  `void`
  `onDump(String prefix, FileDescriptor fd, PrintWriter writer, String... args)`
  Print internal state into the given stream.
  `View`
  `onFindViewById(int id)`
  `abstract E`
  `onGetHost()`
  Return the object that's currently hosting the fragment.
  `boolean`
  `onHasView()`

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

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

- ## Constructor Details

  - ### FragmentHostCallback

    public FragmentHostCallback(@NonNull Context context, @NonNull Handler handler)

- ## Method Details

  - ### onDump

    public void onDump(@NonNull String prefix, @Nullable FileDescriptor fd, @NonNull PrintWriter writer, @Nullable String... args)
    Print internal state into the given stream.
    Parameters:
      `prefix` - Desired prefix to prepend at each line of output.
      `fd` - The raw file descriptor that the dump is being sent to.
      `writer` - The PrintWriter to which you should dump your state. This will be closed for you after you return.
      `args` - additional arguments to the dump request.

  - ### onGetHost

    @Nullable public abstract E onGetHost()
    Return the object that's currently hosting the fragment.

  - ### onFindViewById

    @Nullable public View onFindViewById(int id)

  - ### onHasView

    public boolean onHasView()