public abstract class FragmentHostCallback<E> extends FragmentContainer
Fragments may be hosted by any object; such as an Activity
. In order to
host fragments, implement FragmentHostCallback
, overriding the methods
applicable to the host.
Constructor and Description |
---|
FragmentHostCallback(Context context,
Handler handler,
int windowAnimations) |
Modifier and Type | Method and Description |
---|---|
void |
onDump(String prefix,
FileDescriptor fd,
PrintWriter writer,
String[] args)
Print internal state into the given stream.
|
View |
onFindViewById(int id)
Return the view with the given resource ID.
|
abstract E |
onGetHost()
Return the object that's currently hosting the fragment.
|
LayoutInflater |
onGetLayoutInflater()
Return a
LayoutInflater . |
int |
onGetWindowAnimations()
Return the window animations.
|
boolean |
onHasView()
Return
true if the container holds any view. |
boolean |
onHasWindowAnimations()
Return
true if there are window animations. |
void |
onRequestPermissionsFromFragment(Fragment fragment,
String[] permissions,
int requestCode)
Requests permissions from the given fragment.
|
boolean |
onShouldSaveFragmentState(Fragment fragment)
Return
true if the fragment's state needs to be saved. |
boolean |
onShouldShowRequestPermissionRationale(String permission)
Checks whether to show permission rationale UI from a fragment.
|
void |
onStartActivityFromFragment(Fragment fragment,
Intent intent,
int requestCode)
Starts a new
Activity from the given fragment. |
void |
onStartActivityFromFragment(Fragment fragment,
Intent intent,
int requestCode,
Bundle options)
Starts a new
Activity from the given fragment. |
void |
onStartIntentSenderFromFragment(Fragment fragment,
IntentSender intent,
int requestCode,
Intent fillInIntent,
int flagsMask,
int flagsValues,
int extraFlags,
Bundle options)
Starts a new
IntentSender from the given fragment. |
void |
onSupportInvalidateOptionsMenu()
Invalidates the activity's options menu.
|
public void onDump(String prefix, FileDescriptor fd, PrintWriter writer, String[] args)
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.public boolean onShouldSaveFragmentState(Fragment fragment)
true
if the fragment's state needs to be saved.public LayoutInflater onGetLayoutInflater()
LayoutInflater
.
See Activity.getLayoutInflater()
.@Nullable public abstract E onGetHost()
Fragment
is hosted by a FragmentActivity
, the object returned here should be
the same object returned from Fragment.getActivity()
.public void onSupportInvalidateOptionsMenu()
FragmentActivity.supportInvalidateOptionsMenu()
public void onStartActivityFromFragment(Fragment fragment, Intent intent, int requestCode)
Activity
from the given fragment.
See FragmentActivity.startActivityForResult(Intent, int)
.public void onStartActivityFromFragment(Fragment fragment, Intent intent, int requestCode, @Nullable Bundle options)
Activity
from the given fragment.
See BaseFragmentActivityJB.startActivityForResult(Intent, int, Bundle)
.public void onStartIntentSenderFromFragment(Fragment fragment, IntentSender intent, int requestCode, @Nullable Intent fillInIntent, int flagsMask, int flagsValues, int extraFlags, Bundle options) throws IntentSender.SendIntentException
IntentSender
from the given fragment.
See Activity.startIntentSender(IntentSender, Intent, int, int, int, Bundle)
.IntentSender.SendIntentException
public void onRequestPermissionsFromFragment(@NonNull Fragment fragment, @NonNull String[] permissions, int requestCode)
Activity.requestPermissions(String[], int)
public boolean onShouldShowRequestPermissionRationale(@NonNull String permission)
Activity.shouldShowRequestPermissionRationale(String)
public boolean onHasWindowAnimations()
true
if there are window animations.public int onGetWindowAnimations()
@Nullable public View onFindViewById(int id)
FragmentContainer
null
if the
view is not a child of this container.onFindViewById
in class FragmentContainer
public boolean onHasView()
FragmentContainer
true
if the container holds any view.onHasView
in class FragmentContainer