public abstract class AbstractFeature extends AbstractPluginStateComponent implements Feature, DependencyScopeOwner
AbstractFeature
provides an abstract base class for implementing Feature
s.Modifier and Type | Field and Description |
---|---|
protected java.util.ArrayList<FeatureView> |
activeViews |
protected java.util.HashMap<java.lang.String,FeatureView> |
backStackViews |
protected int |
featureContainerId |
protected FeatureManager |
featureManager |
protected DependencyScope |
featureScope |
protected boolean |
isActivityFeature |
protected Feature |
parentFeature |
protected java.lang.Class<? extends DependencyScope> |
scopeClass |
params
Modifier | Constructor and Description |
---|---|
protected |
AbstractFeature(java.lang.Class<? extends DependencyScope> scopeClass)
Construct a new instance of
AbstractFeature . |
protected |
AbstractFeature(java.lang.Class<? extends DependencyScope> scopeClass,
boolean isActivityFeature)
Construct a new instance of
AbstractFeature . |
Modifier and Type | Method and Description |
---|---|
FeatureView |
addActiveView(FeatureView view)
|
protected void |
addBackStackView(java.lang.String tag,
FeatureView view)
Adds the given
FeatureView to the HashMap that contains all
the FeatureView s of this Feature that has been added to back stack. |
boolean |
canGoBack()
Tests if the previous
FeatureView can be navigated back to. |
void |
clearBackStack()
Clears the back stack managed by
FragmentManager . |
void |
destroy()
Invoked to set the state of
PluginStateComponent to be destroyed. |
void |
finish()
Finishes this
Feature |
java.util.List<FeatureView> |
getActiveViews()
Gets the currently active
FeatureView s. |
protected static java.lang.Class<? extends FeatureView> |
getClass(FeatureView view) |
FeatureContainer |
getFeatureContainer()
|
protected DependencyScope |
getFeatureScope() |
DependencyScope |
getOwnedScope()
Gets the
DependencyScope owned by this DependencyScopeOwner . |
Feature |
getParentFeature()
|
java.lang.Class<? extends DependencyScope> |
getScopeClass()
|
void |
goBack()
Goes back to previous
FeatureView . |
boolean |
hasBackStackViews()
Tests if this
Feature has any FeatureView s in back stack. |
boolean |
hasForegroundView()
Tests if this
Feature is in foreground i.e. |
void |
hideView(java.lang.Class<? extends Presenter> presenterClass,
boolean addedToBackStack,
java.lang.String tag)
Hides the
FeatureView attached to the given Presenter . |
void |
hideView(FeaturePresenter presenter,
boolean addedToBackStack,
java.lang.String tag)
Hides the
FeatureView attached to the given Presenter . |
boolean |
isActiveView(FeatureView view)
Tests if the given
FeatureView is currently active one. |
boolean |
isActivityFeature()
Tests if this
Feature is set to be an Activity Feature that is owned and controlled
by an Activity . |
boolean |
isBackPressedEventHandler()
Tests if this
Feature handles the back pressed event. |
void |
onFeatureContainerPaused(FeatureContainer container,
boolean finishing)
Invoked when a
FeatureContainer has been paused. |
void |
onFeatureContainerResumed(FeatureContainer container)
Invoked when a
FeatureContainer has been resumed. |
void |
onFeatureContainerStarted(FeatureContainer container)
Invoked when a
FeatureContainer has been started. |
void |
onFeatureContainerStopped(FeatureContainer container,
boolean finishing)
Invoked when a
FeatureContainer has been stopped. |
protected void |
onPause(boolean finishing)
Invoked by
Feature.pause(boolean) . |
void |
onPresenterFinished(Presenter presenter)
Invoked by a
Presenter when it has been finished by invoking Presenter.finish() . |
void |
pause()
Invoked to pause this
PluginStateComponent . |
void |
pause(boolean finishing)
Invoked to pause this
Feature . |
<T> T |
plug(java.lang.Class<?> pluginClass)
Plugs an instance of specific
Class to PluginBus . |
<T> T |
plug(java.lang.Object plugin)
Plugs the the given plugin
Object to this PluginBus . |
FeatureView |
removeActiveView(FeatureView view)
|
protected void |
removeBackStackView(java.lang.String tag)
Removes the specified
FeatureView from the HashMap that contains all the
FeatureView s of this Feature that has been added to back stack. |
void |
resume()
Invoked to resume this
PluginStateComponent . |
void |
setActivityFeature(boolean isActivityFeature)
Sets this
Feature to be an Activity Feature that is owned and controlled by
an Activity . |
void |
setFeatureContainer(FeatureContainer container)
|
void |
setFeatureManager(FeatureManager manager)
Sets the
FeatureManager that started this Feature . |
void |
setParentFeature(Feature parentFeature)
|
FeatureView |
showView(java.lang.Class<? extends Presenter> presenterClass,
boolean addToBackStack,
Params... params)
Shows the
FeatureView attached to the specified Presenter . |
FeatureView |
showView(FeatureTransitionManager transitionManager,
java.lang.Class<? extends Presenter> presenterClass,
boolean addToBackStack,
java.lang.String tag,
Params... params)
Shows the
FeatureView attached to the specified Presenter . |
FeatureView |
showView(int featureContainerId,
java.lang.Class<? extends Presenter> presenterClass,
boolean addToBackStack,
java.lang.String tag,
Params... params)
Shows the
FeatureView attached to the specified Presenter . |
void |
stop()
Invoked to set the state of
PluginStateComponent to be stopped. |
void |
unplug(java.lang.Object plugin)
Unplugs the the given plugin
Object to this PluginBus . |
getLifecycleState, getParams, getState, isDestroyed, isPaused, isRestarted, isResumed, isStarted, isStopped, onCreate, onDestroy, onPause, onRestart, onResume, onStart, onStop, restart, start, start
onPlugged, onPluginPlugged, onPluginUnplugged, onUnplugged
getScope, setScope
clone, equals, finalize, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait
getLifecycleState, getState, isDestroyed, isPaused, isRestarted, isResumed, isStarted, isStopped, restart, start, start
onPlugged, onPluginPlugged, onPluginUnplugged, onUnplugged
protected final java.util.ArrayList<FeatureView> activeViews
protected final java.util.HashMap<java.lang.String,FeatureView> backStackViews
protected int featureContainerId
protected FeatureManager featureManager
protected DependencyScope featureScope
protected boolean isActivityFeature
protected Feature parentFeature
protected java.lang.Class<? extends DependencyScope> scopeClass
protected AbstractFeature(java.lang.Class<? extends DependencyScope> scopeClass)
AbstractFeature
.scopeClass
- The Class
of the owned DependencyScope
.protected AbstractFeature(java.lang.Class<? extends DependencyScope> scopeClass, boolean isActivityFeature)
AbstractFeature
.scopeClass
- The Class
of the owned DependencyScope
.isActivityFeature
- A boolean
flag specifying if this AbstractFeature
is an Activity Feature.public java.lang.Class<? extends DependencyScope> getScopeClass()
DependencyScopeOwner
getScopeClass
in interface DependencyScopeOwner
Class
.public DependencyScope getOwnedScope()
DependencyScopeOwner
DependencyScope
owned by this DependencyScopeOwner
.getOwnedScope
in interface DependencyScopeOwner
DependencyScope
.protected DependencyScope getFeatureScope()
public Feature getParentFeature()
Feature
getParentFeature
in interface Feature
Feature
.public void setParentFeature(Feature parentFeature)
Feature
setParentFeature
in interface Feature
parentFeature
- A Feature
.public final java.util.List<FeatureView> getActiveViews()
Feature
FeatureView
s.getActiveViews
in interface Feature
List
containing the currently active views as FeatureView
s.public final FeatureView addActiveView(FeatureView view)
Feature
addActiveView
in interface Feature
view
- A FeatureView
to be added.FeatureView
if it was added as a new active FeatureView
.public final FeatureView removeActiveView(FeatureView view)
Feature
removeActiveView
in interface Feature
view
- A FeatureView
to be removed.FeatureView
if it was removed from being an active FeatureView
.protected final void addBackStackView(java.lang.String tag, FeatureView view)
FeatureView
to the HashMap
that contains all
the FeatureView
s of this Feature
that has been added to back stack.tag
- The tag of the added FeatureView
.view
- The FeatureView
that has been added.protected final void removeBackStackView(java.lang.String tag)
FeatureView
from the HashMap
that contains all the
FeatureView
s of this Feature
that has been added to back stack.tag
- The tag specifying the FeatureView
to be removed.public boolean hasForegroundView()
Feature
Feature
is in foreground i.e. it has at least one visible
FeatureView
.hasForegroundView
in interface Feature
boolean
value.public void setActivityFeature(boolean isActivityFeature)
Feature
Feature
to be an Activity Feature that is owned and controlled by
an Activity
.setActivityFeature
in interface Feature
isActivityFeature
- A boolean
value.public boolean isActivityFeature()
Feature
Feature
is set to be an Activity Feature that is owned and controlled
by an Activity
.isActivityFeature
in interface Feature
boolean
value.public boolean isActiveView(FeatureView view)
Feature
FeatureView
is currently active one.isActiveView
in interface Feature
view
- A FeatureView
.boolean
value.public void setFeatureManager(FeatureManager manager)
Feature
FeatureManager
that started this Feature
.setFeatureManager
in interface Feature
manager
- A FeatureManager
.public FeatureContainer getFeatureContainer()
Feature
getFeatureContainer
in interface Feature
FeatureContainer
.public void setFeatureContainer(FeatureContainer container)
Feature
setFeatureContainer
in interface Feature
container
- A FeatureContainer
.public FeatureView showView(java.lang.Class<? extends Presenter> presenterClass, boolean addToBackStack, Params... params)
FeatureView
attached to the specified Presenter
.showView
in interface Feature
presenterClass
- A Class
specifying the Presenter
.addToBackStack
- A boolean
value specifying if the FeatureView
is added
to back stack.params
- Optional Params
.FeatureView
. May be PlugInvoker
.public FeatureView showView(int featureContainerId, java.lang.Class<? extends Presenter> presenterClass, boolean addToBackStack, java.lang.String tag, Params... params)
FeatureView
attached to the specified Presenter
.
The FeatureView
is shown using the specified FeatureContainer
.showView
in interface Feature
featureContainerId
- An id of the FeatureContainer
.presenterClass
- A Class
specifying the Presenter
.addToBackStack
- A boolean
value specifying if the FeatureView
is to
be added to back stack.tag
- A tag for the FeatureView
used for FragmentTransaction
.
May be null
.params
- Optional Params
.FeatureView
. May be PlugInvoker
.public FeatureView showView(FeatureTransitionManager transitionManager, java.lang.Class<? extends Presenter> presenterClass, boolean addToBackStack, java.lang.String tag, Params... params)
FeatureView
attached to the specified Presenter
.
The FeatureView
is shown using the given FeatureTransitionManager
.showView
in interface Feature
transitionManager
- A FeatureTransitionManager
.presenterClass
- A Class
specifying the Presenter
.addToBackStack
- A boolean
value specifying if the FeatureView
is to
be added to back stack.tag
- A tag for the FeatureView
used for FragmentTransaction
.
May be null
.params
- Optional Params
.FeatureView
. May be PlugInvoker
.public void hideView(java.lang.Class<? extends Presenter> presenterClass, boolean addedToBackStack, java.lang.String tag)
FeatureView
attached to the given Presenter
.hideView
in interface Feature
presenterClass
- A Presenter
.addedToBackStack
- A boolean
value specifying if the FeatureView
was
added to backstack.tag
- A tag for the FeatureView
used for FragmentTransaction
.
May be null
.public void hideView(FeaturePresenter presenter, boolean addedToBackStack, java.lang.String tag)
FeatureView
attached to the given Presenter
.hideView
in interface Feature
presenter
- A Presenter
.addedToBackStack
- A boolean
value specifying if the FeatureView
was
added to backstack.tag
- A tag for the FeatureView
used for FragmentTransaction
.
May be null
.public void clearBackStack()
Feature
FragmentManager
.clearBackStack
in interface Feature
public void goBack()
Feature
FeatureView
.protected static java.lang.Class<? extends FeatureView> getClass(FeatureView view)
public boolean isBackPressedEventHandler()
Feature
Feature
handles the back pressed event.isBackPressedEventHandler
in interface Feature
boolean
value.public boolean hasBackStackViews()
Feature
Feature
has any FeatureView
s in back stack.hasBackStackViews
in interface Feature
boolean
value.public boolean canGoBack()
Feature
FeatureView
can be navigated back to.public <T> T plug(java.lang.Class<?> pluginClass)
Class
to PluginBus
.pluginClass
- A Class
Object
public <T> T plug(java.lang.Object plugin)
Object
to this PluginBus
.plugin
- A plugin Object
.public void unplug(java.lang.Object plugin)
Object
to this PluginBus
.plugin
- A plugin Object
.public final void pause()
PluginStateComponent
PluginStateComponent
.pause
in interface PluginStateComponent
pause
in class AbstractPluginStateComponent
public final void pause(boolean finishing)
Feature
Feature
.public final void resume()
PluginStateComponent
PluginStateComponent
.resume
in interface PluginStateComponent
resume
in class AbstractPluginStateComponent
public final void stop()
PluginStateComponent
PluginStateComponent
to be stopped. A stopped
PluginStateComponent
is unplugged from PluginBus
.stop
in interface PluginStateComponent
stop
in class AbstractPluginStateComponent
public final void destroy()
PluginStateComponent
PluginStateComponent
to be destroyed. This method is
automatically invoked for a stopped PluginStateComponent
.destroy
in interface PluginStateComponent
destroy
in class AbstractPluginStateComponent
protected void onPause(boolean finishing)
Feature.pause(boolean)
.finishing
- A boolean
value indicating if the Feature
is
going to be finished i.e. it is not resumed nor restarted anymore.public void onPresenterFinished(Presenter presenter)
PresenterListener
Presenter
when it has been finished by invoking Presenter.finish()
.onPresenterFinished
in interface PresenterListener
presenter
- The finished Presenter
.public void onFeatureContainerPaused(FeatureContainer container, boolean finishing)
Feature
FeatureContainer
has been paused.onFeatureContainerPaused
in interface Feature
container
- A FeatureContainer
.finishing
- A boolean
flag indicating if the FeatureContainer
is finishing.public void onFeatureContainerResumed(FeatureContainer container)
Feature
FeatureContainer
has been resumed.onFeatureContainerResumed
in interface Feature
container
- A FeatureContainer
.public void onFeatureContainerStarted(FeatureContainer container)
Feature
FeatureContainer
has been started.onFeatureContainerStarted
in interface Feature
container
- A FeatureContainer
.public void onFeatureContainerStopped(FeatureContainer container, boolean finishing)
Feature
FeatureContainer
has been stopped.onFeatureContainerStopped
in interface Feature
container
- A FeatureContainer
.finishing
- A boolean
flag indicating if the FeatureContainer
is finishing.