Package icyllis.modernui.fragment
Interface FragmentResultOwner
- All Known Implementing Classes:
FragmentManager
public interface FragmentResultOwner
A class that manages passing data between fragments.
-
Method Summary
Modifier and TypeMethodDescriptionvoid
clearFragmentResult
(String requestKey) Clears the stored result for the given requestKey.void
clearFragmentResultListener
(String requestKey) Clears the storedFragmentResultListener
for the given requestKey.void
setFragmentResult
(String requestKey, DataSet result) Sets the given result for the requestKey.void
setFragmentResultListener
(String requestKey, LifecycleOwner lifecycleOwner, FragmentResultListener listener) Sets theFragmentResultListener
for a given requestKey.
-
Method Details
-
setFragmentResult
Sets the given result for the requestKey. This result will be delivered to aFragmentResultListener
that is called given tosetFragmentResultListener(String, LifecycleOwner, FragmentResultListener)
with the same requestKey. If noFragmentResultListener
with the same key is set or the Lifecycle associated with the listener is not at leastLifecycle.State.STARTED
, the result is stored until one becomes available, orclearFragmentResult(String)
is called with the same requestKey.- Parameters:
requestKey
- key used to identify the resultresult
- the result to be passed to another fragment
-
clearFragmentResult
Clears the stored result for the given requestKey.This clears any result that was previously set via
setFragmentResult(String, DataSet)
that hasn't yet been delivered to aFragmentResultListener
.- Parameters:
requestKey
- key used to identify the result
-
setFragmentResultListener
void setFragmentResultListener(@Nonnull String requestKey, @Nonnull LifecycleOwner lifecycleOwner, @Nonnull FragmentResultListener listener) Sets theFragmentResultListener
for a given requestKey. Once the givenLifecycleOwner
is at least in theLifecycle.State.STARTED
state, any results set bysetFragmentResult(String, DataSet)
using the same requestKey will be delivered to thecallback
. The callback will remain active until the LifecycleOwner reaches theLifecycle.State.DESTROYED
state orclearFragmentResultListener(String)
is called with the same requestKey.- Parameters:
requestKey
- requestKey used to identify the resultlifecycleOwner
- lifecycleOwner for handling the resultlistener
- listener for result changes
-
clearFragmentResultListener
Clears the storedFragmentResultListener
for the given requestKey.This clears any
FragmentResultListener
that was previously set viasetFragmentResultListener(String, LifecycleOwner, FragmentResultListener)
.- Parameters:
requestKey
- key used to identify the result
-