Google is committed to advancing racial equity for Black communities. See how.

FragmentTransactionCallback

abstract class FragmentTransactionCallback
kotlin.Any
   ↳ androidx.viewpager2.adapter.FragmentStateAdapter.FragmentTransactionCallback

Callback interface for listening to fragment lifecycle changes that happen inside the adapter.

Summary

Nested classes
abstract

Callback returned by onFragmentPreAdded, onFragmentPreRemoved, onFragmentMaxLifecyclePreUpdated called after the operation ends.

Public constructors

Callback interface for listening to fragment lifecycle changes that happen inside the adapter.

Public methods
open FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener
onFragmentMaxLifecyclePreUpdated(@NonNull fragment: Fragment, @NonNull maxLifecycleState: Lifecycle.State)

Called right before Fragment's maximum state is capped via FragmentTransaction#setMaxLifecycle.

open FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener
onFragmentPreAdded(@NonNull fragment: Fragment)

Called right before the Fragment is added to adapter's FragmentManager.

open FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener
onFragmentPreRemoved(@NonNull fragment: Fragment)

Called right before the Fragment is removed from adapter's FragmentManager.

Public constructors

<init>

FragmentTransactionCallback()

Callback interface for listening to fragment lifecycle changes that happen inside the adapter.

Public methods

onFragmentMaxLifecyclePreUpdated

@NonNull open fun onFragmentMaxLifecyclePreUpdated(
    @NonNull fragment: Fragment,
    @NonNull maxLifecycleState: Lifecycle.State
): FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener

Called right before Fragment's maximum state is capped via FragmentTransaction#setMaxLifecycle.

Parameters
fragment Fragment: Fragment to have its state capped
maxLifecycleState Lifecycle.State: Ceiling state for the fragment
Return
FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener Listener called after the operation

onFragmentPreAdded

@NonNull open fun onFragmentPreAdded(@NonNull fragment: Fragment): FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener

Called right before the Fragment is added to adapter's FragmentManager.

Parameters
fragment Fragment: Fragment changing state
Return
FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener Listener called after the operation

onFragmentPreRemoved

@NonNull open fun onFragmentPreRemoved(@NonNull fragment: Fragment): FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener

Called right before the Fragment is removed from adapter's FragmentManager.

Parameters
fragment Fragment: Fragment changing state
Return
FragmentStateAdapter.FragmentTransactionCallback.OnPostEventListener Listener called after the operation