FragmentKt

public final class FragmentKt


Summary

Public methods

static final void
FragmentKt.clearFragmentResult(
    @NonNull Fragment receiver,
    @NonNull String requestKey
)

Clears the stored result for the given requestKey.

static final void
FragmentKt.clearFragmentResultListener(
    @NonNull Fragment receiver,
    @NonNull String requestKey
)

Clears the stored FragmentResultListener for the given requestKey.

static final void
FragmentKt.setFragmentResult(
    @NonNull Fragment receiver,
    @NonNull String requestKey,
    @NonNull Bundle result
)

Sets the given result for the requestKey.

static final void
FragmentKt.setFragmentResultListener(
    @NonNull Fragment receiver,
    @NonNull String requestKey,
    @NonNull Function2<@NonNull String, @NonNull BundleUnit> listener
)

Sets the FragmentResultListener for a given requestKey.

Public methods

FragmentKt.clearFragmentResult

@NonNull
public static final void FragmentKt.clearFragmentResult(
    @NonNull Fragment receiver,
    @NonNull String requestKey
)

Clears the stored result for the given requestKey.

This clears a result that was previously set a call to setFragmentResult.

If this is called with a requestKey that is not associated with any result, this method does nothing.

Parameters
@NonNull String requestKey

key used to identify the result

FragmentKt.clearFragmentResultListener

@NonNull
public static final void FragmentKt.clearFragmentResultListener(
    @NonNull Fragment receiver,
    @NonNull String requestKey
)

Clears the stored FragmentResultListener for the given requestKey.

This clears a FragmentResultListener that was previously set a call to setFragmentResultListener.

If this is called with a requestKey that is not associated with any FragmentResultListener, this method does nothing.

Parameters
@NonNull String requestKey

key used to identify the result

FragmentKt.setFragmentResult

@NonNull
public static final void FragmentKt.setFragmentResult(
    @NonNull Fragment receiver,
    @NonNull String requestKey,
    @NonNull Bundle result
)

Sets the given result for the requestKey. This result will be delivered to a FragmentResultListener that is called given to setFragmentResultListener with the same requestKey. If no FragmentResultListener with the same key is set or the Lifecycle associated with the listener is not at least androidx.lifecycle.Lifecycle.State.STARTED, the result is stored until one becomes available, or clearFragmentResult is called with the same requestKey.

Parameters
@NonNull String requestKey

key used to identify the result

@NonNull Bundle result

the result to be passed to another fragment.

FragmentKt.setFragmentResultListener

@NonNull
public static final void FragmentKt.setFragmentResultListener(
    @NonNull Fragment receiver,
    @NonNull String requestKey,
    @NonNull Function2<@NonNull String, @NonNull BundleUnit> listener
)

Sets the FragmentResultListener for a given requestKey. Once this Fragment is at least in the androidx.lifecycle.Lifecycle.State.STARTED state, any results set by setFragmentResult using the same requestKey will be delivered to the FragmentResultListener.onFragmentResult callback. The callback will remain active until this Fragment reaches the androidx.lifecycle.Lifecycle.State.DESTROYED state or clearFragmentResultListener is called with the same requestKey.

Parameters
@NonNull String requestKey

requestKey used to store the result

@NonNull Function2<@NonNull String, @NonNull BundleUnit> listener

listener for result changes.