public final class FlowCoordinator
extends java.lang.Object
The flow coordinator can be used within a Fragment or an Activity. The coordinator expects to be informed about certain life cycle
events:
onCreateView(LayoutInflater, ViewGroup,
Bundle) has to be called. The method returns a View which can be added to the current
layout.onSaveInstanceState(Bundle) and onDestroy() should be invoked. Eventually only one of
them has to be invoked.Further the coordinator may have references to View and as
such the coordinator should be dereferenced once the handlerView hierarchy is destroyed. The
coordinator ensures that the views which are created as part of state changes gets properly
dereferenced. However the coordinator must have always a reference to the current handlerView and
as such when this current handlerView is destroyed also the coordinator has to be destroyed.
To register for events the coordinator accepts through it's FlowConfiguration listeners. Candidates about which the coordinator will inform about are
subinterfaces of FlowListener.
The coordinator allows also to trigger certain actions from the outside. The
possible actions can be found FlowAction. They can be triggered through triggerAction(FlowAction).
The coordinator has an internal state this state will be
persisted through onSaveInstanceState(Bundle). The state and all relevant data is
attached to the bundle. It will automatically restore the state throught onCreateView(LayoutInflater, ViewGroup, Bundle).
| Constructor and Description |
|---|
FlowCoordinator(FlowConfiguration configuration)
Constructor of the coordinator.
|
| Modifier and Type | Method and Description |
|---|---|
boolean |
dryTriggerAction(FlowAction action)
This method will trigger the
action without actually executing it. |
android.view.View |
onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup parent,
android.os.Bundle savedInstanceState)
This method creates the handlerView which is relevant for the
savedInstanceState of
the coordinator. |
void |
onDestroy()
This method destroys any link to the handlerView references etc.
|
void |
onSaveInstanceState(android.os.Bundle outState)
This method persists the current state of the coordinator into the given
outState
bundle. |
boolean |
triggerAction(FlowAction action)
This method triggers the
action. |
public FlowCoordinator(FlowConfiguration configuration)
configuration - the configuration to use for this coordinator.public boolean dryTriggerAction(FlowAction action)
action without actually executing it. This method allows
to test if the execution of a particular action will be executed or not. The method will
return true when the action can be executed.
The method givens an indication of an execution is possible at the moment or not. However
there will be no guarantee that the call of triggerAction(FlowAction) will execute
the action. There is a small time frame between those calls and as such the inner
state may change in this time frame. So the action may be right now executable but a bit
later not anymore. As such this method should only be used as an indicator.
action - the action which should be tested to be executed.true when the given action can be executed otherwise false.public boolean triggerAction(FlowAction action)
action. The action will affect the inner state of the
coordinator.
To test if a particular action may be executed the method dryTriggerAction(FlowAction) can be used. The method gives an indication if a particular
FlowAction can be triggered according to the current inner state of the
coordinator.
The method will return true when the action has been executed. Otherwise the
method will return false.
action - the action which should be triggered. See the action description what the
action will trigger and the action can be triggered.true when the action has been executed. Otherwise the method will return
false.public android.view.View onCreateView(android.view.LayoutInflater inflater,
android.view.ViewGroup parent,
android.os.Bundle savedInstanceState)
savedInstanceState of
the coordinator. When the savedInstanceState is null (which is the case when the
coordinator is created the first time for a particular flow) the default handlerView will be
loaded.
The method will return a container into which all other views will be rendered into. The
returned handlerView is not added to the parent. The parent is only used for layout
purposes.
The intention is to call this method from within Activity.onCreateView(String,
Context, AttributeSet) resp. Fragment.onCreateView(LayoutInflater,
ViewGroup, Bundle).
inflater - the inflater to use.parent - the parent handlerView into which the returned handlerView will be
embedded into by the caller.savedInstanceState - the state which should be used to restore the handlerView.parent. The handlerView
returned is a container. Any modification applied will only occur within this handlerView and
not outside.public void onSaveInstanceState(android.os.Bundle outState)
outState
bundle.
The intention is that this method is called from within Activity.onSaveInstanceState(Bundle) resp. Fragment.onSaveInstanceState(Bundle).
outState - public void onDestroy()
The intention is that this method is called from within Activity.onDestroy() resp.
Fragment.onDestroy().