java.lang.Object
↳androidx.fragment.app.FragmentController
Gradle dependencies
compile group: 'androidx.fragment', name: 'fragment', version: '1.8.3'
- groupId: androidx.fragment
- artifactId: fragment
- version: 1.8.3
Artifact androidx.fragment:fragment:1.8.3 it located at Google repository (https://maven.google.com/)
Androidx artifact mapping:
androidx.fragment:fragment com.android.support:support-fragment
Androidx class mapping:
androidx.fragment.app.FragmentController android.support.v4.app.FragmentController
Overview
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.
Summary
Methods |
---|
public void | attachHost(Fragment parent)
Attaches the host to the FragmentManager for this controller. |
public static FragmentController | createController(FragmentHostCallback<java.lang.Object> callbacks)
Returns a FragmentController. |
public void | dispatchActivityCreated()
Moves all Fragments managed by the controller's FragmentManager
into the activity created state. |
public void | dispatchConfigurationChanged(Configuration newConfig)
Lets all Fragments managed by the controller's FragmentManager
know a configuration change occurred. |
public boolean | dispatchContextItemSelected(MenuItem item)
Sends a context item selection event to the Fragments managed by the
controller's FragmentManager. |
public void | dispatchCreate()
Moves all Fragments managed by the controller's FragmentManager
into the create state. |
public boolean | dispatchCreateOptionsMenu(Menu menu, MenuInflater inflater)
Lets all Fragments managed by the controller's FragmentManager
know they should create an options menu. |
public void | dispatchDestroy()
Moves Fragments managed by the controller's FragmentManager
into the destroy state. |
public void | dispatchDestroyView()
Moves all Fragments managed by the controller's FragmentManager
into the destroy view state. |
public void | dispatchLowMemory()
Lets all Fragments managed by the controller's FragmentManager
know the device is in a low memory condition. |
public void | dispatchMultiWindowModeChanged(boolean isInMultiWindowMode)
Lets all Fragments managed by the controller's FragmentManager know the multi-window mode of
the activity changed. |
public boolean | dispatchOptionsItemSelected(MenuItem item)
Sends an option item selection event to the Fragments managed by the
controller's FragmentManager. |
public void | dispatchOptionsMenuClosed(Menu menu)
Lets all Fragments managed by the controller's FragmentManager
know their options menu has closed. |
public void | dispatchPause()
Moves all Fragments managed by the controller's FragmentManager
into the pause state. |
public void | dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode)
Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture
mode of the activity changed. |
public boolean | dispatchPrepareOptionsMenu(Menu menu)
Lets all Fragments managed by the controller's FragmentManager
know they should prepare their options menu for display. |
public void | dispatchReallyStop()
|
public void | dispatchResume()
Moves all Fragments managed by the controller's FragmentManager
into the resume state. |
public void | dispatchStart()
Moves all Fragments managed by the controller's FragmentManager
into the start state. |
public void | dispatchStop()
Moves all Fragments managed by the controller's FragmentManager
into the stop state. |
public void | doLoaderDestroy()
Destroys the loaders and, if their state is not being retained, removes them. |
public void | doLoaderRetain()
Retains the state of each of the loaders. |
public void | doLoaderStart()
Starts the loaders. |
public void | doLoaderStop(boolean retain)
Stops the loaders, optionally retaining their state. |
public void | dumpLoaders(java.lang.String prefix, java.io.FileDescriptor fd, java.io.PrintWriter writer, java.lang.String args[])
Dumps the current state of the loaders. |
public boolean | execPendingActions()
Execute any pending actions for the Fragments managed by the
controller's FragmentManager. |
public Fragment | findFragmentByWho(java.lang.String who)
Returns a fragment with the given identifier. |
public java.util.List<Fragment> | getActiveFragments(java.util.List<Fragment> actives)
Returns the list of active fragments. |
public int | getActiveFragmentsCount()
Returns the number of active fragments. |
public FragmentManager | getSupportFragmentManager()
Returns a FragmentManager for this controller. |
public LoaderManager | getSupportLoaderManager()
Returns a LoaderManager. |
public void | noteStateNotSaved()
Marks the fragment state as unsaved. |
public View | onCreateView(View parent, java.lang.String name, Context context, AttributeSet attrs)
Instantiates a Fragment's view. |
public void | reportLoaderStart()
Lets the loaders know the host is ready to receive notifications. |
public void | restoreAllState(Parcelable state, FragmentManagerNonConfig nonConfig)
Restores the saved state for all Fragments. |
public void | restoreAllState(Parcelable state, java.util.List<Fragment> nonConfigList)
Restores the saved state for all Fragments. |
public void | restoreLoaderNonConfig(SimpleArrayMap<java.lang.String, LoaderManager> loaderManagers)
Restores the saved state for all LoaderManagers. |
public void | restoreSaveState(Parcelable state)
Restores the saved state for all Fragments. |
public SimpleArrayMap<java.lang.String, LoaderManager> | retainLoaderNonConfig()
Returns a list of LoaderManagers that have opted to retain their instance across
configuration changes. |
public FragmentManagerNonConfig | retainNestedNonConfig()
Returns a nested tree of Fragments that have opted to retain their instance across
configuration changes. |
public java.util.List<Fragment> | retainNonConfig()
Returns a list of Fragments that have opted to retain their instance across
configuration changes. |
public Parcelable | saveAllState()
Saves the state for all Fragments. |
from java.lang.Object | clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Methods
Returns a FragmentController.
Returns a FragmentManager for this controller.
Deprecated: Loaders are managed separately from FragmentController and this now throws an
java.lang.UnsupportedOperationException
. Use LoaderManager.getInstance(T) to obtain a
LoaderManager.
Returns a LoaderManager.
See also: LoaderManager.getInstance(T)
public
Fragment findFragmentByWho(java.lang.String who)
Returns a fragment with the given identifier.
public int
getActiveFragmentsCount()
Returns the number of active fragments.
public java.util.List<Fragment>
getActiveFragments(java.util.List<Fragment> actives)
Returns the list of active fragments.
Attaches the host to the FragmentManager for this controller. The host must be
attached before the FragmentManager can be used to manage Fragments.
public View
onCreateView(View parent, java.lang.String name, Context context, AttributeSet attrs)
Instantiates a Fragment's view.
Parameters:
parent: The parent that the created view will be placed
in; note that this may be null.
name: Tag name to be inflated.
context: The context the view is being created in.
attrs: Inflation attributes as specified in XML file.
Returns:
view the newly created view
public void
noteStateNotSaved()
Marks the fragment state as unsaved. This allows for "state loss" detection.
public Parcelable
saveAllState()
Deprecated: Have your FragmentHostCallback implement
SavedStateRegistryOwner to automatically
save state via the FragmentManager.
Saves the state for all Fragments.
See also: FragmentController.restoreSaveState(Parcelable)
public void
restoreAllState(Parcelable state, java.util.List<Fragment> nonConfigList)
Deprecated: Have your FragmentHostCallback implement ViewModelStoreOwner
to automatically restore the Fragment's non configuration state and use
FragmentController.restoreSaveState(Parcelable) to restore the Fragment's save state.
Restores the saved state for all Fragments. The given Fragment list are Fragment
instances retained across configuration changes.
Deprecated: Have your FragmentHostCallback implement ViewModelStoreOwner
to automatically restore the Fragment's non configuration state and use
FragmentController.restoreSaveState(Parcelable) to restore the Fragment's save state.
Restores the saved state for all Fragments. The given FragmentManagerNonConfig are Fragment
instances retained across configuration changes, including nested fragments
public void
restoreSaveState(Parcelable state)
Deprecated: Have your FragmentHostCallback implement
SavedStateRegistryOwner to automatically
restore the saved state via the FragmentManager.
Restores the saved state for all Fragments.
Parameters:
state: the saved state containing the Parcelable returned by FragmentController.saveAllState()
See also: FragmentController.saveAllState()
public java.util.List<Fragment>
retainNonConfig()
Deprecated: Have your FragmentHostCallback implement ViewModelStoreOwner
to automatically retain the Fragment's non configuration state.
Returns a list of Fragments that have opted to retain their instance across
configuration changes.
Deprecated: Have your FragmentHostCallback implement ViewModelStoreOwner
to automatically retain the Fragment's non configuration state.
Returns a nested tree of Fragments that have opted to retain their instance across
configuration changes.
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(Bundle)
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.
See also: Fragment.onActivityCreated(Bundle)
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()
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()
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()
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()
public void
dispatchReallyStop()
Deprecated: This functionality has been rolled into FragmentController.dispatchStop().
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()
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.
Otherwise, the FragmentManager will look to see if the
host's Context is an
and if returns true. In only that case
will non configuration state be retained.
Call when Fragments should be destroyed.
See also: Fragment.onDestroy()
public void
dispatchMultiWindowModeChanged(boolean isInMultiWindowMode)
Deprecated: Have your FragmentHostCallback implement
OnMultiWindowModeChangedProvider
to automatically dispatch multi-window mode changes to fragments.
Lets all Fragments managed by the controller's FragmentManager know the multi-window mode of
the activity changed.
Call when the multi-window mode of the activity changed.
See also: Fragment.onMultiWindowModeChanged(boolean)
public void
dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode)
Deprecated: Have your FragmentHostCallback implement
OnPictureInPictureModeChangedProvider
to automatically dispatch picture-in-picture mode changes to fragments.
Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture
mode of the activity changed.
Call when the picture-in-picture mode of the activity changed.
See also: Fragment.onPictureInPictureModeChanged(boolean)
public void
dispatchConfigurationChanged(Configuration newConfig)
Deprecated: Have your FragmentHostCallback implement
OnConfigurationChangedProvider
to automatically dispatch configuration changes to fragments.
Lets all Fragments managed by the controller's FragmentManager
know a configuration change occurred.
Call when there is a configuration change.
See also: Fragment.onConfigurationChanged(Configuration)
public void
dispatchLowMemory()
Deprecated: Have your FragmentHostCallback implement
OnTrimMemoryProvider
to automatically dispatch low memory callbacks to fragments.
Lets all Fragments managed by the controller's FragmentManager
know the device is in a low memory condition.
Call when the device is low on memory and Fragment's should trim
their memory usage.
See also: Fragment.onLowMemory()
public boolean
dispatchCreateOptionsMenu(Menu menu, MenuInflater inflater)
Deprecated: Have your FragmentHostCallback implement
MenuHost to automatically dispatch menu changes to fragments.
Lets all Fragments managed by the controller's FragmentManager
know they should create an options menu.
Call when the Fragment should create an options menu.
Returns:
true if the options menu contains items to display
See also: Fragment.onCreateOptionsMenu(Menu, MenuInflater)
public boolean
dispatchPrepareOptionsMenu(Menu menu)
Deprecated: Have your FragmentHostCallback implement
MenuHost to automatically dispatch menu changes to fragments.
Lets all Fragments managed by the controller's FragmentManager
know they should prepare their options menu for display.
Call immediately before displaying the Fragment's options menu.
Returns:
true if the options menu contains items to display
See also: Fragment.onPrepareOptionsMenu(Menu)
public boolean
dispatchOptionsItemSelected(MenuItem item)
Deprecated: Have your FragmentHostCallback implement
MenuHost to automatically dispatch menu changes to fragments.
Sends an option item selection event to the Fragments managed by the
controller's FragmentManager. Once the event has been consumed,
no additional handling will be performed.
Call immediately after an options menu item has been selected
Returns:
true if the options menu selection event was consumed
See also: Fragment.onOptionsItemSelected(MenuItem)
public boolean
dispatchContextItemSelected(MenuItem item)
Sends a context item selection event to the Fragments managed by the
controller's FragmentManager. Once the event has been consumed,
no additional handling will be performed.
Call immediately after an options menu item has been selected
Returns:
true if the context menu selection event was consumed
See also: Fragment.onContextItemSelected(MenuItem)
public void
dispatchOptionsMenuClosed(Menu menu)
Deprecated: Have your FragmentHostCallback implement
MenuHost to automatically dispatch menu changes to fragments.
Lets all Fragments managed by the controller's FragmentManager
know their options menu has closed.
Call immediately after closing the Fragment's options menu.
See also: Fragment.onOptionsMenuClosed(Menu)
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
public void
doLoaderStart()
Deprecated: Loaders are managed separately from FragmentController
Starts the loaders.
public void
doLoaderStop(boolean retain)
Deprecated: Loaders are managed separately from FragmentController
Stops the loaders, optionally retaining their state. This is useful for keeping the
loader state across configuration changes.
Parameters:
retain: When true, the loaders aren't stopped, but, their instances
are retained in a started state
public void
doLoaderRetain()
Deprecated: Loaders are managed separately from FragmentController
Retains the state of each of the loaders.
public void
doLoaderDestroy()
Deprecated: Loaders are managed separately from FragmentController
Destroys the loaders and, if their state is not being retained, removes them.
public void
reportLoaderStart()
Deprecated: Loaders are managed separately from FragmentController
Lets the loaders know the host is ready to receive notifications.
public
SimpleArrayMap<java.lang.String, LoaderManager>
retainLoaderNonConfig()
Deprecated: Loaders are managed separately from FragmentController
Returns a list of LoaderManagers that have opted to retain their instance across
configuration changes.
public void
restoreLoaderNonConfig(
SimpleArrayMap<java.lang.String, LoaderManager> loaderManagers)
Deprecated: Loaders are managed separately from FragmentController
Restores the saved state for all LoaderManagers. The given LoaderManager list are
LoaderManager instances retained across configuration changes.
See also: FragmentController.retainLoaderNonConfig()
public void
dumpLoaders(java.lang.String prefix, java.io.FileDescriptor fd, java.io.PrintWriter writer, java.lang.String args[])
Deprecated: Loaders are managed separately from FragmentController
Dumps the current state of the loaders.
Source
/*
* Copyright 2018 The Android Open Source Project
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package androidx.fragment.app;
import static androidx.core.util.Preconditions.checkNotNull;
import android.annotation.SuppressLint;
import android.app.Activity;
import android.content.Context;
import android.content.res.Configuration;
import android.os.Parcelable;
import android.util.AttributeSet;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import androidx.annotation.NonNull;
import androidx.annotation.Nullable;
import androidx.collection.SimpleArrayMap;
import androidx.core.view.MenuHost;
import androidx.lifecycle.ViewModelStoreOwner;
import androidx.loader.app.LoaderManager;
import java.io.FileDescriptor;
import java.io.PrintWriter;
import java.util.ArrayList;
import java.util.List;
/**
* Provides integration points with a {@link FragmentManager} for a fragment host.
* <p>
* It is the responsibility of the host to take care of the Fragment's lifecycle.
* The methods provided by {@link FragmentController} are for that purpose.
*/
public class FragmentController {
private final FragmentHostCallback<?> mHost;
/**
* Returns a {@link FragmentController}.
*/
@NonNull
public static FragmentController createController(@NonNull FragmentHostCallback<?> callbacks) {
return new FragmentController(checkNotNull(callbacks, "callbacks == null"));
}
private FragmentController(FragmentHostCallback<?> callbacks) {
mHost = callbacks;
}
/**
* Returns a {@link FragmentManager} for this controller.
*/
@NonNull
public FragmentManager getSupportFragmentManager() {
return mHost.getFragmentManager();
}
/**
* Returns a {@link LoaderManager}.
*
* @deprecated Loaders are managed separately from FragmentController and this now throws an
* {@link UnsupportedOperationException}. Use {@link LoaderManager#getInstance} to obtain a
* LoaderManager.
* @see LoaderManager#getInstance
*/
@Deprecated
@SuppressLint("UnknownNullness")
public LoaderManager getSupportLoaderManager() {
throw new UnsupportedOperationException("Loaders are managed separately from "
+ "FragmentController, use LoaderManager.getInstance() to obtain a LoaderManager.");
}
/**
* Returns a fragment with the given identifier.
*/
@Nullable
public Fragment findFragmentByWho(@NonNull String who) {
return mHost.getFragmentManager().findFragmentByWho(who);
}
/**
* Returns the number of active fragments.
*/
public int getActiveFragmentsCount() {
return mHost.getFragmentManager().getActiveFragmentCount();
}
/**
* Returns the list of active fragments.
*/
@NonNull
public List<Fragment> getActiveFragments(@SuppressLint("UnknownNullness")
List<Fragment> actives) {
return mHost.getFragmentManager().getActiveFragments();
}
/**
* Attaches the host to the FragmentManager for this controller. The host must be
* attached before the FragmentManager can be used to manage Fragments.
*/
public void attachHost(@Nullable Fragment parent) {
mHost.getFragmentManager().attachController(
mHost, mHost /*container*/, parent);
}
/**
* Instantiates a Fragment's view.
*
* @param parent The parent that the created view will be placed
* in; <em>note that this may be null</em>.
* @param name Tag name to be inflated.
* @param context The context the view is being created in.
* @param attrs Inflation attributes as specified in XML file.
*
* @return view the newly created view
*/
@Nullable
public View onCreateView(@Nullable View parent, @NonNull String name, @NonNull Context context,
@NonNull AttributeSet attrs) {
return mHost.getFragmentManager().getLayoutInflaterFactory()
.onCreateView(parent, name, context, attrs);
}
/**
* Marks the fragment state as unsaved. This allows for "state loss" detection.
*/
public void noteStateNotSaved() {
mHost.getFragmentManager().noteStateNotSaved();
}
/**
* Saves the state for all Fragments.
*
* @see #restoreSaveState(Parcelable)
*
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link androidx.savedstate.SavedStateRegistryOwner} to automatically
* save state via the {@link FragmentManager}.
*/
@SuppressWarnings("deprecation")
@Deprecated
@Nullable
public Parcelable saveAllState() {
return mHost.getFragmentManager().saveAllState();
}
/**
* Restores the saved state for all Fragments. The given Fragment list are Fragment
* instances retained across configuration changes.
*
* @deprecated Have your {@link FragmentHostCallback} implement {@link ViewModelStoreOwner}
* to automatically restore the Fragment's non configuration state and use
* {@link #restoreSaveState(Parcelable)} to restore the Fragment's save state.
*/
@SuppressWarnings("deprecation")
@Deprecated
public void restoreAllState(@Nullable Parcelable state,
@Nullable List<Fragment> nonConfigList) {
mHost.getFragmentManager().restoreAllState(state,
new FragmentManagerNonConfig(nonConfigList, null, null));
}
/**
* Restores the saved state for all Fragments. The given FragmentManagerNonConfig are Fragment
* instances retained across configuration changes, including nested fragments
*
* @deprecated Have your {@link FragmentHostCallback} implement {@link ViewModelStoreOwner}
* to automatically restore the Fragment's non configuration state and use
* {@link #restoreSaveState(Parcelable)} to restore the Fragment's save state.
*/
@SuppressWarnings("deprecation")
@Deprecated
public void restoreAllState(@Nullable Parcelable state,
@Nullable FragmentManagerNonConfig nonConfig) {
mHost.getFragmentManager().restoreAllState(state, nonConfig);
}
/**
* Restores the saved state for all Fragments.
*
* @param state the saved state containing the Parcelable returned by {@link #saveAllState()}
* @see #saveAllState()
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link androidx.savedstate.SavedStateRegistryOwner} to automatically
* restore the saved state via the {@link FragmentManager}.
*/
@SuppressWarnings("deprecation")
@Deprecated
public void restoreSaveState(@Nullable Parcelable state) {
if (!(mHost instanceof ViewModelStoreOwner)) {
throw new IllegalStateException("Your FragmentHostCallback must implement "
+ "ViewModelStoreOwner to call restoreSaveState(). Call restoreAllState() "
+ " if you're still using retainNestedNonConfig().");
}
mHost.getFragmentManager().restoreSaveState(state);
}
/**
* Returns a list of Fragments that have opted to retain their instance across
* configuration changes.
*
* @deprecated Have your {@link FragmentHostCallback} implement {@link ViewModelStoreOwner}
* to automatically retain the Fragment's non configuration state.
*/
@SuppressWarnings("deprecation")
@Deprecated
@Nullable
public List<Fragment> retainNonConfig() {
FragmentManagerNonConfig nonconf = mHost.getFragmentManager().retainNonConfig();
return nonconf != null && nonconf.getFragments() != null
? new ArrayList<>(nonconf.getFragments())
: null;
}
/**
* Returns a nested tree of Fragments that have opted to retain their instance across
* configuration changes.
*
* @deprecated Have your {@link FragmentHostCallback} implement {@link ViewModelStoreOwner}
* to automatically retain the Fragment's non configuration state.
*/
@SuppressWarnings("deprecation")
@Deprecated
@Nullable
public FragmentManagerNonConfig retainNestedNonConfig() {
return mHost.getFragmentManager().retainNonConfig();
}
/**
* Moves all Fragments managed by the controller's FragmentManager
* into the create state.
* <p>Call when Fragments should be created.
*
* @see Fragment#onCreate(Bundle)
*/
public void dispatchCreate() {
mHost.getFragmentManager().dispatchCreate();
}
/**
* Moves all Fragments managed by the controller's FragmentManager
* into the activity created state.
* <p>Call when Fragments should be informed their host has been created.
*
* @see Fragment#onActivityCreated(Bundle)
*/
public void dispatchActivityCreated() {
mHost.getFragmentManager().dispatchActivityCreated();
}
/**
* Moves all Fragments managed by the controller's FragmentManager
* into the start state.
* <p>Call when Fragments should be started.
*
* @see Fragment#onStart()
*/
public void dispatchStart() {
mHost.getFragmentManager().dispatchStart();
}
/**
* Moves all Fragments managed by the controller's FragmentManager
* into the resume state.
* <p>Call when Fragments should be resumed.
*
* @see Fragment#onResume()
*/
public void dispatchResume() {
mHost.getFragmentManager().dispatchResume();
}
/**
* Moves all Fragments managed by the controller's FragmentManager
* into the pause state.
* <p>Call when Fragments should be paused.
*
* @see Fragment#onPause()
*/
public void dispatchPause() {
mHost.getFragmentManager().dispatchPause();
}
/**
* Moves all Fragments managed by the controller's FragmentManager
* into the stop state.
* <p>Call when Fragments should be stopped.
*
* @see Fragment#onStop()
*/
public void dispatchStop() {
mHost.getFragmentManager().dispatchStop();
}
/**
* @deprecated This functionality has been rolled into {@link #dispatchStop()}.
*/
@Deprecated
public void dispatchReallyStop() {
}
/**
* Moves all Fragments managed by the controller's FragmentManager
* into the destroy view state.
* <p>Call when the Fragment's views should be destroyed.
*
* @see Fragment#onDestroyView()
*/
public void dispatchDestroyView() {
mHost.getFragmentManager().dispatchDestroyView();
}
/**
* Moves Fragments managed by the controller's FragmentManager
* into the destroy state.
* <p>
* If the {@link androidx.fragment.app.FragmentHostCallback} is an instance of {@link ViewModelStoreOwner},
* then retained Fragments and any other non configuration state such as any
* {@link androidx.lifecycle.ViewModel} attached to Fragments will only be destroyed if
* {@link androidx.lifecycle.ViewModelStore#clear()} is called prior to this method.
* <p>
* Otherwise, the FragmentManager will look to see if the
* {@link FragmentHostCallback host's} Context is an {@link Activity}
* and if {@link Activity#isChangingConfigurations()} returns true. In only that case
* will non configuration state be retained.
* <p>Call when Fragments should be destroyed.
*
* @see Fragment#onDestroy()
*/
public void dispatchDestroy() {
mHost.getFragmentManager().dispatchDestroy();
}
/**
* Lets all Fragments managed by the controller's FragmentManager know the multi-window mode of
* the activity changed.
* <p>Call when the multi-window mode of the activity changed.
*
* @see Fragment#onMultiWindowModeChanged
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link androidx.core.app.OnMultiWindowModeChangedProvider}
* to automatically dispatch multi-window mode changes to fragments.
*/
@Deprecated
public void dispatchMultiWindowModeChanged(boolean isInMultiWindowMode) {
mHost.getFragmentManager().dispatchMultiWindowModeChanged(isInMultiWindowMode, true);
}
/**
* Lets all Fragments managed by the controller's FragmentManager know the picture-in-picture
* mode of the activity changed.
* <p>Call when the picture-in-picture mode of the activity changed.
*
* @see Fragment#onPictureInPictureModeChanged
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link androidx.core.app.OnPictureInPictureModeChangedProvider}
* to automatically dispatch picture-in-picture mode changes to fragments.
*/
@Deprecated
public void dispatchPictureInPictureModeChanged(boolean isInPictureInPictureMode) {
mHost.getFragmentManager().dispatchPictureInPictureModeChanged(
isInPictureInPictureMode, true);
}
/**
* Lets all Fragments managed by the controller's FragmentManager
* know a configuration change occurred.
* <p>Call when there is a configuration change.
*
* @see Fragment#onConfigurationChanged(Configuration)
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link androidx.core.content.OnConfigurationChangedProvider}
* to automatically dispatch configuration changes to fragments.
*/
@Deprecated
public void dispatchConfigurationChanged(@NonNull Configuration newConfig) {
mHost.getFragmentManager().dispatchConfigurationChanged(newConfig, true);
}
/**
* Lets all Fragments managed by the controller's FragmentManager
* know the device is in a low memory condition.
* <p>Call when the device is low on memory and Fragment's should trim
* their memory usage.
*
* @see Fragment#onLowMemory()
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link androidx.core.content.OnTrimMemoryProvider}
* to automatically dispatch low memory callbacks to fragments.
*/
@Deprecated
public void dispatchLowMemory() {
mHost.getFragmentManager().dispatchLowMemory(true);
}
/**
* Lets all Fragments managed by the controller's FragmentManager
* know they should create an options menu.
* <p>Call when the Fragment should create an options menu.
*
* @return {@code true} if the options menu contains items to display
* @see Fragment#onCreateOptionsMenu(Menu, MenuInflater)
*
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link MenuHost} to automatically dispatch menu changes to fragments.
*/
@Deprecated
public boolean dispatchCreateOptionsMenu(@NonNull Menu menu, @NonNull MenuInflater inflater) {
return mHost.getFragmentManager().dispatchCreateOptionsMenu(menu, inflater);
}
/**
* Lets all Fragments managed by the controller's FragmentManager
* know they should prepare their options menu for display.
* <p>Call immediately before displaying the Fragment's options menu.
*
* @return {@code true} if the options menu contains items to display
* @see Fragment#onPrepareOptionsMenu(Menu)
*
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link MenuHost} to automatically dispatch menu changes to fragments.
*/
@Deprecated
public boolean dispatchPrepareOptionsMenu(@NonNull Menu menu) {
return mHost.getFragmentManager().dispatchPrepareOptionsMenu(menu);
}
/**
* Sends an option item selection event to the Fragments managed by the
* controller's FragmentManager. Once the event has been consumed,
* no additional handling will be performed.
* <p>Call immediately after an options menu item has been selected
*
* @return {@code true} if the options menu selection event was consumed
* @see Fragment#onOptionsItemSelected(MenuItem)
*
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link MenuHost} to automatically dispatch menu changes to fragments.
*/
@Deprecated
public boolean dispatchOptionsItemSelected(@NonNull MenuItem item) {
return mHost.getFragmentManager().dispatchOptionsItemSelected(item);
}
/**
* Sends a context item selection event to the Fragments managed by the
* controller's FragmentManager. Once the event has been consumed,
* no additional handling will be performed.
* <p>Call immediately after an options menu item has been selected
*
* @return {@code true} if the context menu selection event was consumed
* @see Fragment#onContextItemSelected(MenuItem)
*/
public boolean dispatchContextItemSelected(@NonNull MenuItem item) {
return mHost.getFragmentManager().dispatchContextItemSelected(item);
}
/**
* Lets all Fragments managed by the controller's FragmentManager
* know their options menu has closed.
* <p>Call immediately after closing the Fragment's options menu.
*
* @see Fragment#onOptionsMenuClosed(Menu)
*
* @deprecated Have your {@link FragmentHostCallback} implement
* {@link MenuHost} to automatically dispatch menu changes to fragments.
*/
@Deprecated
public void dispatchOptionsMenuClosed(@NonNull Menu menu) {
mHost.getFragmentManager().dispatchOptionsMenuClosed(menu);
}
/**
* Execute any pending actions for the Fragments managed by the
* controller's FragmentManager.
* <p>Call when queued actions can be performed [eg when the
* Fragment moves into a start or resume state].
* @return {@code true} if queued actions were performed
*/
public boolean execPendingActions() {
return mHost.getFragmentManager().execPendingActions(true);
}
/**
* Starts the loaders.
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
public void doLoaderStart() {
}
/**
* Stops the loaders, optionally retaining their state. This is useful for keeping the
* loader state across configuration changes.
*
* @param retain When {@code true}, the loaders aren't stopped, but, their instances
* are retained in a started state
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
public void doLoaderStop(boolean retain) {
}
/**
* Retains the state of each of the loaders.
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
public void doLoaderRetain() {
}
/**
* Destroys the loaders and, if their state is not being retained, removes them.
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
public void doLoaderDestroy() {
}
/**
* Lets the loaders know the host is ready to receive notifications.
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
public void reportLoaderStart() {
}
/**
* Returns a list of LoaderManagers that have opted to retain their instance across
* configuration changes.
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
@Nullable
public SimpleArrayMap<String, LoaderManager> retainLoaderNonConfig() {
return null;
}
/**
* Restores the saved state for all LoaderManagers. The given LoaderManager list are
* LoaderManager instances retained across configuration changes.
*
* @see #retainLoaderNonConfig()
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
public void restoreLoaderNonConfig(@SuppressLint("UnknownNullness")
SimpleArrayMap<String, LoaderManager> loaderManagers) {
}
/**
* Dumps the current state of the loaders.
*
* @deprecated Loaders are managed separately from FragmentController
*/
@Deprecated
public void dumpLoaders(@NonNull String prefix, @Nullable FileDescriptor fd,
@NonNull PrintWriter writer, @Nullable String[] args) {
}
}