public abstract class Router
extends java.lang.Object
Controllers. Router objects are attached
to Activity/containing ViewGroup pairs. Routers do not directly render or push Views to the container ViewGroup,
but instead defer this responsibility to the ControllerChangeHandler specified in a given transaction.| Constructor and Description |
|---|
Router() |
| Modifier and Type | Method and Description |
|---|---|
void |
addChangeListener(ControllerChangeHandler.ControllerChangeListener changeListener)
Adds a listener for all of this Router's
Controller change events |
abstract android.app.Activity |
getActivity()
Returns this Router's host Activity or
null if it has either not yet been attached to
an Activity or if the Activity has been destroyed. |
java.util.List<RouterTransaction> |
getBackstack()
Returns the current backstack, ordered from root to most recently pushed.
|
int |
getBackstackSize()
Returns the number of
Controllers currently in the backstack |
int |
getContainerId() |
Controller |
getControllerWithInstanceId(java.lang.String instanceId)
Returns the hosted Controller with the given instance id or
null if no such
Controller exists in this Router. |
Controller |
getControllerWithTag(java.lang.String tag)
Returns the hosted Controller that was pushed with the given tag or
null if no
such Controller exists in this Router. |
boolean |
handleBack()
This should be called by the host Activity when its onBackPressed method is called.
|
java.lang.Boolean |
handleRequestedPermission(java.lang.String permission) |
boolean |
hasRootController()
Returns whether or not this Router has a root
Controller |
void |
onActivityDestroyed(android.app.Activity activity) |
void |
onActivityPaused(android.app.Activity activity) |
abstract void |
onActivityResult(int requestCode,
int resultCode,
android.content.Intent data)
This should be called by the host Activity when its onActivityResult method is called if the instanceId
of the controller that called startActivityForResult is not known.
|
void |
onActivityResult(java.lang.String instanceId,
int requestCode,
int resultCode,
android.content.Intent data) |
void |
onActivityResumed(android.app.Activity activity) |
void |
onActivityStarted(android.app.Activity activity) |
void |
onActivityStopped(android.app.Activity activity) |
void |
onCreateOptionsMenu(android.view.Menu menu,
android.view.MenuInflater inflater) |
boolean |
onOptionsItemSelected(android.view.MenuItem item) |
void |
onPrepareOptionsMenu(android.view.Menu menu) |
void |
onRequestPermissionsResult(java.lang.String instanceId,
int requestCode,
java.lang.String[] permissions,
int[] grantResults)
This should be called by the host Activity when its onRequestPermissionsResult method is called.
|
boolean |
popController(Controller controller)
Pops the passed
Controller from the backstack |
boolean |
popCurrentController()
Pops the top
Controller from the backstack |
boolean |
popToRoot()
Pops all
Controllers until only the root is left |
boolean |
popToRoot(ControllerChangeHandler changeHandler)
Pops all
Controller until only the root is left |
boolean |
popToTag(java.lang.String tag)
Pops all
Controllers until the Controller with the passed tag is at the top |
boolean |
popToTag(java.lang.String tag,
ControllerChangeHandler changeHandler)
Pops all
Controllers until the Controller with the passed tag is at the top |
void |
prepareForHostDetach() |
void |
pushController(RouterTransaction transaction)
Pushes a new
Controller to the backstack |
protected void |
pushToBackstack(RouterTransaction entry) |
void |
rebindIfNeeded()
Attaches this Router's existing backstack to its container if one exists.
|
void |
removeChangeListener(ControllerChangeHandler.ControllerChangeListener changeListener)
Removes a previously added listener
|
void |
replaceTopController(RouterTransaction transaction)
Replaces this Router's top
Controller with a new Controller |
void |
restoreInstanceState(android.os.Bundle savedInstanceState) |
void |
saveInstanceState(android.os.Bundle outState) |
void |
setBackstack(java.util.List<RouterTransaction> newBackstack,
ControllerChangeHandler changeHandler)
Sets the backstack, transitioning from the current top controller to the top of the new stack (if different)
using the passed
ControllerChangeHandler |
Router |
setPopsLastView(boolean popsLastView)
If set to true, this router will handle back presses by performing a change handler on the last controller and view
in the stack.
|
void |
setRoot(RouterTransaction transaction)
Sets the root Controller.
|
public abstract android.app.Activity getActivity()
null if it has either not yet been attached to
an Activity or if the Activity has been destroyed.public abstract void onActivityResult(int requestCode,
int resultCode,
android.content.Intent data)
requestCode - The Activity's onActivityResult requestCoderesultCode - The Activity's onActivityResult resultCodedata - The Activity's onActivityResult datapublic void onRequestPermissionsResult(java.lang.String instanceId,
int requestCode,
java.lang.String[] permissions,
int[] grantResults)
Controller with the instanceId passed in.instanceId - The instanceId of the Controller to which this result should be forwardedrequestCode - The Activity's onRequestPermissionsResult requestCodepermissions - The Activity's onRequestPermissionsResult permissionsgrantResults - The Activity's onRequestPermissionsResult grantResultspublic boolean handleBack()
Controller. If that controller doesn't handle it, then it will be popped.public boolean popCurrentController()
Controller from the backstackpublic boolean popController(Controller controller)
Controller from the backstackcontroller - The controller that should be popped from this Routerpublic void pushController(RouterTransaction transaction)
Controller to the backstacktransaction - The transaction detailing what should be pushed, including the Controller,
and its push and pop ControllerChangeHandler, and its tag.public void replaceTopController(RouterTransaction transaction)
Controller with a new Controllertransaction - The transaction detailing what should be pushed, including the Controller,
and its push and pop ControllerChangeHandler, and its tag.public int getContainerId()
public Router setPopsLastView(boolean popsLastView)
public boolean popToRoot()
Controllers until only the root is leftControllers were popped in order to get to the root transactionpublic boolean popToRoot(ControllerChangeHandler changeHandler)
Controller until only the root is leftchangeHandler - The ControllerChangeHandler to handle this transactionControllers were popped in order to get to the root transactionpublic boolean popToTag(java.lang.String tag)
Controllers until the Controller with the passed tag is at the toptag - The tag being popped toControllers were popped in order to get to the transaction with the passed tagpublic boolean popToTag(java.lang.String tag,
ControllerChangeHandler changeHandler)
Controllers until the Controller with the passed tag is at the toptag - The tag being popped tochangeHandler - The ControllerChangeHandler to handle this transactionController with the passed tag is now at the toppublic void setRoot(RouterTransaction transaction)
Controllers are currently in the backstack, they will be removed.transaction - The transaction detailing what should be pushed, including the Controller,
and its push and pop ControllerChangeHandler, and its tag.public Controller getControllerWithInstanceId(java.lang.String instanceId)
null if no such
Controller exists in this Router.instanceId - The instance ID being searched forpublic Controller getControllerWithTag(java.lang.String tag)
null if no
such Controller exists in this Router.tag - The tag being searched forpublic int getBackstackSize()
Controllers currently in the backstackpublic java.util.List<RouterTransaction> getBackstack()
public void setBackstack(java.util.List<RouterTransaction> newBackstack, ControllerChangeHandler changeHandler)
ControllerChangeHandlernewBackstack - The new backstackchangeHandler - An optional change handler to be used to handle the root view of transitionpublic boolean hasRootController()
Controllerpublic void addChangeListener(ControllerChangeHandler.ControllerChangeListener changeListener)
Controller change eventschangeListener - The listenerpublic void removeChangeListener(ControllerChangeHandler.ControllerChangeListener changeListener)
changeListener - The listener to be removedpublic void rebindIfNeeded()
public final void onActivityResult(java.lang.String instanceId,
int requestCode,
int resultCode,
android.content.Intent data)
public final void onActivityStarted(android.app.Activity activity)
public final void onActivityResumed(android.app.Activity activity)
public final void onActivityPaused(android.app.Activity activity)
public final void onActivityStopped(android.app.Activity activity)
public void onActivityDestroyed(android.app.Activity activity)
public void prepareForHostDetach()
public void saveInstanceState(android.os.Bundle outState)
public void restoreInstanceState(android.os.Bundle savedInstanceState)
public final void onCreateOptionsMenu(android.view.Menu menu,
android.view.MenuInflater inflater)
public final void onPrepareOptionsMenu(android.view.Menu menu)
public final boolean onOptionsItemSelected(android.view.MenuItem item)
public final java.lang.Boolean handleRequestedPermission(java.lang.String permission)
protected void pushToBackstack(RouterTransaction entry)