FragmentManager.OnBackStackChangedListener


interface FragmentManager.OnBackStackChangedListener


Interface to watch for changes to the back stack.

Summary

Public functions

Unit

Called whenever a predictive back gesture is cancelled.

Unit

Called whenever the contents of a back stack change is committed.

Unit

Called whenever a predictive back gesture is changing the back stack.

Unit

Called whenever the contents of the back stack are starting to be changed, before any fragment actually changes its lifecycle state.

Unit

Called whenever the contents of the back stack change, after the fragment manager has moved all of the fragments to their final state.

Public functions

onBackStackChangeCancelled

Added in 1.7.0
@MainThread
fun onBackStackChangeCancelled(): Unit

Called whenever a predictive back gesture is cancelled.

This is called immediately after onBackStackChangeProgressed once a predictive back gesture has been cancelled and will place the FragmentManager back into the state before the predictive back gesture was started.

onBackStackChangeCommitted

Added in 1.6.0
@MainThread
fun onBackStackChangeCommitted(fragment: Fragment, pop: Boolean): Unit

Called whenever the contents of a back stack change is committed. If this is caused by a forward transaction and the given fragment is incoming, it will return false from isRemoving. If this is caused by a pop operation and the given fragment is being popped, it will return true from isRemoving.

This is called immediately after onBackStackChangeStarted for a forward transaction or for a non-predictive back pop. If this is caused by a predictive back gesture, it will be called after onBackStackChangeProgressed before the fragment moves to the final state.

Parameters
fragment: Fragment

one of the fragments that is affected by the committed back stack change

pop: Boolean

true, if this callback was triggered by a pop operation, false otherwise

onBackStackChangeProgressed

Added in 1.7.0
@MainThread
fun onBackStackChangeProgressed(backEventCompat: BackEventCompat): Unit

Called whenever a predictive back gesture is changing the back stack. This will continue to be called with an updated BackEventCompat object until the gesture is either cancelled or completed.

This is called immediately after onBackStackChangeStarted during a predictive back gesture. If the gesture is completed, this will be followed by onBackStackChangeCommitted and if it is cancelled, it will be followed by onBackStackChangeCancelled.

Parameters
backEventCompat: BackEventCompat

provides the current progress of the active predictive back gesture

onBackStackChangeStarted

Added in 1.6.0
@MainThread
fun onBackStackChangeStarted(fragment: Fragment, pop: Boolean): Unit

Called whenever the contents of the back stack are starting to be changed, before any fragment actually changes its lifecycle state. If this is caused by a forward transaction and the given fragment is incoming, it will return false from isRemoving. If this is caused by a pop operation and the given fragment is being popped, it will return true from isRemoving.

This is the first callback that will be delivered to the listener. If the transaction is caused by a predictive back gesture, it will be followed by an onBackStackChangeProgressed callback otherwise, the next callback will be onBackStackChangeCommitted.

Parameters
fragment: Fragment

one of the fragments that is affected by the starting back stack change

pop: Boolean

true, if this callback was triggered by a pop operation, false otherwise

onBackStackChanged

Added in 1.1.0
@MainThread
fun onBackStackChanged(): Unit

Called whenever the contents of the back stack change, after the fragment manager has moved all of the fragments to their final state.

This is the final callback that will be delivered to the listener in all cases except for when the predictive back gesture is cancelled. It will be called after onBackStackChangeCommitted.