java.lang.Object | |
↳ | com.neomades.app.Screen |
![]() |
This class is the abstract base class for all screens. A Screen can be pushed
to the real device screen by calling the pushScreen(Class)
method. There can be only one screen showing at each time.
Screens in the application are managed as screen stack (managed by the controller). When a new screen is started, it is placed on the top of the stack and becomes the running screen -- the previous screen always remains below it in the stack, and will not come to the foreground again until the new screen exits.
A screen has essentially four states:onCreate()
is called.onResume()
method is called
before entering in this stateonPause()
method is called before entering in this stateonDestroy()
method is called to clean up screenConstants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
int | TITLE_BAR_STYLE_BLACK | iOS TitleBar style black | |||||||||
int | TITLE_BAR_STYLE_DEFAULT | iOS TitleBar style default |
[Expand]
Inherited Constants | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() | |||||||||||
![]() | |||||||||||
![]() | |||||||||||
![]() |
Fields | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
protected final Controller | controller | navigation controller |
Public Constructors | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Screen()
Do not call this constructor at any time.
|
Public Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
Keyboard |
getKeyboard()
Returns a | ||||||||||
void |
onReceiveEvent(Event event)
Called when this screen has received an event (inside UI-Thread).
| ||||||||||
void |
send(Event event)
Sends an event into Application's event bus.
| ||||||||||
final void |
setTitle(int resId)
Sets the title of the screen, which will be displayed at the top of the
screen
| ||||||||||
final void |
setTitle(String title)
Sets the title of the screen, which will be displayed at the top of the
screen.
|
Protected Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
final void |
applyTitleBackgroundColorToStatusBar()
Configure the color of the status bar to be the same as the title bar.
| ||||||||||
View | findView(int viewId) | ||||||||||
EventBus |
getApplicationEventBus()
Gets the application's eventBus if exist.
| ||||||||||
View |
getContent()
Gets the content of this screen.
| ||||||||||
final Controller |
getController()
Gets the navigation Controller instance.
| ||||||||||
final int |
getOrientation()
Returns the current device orientation.
| ||||||||||
ScreenParams |
getScreenParams()
Return the parameters.
| ||||||||||
final void |
hideTitleBarLeftMenuItem()
Hide the default "Home" button item that appears in the left menu of the
Title Bar of the first screen in the Android version of the application.
| ||||||||||
void |
onContentError(ContentError error)
Called when an error has been broadcasting to this screen.
| ||||||||||
void |
onContentResponse(ContentResponse response)
Called when a content response has been broadcasting to this screen.
| ||||||||||
abstract void |
onCreate()
This method has to be overridden to initialize the screen : creation and
layout of UI elements, initializations, ...
| ||||||||||
void |
onDestroy()
This method can be overridden to provide a specific behavior when the screen
is destroyed.
| ||||||||||
void |
onKeyEvent(KeyEvent keyEvent)
Called when a key is dispatched to a screen.
| ||||||||||
void |
onMenuAction(MenuItem item)
This method can be overridden to provide a specific behavior when a item of
the Menu is chosen.
| ||||||||||
void |
onMenuCreate(Menu menu)
This method can be overridden to retrieve the menu corresponding to this
screen.
| ||||||||||
void |
onOrientationChanged(int orientation)
Called when the screen orientation has changed.
| ||||||||||
void |
onPause()
This method can be overridden to provide a specific behavior when the screen
is paused.
| ||||||||||
void |
onResume()
This method can be overridden to provide a specific behavior when the screen
is resumed, after it has been paused.
| ||||||||||
void |
onTouchEvent(TouchEvent touchEvent)
Called when a touch is dispatched to a screen.
| ||||||||||
void |
postQuery(Query query)
Posts a query to a
ContentManager . | ||||||||||
void |
registerContentError()
Registers this screen to receive all
ContentError event's type. | ||||||||||
void |
registerEvent(String type)
Registers this screen to receive the given
ContentResponse
event's type. | ||||||||||
void |
registerEvents()
This method is deprecated.
Use
registerContentError() instead.
| ||||||||||
void |
setActivityIndicatorVisible(boolean visible)
Shows or hides the activity indicator.
| ||||||||||
final void |
setBackButtonText(String backButtonText)
Replaces the "Back" button text for the current screen.
| ||||||||||
final void |
setBackButtonTextColor(Color backButtonTextColor)
Changes the "Back" button text color for the current screen.
| ||||||||||
final void |
setBackground(Background background)
Set the background for this screen.
| ||||||||||
final void |
setBackgroundColor(Color color)
Sets the background color of the screen.
| ||||||||||
final void |
setBackgroundImage(int imageID)
Set the background image for this screen.
| ||||||||||
final void |
setBackgroundImage(Image image)
Set the background image for this screen.
| ||||||||||
void |
setContent(int layoutResId)
Sets the content of this screen, with the root view of the layout.
| ||||||||||
void |
setContent(View content)
Sets the content of this screen, with the view passed in parameter.
| ||||||||||
final void |
setFullscreenMode(boolean fullscreen)
Hides title bar and bottom toolbar.
| ||||||||||
final void |
setResult(ScreenParams result)
Close the screen and send result to the
ScreenResultListener . | ||||||||||
final void |
setSupportedOrientation(int orientation)
Forces the screen to be in portrait and/or landscape mode.
| ||||||||||
final void |
setTitleBackground(Background background)
Sets the title bar background
| ||||||||||
final void |
setTitleBackgroundColor(Color bgColor)
Sets the title bar background color
| ||||||||||
final void |
setTitleBackgroundImage(Image image)
Sets the title bar background image
| ||||||||||
final void |
setTitleBackgroundImage(int resImage)
Sets the title bar background image
| ||||||||||
final void |
setTitleBarStyle(int style)
Sets the iOS title bar style
| ||||||||||
final void |
setTitleBarTranslucent(boolean translucent)
Sets the title bar translucent or not
| ||||||||||
final void |
setTitleBarVisible(boolean visible)
Set the navigation bar (iOS), action bar (Android) or title bar visible or
not without animation.
| ||||||||||
final void |
setTitleBarVisibleAnimated(boolean visible)
Set the navigation bar (iOS), action bar (Android) or title bar visible or
not with animation.
| ||||||||||
final void |
setTitleColor(Color titleColor)
Sets the title text color
| ||||||||||
final void |
setTitleFont(Font font)
Sets the title font
| ||||||||||
void |
setTitleKeepNativeCase(boolean enabled)
Enables or disables the title native case.
| ||||||||||
final void |
setTitleView(View view)
Replaces the title view (inside the title bar) with a custom View.
| ||||||||||
void |
unregisterEvent(String type)
Unregisters this screen to receive the given event's type.
| ||||||||||
void |
unregisterEvents()
Unregisters this screen to receive all event's type.
|
[Expand]
Inherited Methods | |||||||||||
---|---|---|---|---|---|---|---|---|---|---|---|
![]() |
iOS TitleBar style black
iOS TitleBar style default
Do not call this constructor at any time.
DO NOT OVERRIDE THE CONSTRUCTOR
Returns a Keyboard
instance for the current Screen
.
Keyboard
instance
Called when this screen has received an event (inside UI-Thread).
Prefer overriding onContentResponse(ContentResponse)
or
onContentError(ContentError)
.
By default this method switches event from Content or Error.
A typical overriden method could be:public void onReceiveEvent(Event event) { if (event.hasType("My Type")) { // do some stuff for my special events } else { // let calling onContentResponse(ContentResponse)() or // onContentError(ContentError)) for other events super.onReceiveEvent(event); } }
Sends an event into Application's event bus.
event | the event to send |
---|
Sets the title of the screen, which will be displayed at the top of the screen
resId | the id of the string representing the new title of the screen |
---|
Sets the title of the screen, which will be displayed at the top of the screen.
If the title parameter is null or an empty String, the title bar will be hidden.
title | the new title |
---|
Configure the color of the status bar to be the same as the title bar. This is the default behavior on iOS.
viewId | the view Id declared into the XML layout set with the
setContent(int) method or in the java code |
---|
IllegalArgumentException | the view ID has not been recognized |
---|---|
IllegalStateException | the method has been called before setContent() method. |
Gets the application's eventBus if exist.
Gets the content of this screen.
Return the parameters. This method will return null
if called
before onCreate()
.
Hide the default "Home" button item that appears in the left menu of the Title Bar of the first screen in the Android version of the application. In iOS, hides the default "back" button in the navigation bar.
Called when an error has been broadcasting to this screen. (inside a UI-Thread)
Called when a content response has been broadcasting to this screen. (inside a UI-Thread)
This method has to be overridden to initialize the screen : creation and layout of UI elements, initializations, ...
Most screen UI initializations call setContent()
methods, either
with a view built programmatically or a view loaded with a XML layout.
When screen is created, it is automatically registered to listen all
ContentError with registerContentError()
method.
Method onContentError(ContentError)
will be call for each received
error.
This method can be overridden to provide a specific behavior when the screen is destroyed.
When screen is destroyed, it is automatically unregistered to all event types
with unregisterEvents()
method.
Called when a key is dispatched to a screen.
Note: If you have long operations to perform, you should make sure to do them in other threads or asynchronously.
Performing long operations such as network access may block the whole user
interface. If the UI is blocked for more than a few seconds, some platforms
like Android
will show a message popup to inform to the end-used
that the operation is too long.
keyEvent | The object containing information about the event |
---|
This method can be overridden to provide a specific behavior when a item of the Menu is chosen.
item | the item that has been chosen |
---|
This method can be overridden to retrieve the menu corresponding to this screen. In this method, you can add items to the menu.
If the menu has no children, then the menu will not be shown for this screen.
menu | the instance of the menu corresponding to this screen |
---|
Called when the screen orientation has changed. If the screen orientation is
locked in portrait or landscape mode, onOrientationChanged(int)
will
not be called.
This method can be overridden to provide a specific behavior when the screen is paused.
A screen can enter the pause state when :
controller
has pushed or popped another screenWhen a dialog is shown or hidden, this method is not called.
This method can be overridden to provide a specific behavior when the screen is resumed, after it has been paused.
controller
has pushed or popped another screenWhen a dialog is shown or hidden, this method is not called.
Called when a touch is dispatched to a screen.
Note: If you have long operations to perform, you should make sure to do them in other threads or asynchronously.
Performing long operations such as network access may block the whole user
interface. If the UI is blocked for more than a few seconds, some platforms
like Android
will show a message popup to inform to the end-used
that the operation is too long.
touchEvent | The object containing information about the event |
---|
Registers this screen to receive all ContentError
event's type.
This method is automatically call after onCreate()
.
Registers this screen to receive the given ContentResponse
event's type.
type | event's type |
---|
Shows or hides the activity indicator.
visible | true to show it |
---|
Replaces the "Back" button text for the current screen.
On iOS it changes the left back button of the navigation bar.
On Android this method does nothing.
Changes the "Back" button text color for the current screen.
On iOS it changes the left back button text color of the navigation bar.
On Android this method does nothing.
Set the background for this screen. If the background is null
,
the background of the screen will be removed.
background | the background to use |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the background color of the screen. If the background color is
null
, the background will be removed.
color | the background color of the screen |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Set the background image for this screen.
If the size of the image is different than the screen size, then the image will be stretched in order to fill the screen's background.
You should prefer JPG image for performance reason.
imageID | the id of the image to use for the background |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Set the background image for this screen.
If the size of the image is different than the screen size, then the image will be stretched in order to fill the screen's background.
If the background image is null
, the background will be removed.
image | the image to use for the background (null to remove
the current background image) |
---|
CrossThreadException | if the method is called from outside the UI-Thread |
---|
Sets the content of this screen, with the root view of the layout.
To get a sub view of the content,
layoutResId | Resources ID of the XML layout |
---|
ResourceNotFoundException | If the layout resource ID has not been recognized |
---|
Sets the content of this screen, with the view passed in parameter.
If the content
parameter is null, the content of this screen
will be empty.
content | the content of this screen |
---|
Hides title bar and bottom toolbar. Used for splashscreens. Be careful using this feature, because in iOS, the title bar (navigation bar) has back button. Hiding the title bar could avoid the end-user going to the previous screen.
fullscreen | true to enable fullscreen mode |
---|
Close the screen and send result to the ScreenResultListener
.
result | information about result |
---|
Sets the title bar background
background | the background of the title bar |
---|
Sets the title bar background color
bgColor | the background color of the title bar |
---|
Sets the title bar background image
image | the background image of the title bar |
---|
Sets the title bar background image
resImage | the background image of the title bar |
---|
Sets the iOS title bar style
style | TITLE_BAR_STYLE_DEFAULT or TITLE_BAR_STYLE_BLACK |
---|
Sets the title bar translucent or not
Set the navigation bar (iOS), action bar (Android) or title bar visible or not without animation.
In Android if action bar is activated in the application (done by using
setActionBarEnabled(boolean)
in the application main
class), it always shows and hides with animation.
visible | true to set the title bar visible |
---|
Set the navigation bar (iOS), action bar (Android) or title bar visible or not with animation.
In iOS, the layout at the root of the Screen will be stretched to match the
new screen size (if in MATCH_PARENT
). This will be animated too.
In Android the action bar must be activated in the application (done by using
setActionBarEnabled(boolean)
in the application main
class).
Before Android 4.0, the action bar will display with animation but will hide without.
visible | true to set the title bar visible |
---|
Sets the title text color
titleColor | the color for the title |
---|
Sets the title font
font | the font for the title |
---|
Enables or disables the title native case.
enabled | (by default the value is true). |
---|
Replaces the title view (inside the title bar) with a custom View.
view | a view to replace title area inside the title bar or null to let the default behaviour |
---|
Unregisters this screen to receive the given event's type.
type | event's type |
---|
Unregisters this screen to receive all event's type.
This method is automatically call before onDestroy()
.