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 byonGetHost()
.
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 callFragmentManager.addFragmentOnAttachListener(icyllis.modernui.fragment.FragmentOnAttachListener)
from your host in order to receiveFragmentOnAttachListener.onAttachFragment(icyllis.modernui.fragment.FragmentManager, icyllis.modernui.fragment.Fragment)
callbacks for theFragmentController.getFragmentManager()
.OnBackPressedDispatcherOwner
: Removes the need to manually callFragmentManager.popBackStackImmediate()
when handling the system back button.
-
Constructor Summary
-
Method Summary
Modifier and TypeMethodDescriptionvoid
onDump
(String prefix, FileDescriptor fd, PrintWriter writer, String... args) Print internal state into the given stream.onFindViewById
(int id) abstract E
Return the object that's currently hosting the fragment.boolean
-
Constructor Details
-
FragmentHostCallback
-
-
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
Return the object that's currently hosting the fragment. -
onFindViewById
-
onHasView
public boolean onHasView()
-