java.lang.Object | |
↳ | com.neomades.app.Controller |
The controller manages navigation between screens of the application.
Screens can be pushed to the real screen, and popped when they are not needed anymore.
The controller works like a stack, it keeps trace of your screens, so the user can navigate between the screens with the BACK key of the device or BACK button in the title bar for IOS platforms.
Dialogs can also be shown from the controller.
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Screen |
getCurrent()
Returns the current screen.
| ||||||||||
Controller |
getParentController()
Returns the parent navigation controller used in some cases like
SlideScreen to manage a stack of screens. | ||||||||||
Preferences | getPreferences(String name) | ||||||||||
Controller |
getRootController()
Returns the root navigation controller used by the application to manage a
stack of screens.
| ||||||||||
int |
getScreenCount()
Returns the screen stack size.
| ||||||||||
Vibrator |
getVibrator()
See
Vibrator.getVibrator() . | ||||||||||
void |
hideDialog()
Hides the current dialog.
| ||||||||||
void |
popScreen()
This method removes a screen from the real screen.
| ||||||||||
void |
pushScreen(Class screen, ScreenParams parameters)
Pushes a screen to the real screen.
| ||||||||||
void |
pushScreen(Class screen)
Pushes a screen to the real screen.
| ||||||||||
void |
pushScreen(Class screen, ScreenParams parameters, ScreenResultListener resultListener)
Pushes a screen to the real screen.
| ||||||||||
void |
replaceCurrentScreen(Class screen, ScreenParams parameters)
This method replaces the current top screen to the display.
| ||||||||||
void |
replaceCurrentScreen(Class screen)
This method replaces the current top screen to the display.
| ||||||||||
void |
resetScreenStack(Class screen, ScreenParams parameters)
This method clears the history and pushes only one screen to be displayed
with parameters.
| ||||||||||
void |
resetScreenStack(Class screen)
This method clears the history and pushes only one screen to be displayed.
| ||||||||||
void |
runOnBackgroundThread(Runnable action)
Calls
action.run() asynchronously on the Background-Thread. | ||||||||||
void |
runOnUiThread(Runnable action)
Calls
action.run() asynchronously on the UI-Thread. | ||||||||||
void |
scheduleService(Class service)
Starts a
Service and runs it approximatively every 30 minutes. | ||||||||||
void |
scheduleService(Class service, long interval)
Starts a
Service and runs it periodically. | ||||||||||
void |
showBottomSheet(ModalBottomSheet bottomSheet)
Shows a bottom sheet in top of the current screen.
| ||||||||||
void |
showDialog(Dialog dialog)
Shows a dialog in top of the current screen.
| ||||||||||
void |
startService(Class service)
Starts a
Service now and run it once. | ||||||||||
void |
stopService(Class service)
Stops the
Service given as parameter. |
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
Returns the parent navigation controller used in some cases like
SlideScreen
to manage a stack of screens.
Same method as Preferences.getPreferences(String)
.
name | name of the Preferences object. |
---|
Returns the root navigation controller used by the application to manage a stack of screens.
Returns the screen stack size.
Screen
in this controller stack.
See Vibrator.getVibrator()
.
Same method as Vibrator.getVibrator()
.
Hides the current dialog.
Warning : this method has to be called from the UI-Thread. Use
runOnUiThread(Runnable)
if you are on another thread
CrossThreadException | if the method is called from outside the UI-Thread |
---|
This method removes a screen from the real screen.
If another screen is already present in the internal stack of screens, the current screen is popped, and the previous screen is set to the real screen.
If the popScreen()
method is called and no screen is present into
the stack, the application will exit in some platforms (all but iOS)
Pushes a screen to the real screen.
This method takes the class given in parameter, constructs a new instance of it, and call onCreate() on it. This method pushes the screen on an internal stack, so that if popScreen is called, the previous screen is set back to the real screen.
Same method as pushScreen(Class, ScreenParams, null)
.
screen | the type of screen to be built and pushed with additional information |
---|---|
parameters | additional information given to the pushed screen |
Pushes a screen to the real screen.
This method takes the class given in parameter, constructs a new instance of it, and call onCreate() on it. This method pushes the screen on an internal stack, so that if popScreen is called, the previous screen is set back to the real screen.
Same method as pushScreen(Class, null, null)
.
screen | the type of screen to be built and pushed |
---|
Pushes a screen to the real screen.
This method takes the class given in parameter, constructs a new instance of it, and call onCreate() on it. This method pushes the screen on an internal stack, so that if popScreen is called, the previous screen is set back to the real screen.
screen | the type of screen to be built and pushed with additional information |
---|---|
parameters | additional information given to the pushed screen |
resultListener | screen which waiting for a result from the pushed screen |
This method replaces the current top screen to the display.
The difference with pushScreen(Class)
is that the history will
replace the old current screen.
If the method is called when no screen is present into the stack, then the
method will do exactly the same thing as
pushScreen(Class, ScreenParams)
method.
screen | the screen to be built and displayed. |
---|---|
parameters | additional information given to the pushed screen |
This method replaces the current top screen to the display.
The difference with pushScreen(Class)
is that the history will
replace the old current screen.
If the method is called when no screen is present into the stack, then the
method will do exactly the same thing as pushScreen(Class)
method.
screen | the screen to be built and displayed. |
---|
This method clears the history and pushes only one screen to be displayed with parameters.
If the method is called when no screen is present into the stack, then the
method will do exactly the same thing as
pushScreen(Class, ScreenParams)
method.
screen | the screen to be built and displayed. |
---|---|
parameters | additional information given to the pushed screen |
This method clears the history and pushes only one screen to be displayed.
If the method is called when no screen is present into the stack, then the
method will do exactly the same thing as pushScreen(Class)
method.
screen | the screen to be built and displayed. |
---|
Calls action.run()
asynchronously on the Background-Thread. This
method should be used when an application needs to do long operation or
non-UI operation.
action | the action to run |
---|
Calls action.run()
asynchronously on the UI-Thread. This method
should be used when an application thread needs to update the GUI.
If already on the UI-Thread, the Runnable is run immediately.
action | the action to run |
---|
Starts a Service
and runs it approximatively every 30 minutes.
The time interval may vary depending on the platform.
This function will throw SecurityException
if you do not
have permission to start the given service. The service class should be
declared in the URS file.
service | the service to run |
---|
Starts a Service
and runs it periodically.
The time interval can be specified directly in millisecond but prefer to
use INTERVAL_MINUTE
, INTERVAL_30_MINUTES
,
INTERVAL_HOUR
or INTERVAL_DAY
. If the
time interval is too short (less than several minutes), the system will
try to respect it as much as possible but if it can't it will apply its
own period. In all cases, the period is not exact and the service
execution may sometimes be delayed for several minutes.
This function will throw SecurityException
if you do not
have permission to start the given service. The service class should be
declared in the URS file.
In iOS, the service will not be stopped after the application is paused or killed however it is the iOS system that will decide when the service fires, whatever is the schedule time.
In Android, the minimum schedule interval is 15 minutes. If less, the interval will be set to 15 minutes.
service | the service to run |
---|---|
interval | period interval in millisecond |
Shows a bottom sheet in top of the current screen.
Warning : this method has to be called from the UI-Thread. Use
runOnUiThread(Runnable)
if you are on another thread
When a bottom sheet is shown, the screen behind it will keep its state (not paused, not resumed).
bottomSheet | the sheet to show |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Shows a dialog in top of the current screen.
Warning : this method has to be called from the UI-Thread. Use
runOnUiThread(Runnable)
if you are on another thread
When a dialog is shown, the screen behind it will keep its state (not paused, not resumed).
dialog | the popup to show |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Starts a Service
now and run it once. A little delay of a few
second may be observed before the service is executed.
This function will throw SecurityException
if you do not
have permission to start the given service. The service class should be
declared in the URS file.
service | the service to start |
---|
Stops the Service
given as parameter.
service | the service to stop |
---|