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 TypeMethodDescriptionvoidclearFragmentResult(String requestKey) Clears the stored result for the given requestKey.voidclearFragmentResultListener(String requestKey) Clears the storedFragmentResultListenerfor the given requestKey.voidsetFragmentResult(String requestKey, DataSet result) Sets the given result for the requestKey.voidsetFragmentResultListener(String requestKey, LifecycleOwner lifecycleOwner, FragmentResultListener listener) Sets theFragmentResultListenerfor a given requestKey.
-
Method Details
-
setFragmentResult
Sets the given result for the requestKey. This result will be delivered to aFragmentResultListenerthat is called given tosetFragmentResultListener(String, LifecycleOwner, FragmentResultListener)with the same requestKey. If noFragmentResultListenerwith 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 theFragmentResultListenerfor a given requestKey. Once the givenLifecycleOwneris at least in theLifecycle.State.STARTEDstate, 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.DESTROYEDstate 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 storedFragmentResultListenerfor the given requestKey.This clears any
FragmentResultListenerthat was previously set viasetFragmentResultListener(String, LifecycleOwner, FragmentResultListener).- Parameters:
requestKey- key used to identify the result
-