|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
java.lang.Objectnet.rim.device.api.system.Application
net.rim.device.api.ui.UiApplication
public abstract class UiApplication
Base class for all device applications that provide a user interface.
A UI application maintains a stack of Screen objects. As it pushes screens onto the stack, it draws them on top of any other screens already on the stack. When the application pops a screen off the stack, it redraws the underlying screens as necessary. Only the screen on the top of the stack receives input events.
Each screen may appear only once in the display stack. The application throws a runtime exception if you attempt to push a single screen onto the stack more than once.
Note that a UI application must follow rules similar to those of traditional Swing applications. In particular
invokeLater()
or
invokeAndWait()
methods.
Alternatively, a worker thread can synchronize on the
event lock (returned by Application.getEventLock()
to
ensure serialized access to the UI. Note that you should only
hold this lock for short periods of time.
Code on the event thread should not block or execute for long periods of time: the system will not dispatch messages, and the event queue can therefore overflow. You can use background threads for long processing.
Field Summary |
---|
Fields inherited from interface net.rim.device.api.ui.UiEngine |
---|
GLOBAL_MODAL, GLOBAL_QUEUE, GLOBAL_SHOW_LOWER |
Constructor Summary | ||
---|---|---|
protected |
UiApplication()
Constructs a new UI application. |
Method Summary | ||
---|---|---|
protected boolean |
acceptsForeground()
Determines if this application can function in the foreground. |
|
void |
activate()
Handles foregrounding event. |
|
void |
dismissStatus(Screen screen)
Deprecated. Use popScreen(Screen) |
|
Screen |
getActiveScreen()
Retrieves active displayed screen. |
|
int |
getScreenCount()
Retrieves the number of screens currently on the display stack. |
|
static UiApplication |
getUiApplication()
Retrieves this UI application object. |
|
UiEngineInstance |
getUiEngineInstance()
Gets the instance of the UiEngine. |
|
boolean |
isPaintingSuspended()
Determines if repainting is currently suspended. |
|
void |
popScreen(Screen screen)
Removes a screen from the display stack, and updates the screen. |
|
void |
pushGlobalScreen(Screen screen,
int priority,
boolean inputRequired)
Deprecated. Use pushGlobalScreen(Screen, int, int) |
|
void |
pushGlobalScreen(Screen screen,
int priority,
int flags)
Push a global screen. |
|
void |
pushModalScreen(Screen screen)
Pushes a modal screen onto the display and paints it. |
|
void |
pushScreen(Screen screen)
Pushes a screen onto the display stack and paints it. |
|
void |
queueStatus(Screen screen,
int priority,
boolean inputRequired)
Deprecated. Use pushGlobalScreen(Screen, int, int) |
|
void |
relayout()
Updates the layout of all screens and repaints. |
|
void |
repaint()
Repaints entire display. |
|
void |
suspendPainting(boolean suspend)
Suspends painting of the UI. |
|
void |
updateDisplay()
Updates the display for all the screens in this application. |
Methods inherited from class java.lang.Object |
---|
equals, getClass, hashCode, notify, notifyAll, toString, wait, wait, wait |
Constructor Detail |
---|
protected UiApplication()
This default constructor is called by UiApplication subclasses.
Method Detail |
---|
public UiEngineInstance getUiEngineInstance()
public final void suspendPainting(boolean suspend)
Normally, whenever a message is handled the screen gets repainted; you can invoke this method to prevent this.
suspendPainting
in interface UiEngine
suspend
- Specify true to suspend repainting; specify false to
re-enable repainting.
IllegalStateException
- If painting is reenabled without previously
being disabled.public final boolean isPaintingSuspended()
isPaintingSuspended
in interface UiEngine
public final void updateDisplay()
updateDisplay
in interface UiEngine
UiEngine.updateDisplay()
public final void popScreen(Screen screen)
popScreen
in interface UiEngine
screen
- Screen to remove.
IllegalArgumentException
- If your screen is not on the stack.public final void pushGlobalScreen(Screen screen, int priority, int flags)
pushGlobalScreen
in interface UiEngine
screen
- The global screen to displaypriority
- The screen's priority (lower value = higher priority)flags
- One or more of GLOBAL_MODAL (block until dismissed),
GLOBAL_QUEUE (insert below screens of the same priority),
and GLOBAL_SHOW_LOWER (don't block the display of lower-priority global screens).public final void pushScreen(Screen screen)
This method is non-blocking, and returns immediately; the screen remains on the stack. This will cause a layout and paint, so be sure to add all the controls to the screen before pushing it.
pushScreen
in interface UiEngine
screen
- Screen to push.public final void pushModalScreen(Screen screen)
Invoke this method to push a modal screen on to the stack and paint
it. This method does not return until you invoke
UiApplication.popScreen(Screen)
. You must invoke this method on
the event thread.
pushModalScreen
in interface UiEngine
screen
- Screen to push.public final int getScreenCount()
getScreenCount
in interface UiEngine
public final void repaint()
Invoke this method to repaint the entire display. It invalidates, and then paints, each screen on the display stack.
repaint
in interface UiEngine
public final void relayout()
You can invoke this method when, for example, global UI settings change.
relayout
in interface UiEngine
public final Screen getActiveScreen()
Invoke this method to retrieve the topmost screen on the display stack (the currently active screen).
getActiveScreen
in interface UiEngine
public final void queueStatus(Screen screen, int priority, boolean inputRequired)
Global status screens appear on top of all other screens on the device, even if the current application is not in the foreground.
If no other status screens are currently displayed, your provided screen appears immediately.
If a status screen is currently displayed, or the queue contains other screens, this method uses your provided priority to determine when to display your screen. If the priority of the currently displayed screen is strictly greater than the newly pushed screen then the new screen will be shown.
This method ensures that your provided screen is bitmap-based.
queueStatus
in interface UiEngine
screen
- Bitmap-based screen to enqueue.priority
- Priority of queued screen. Lower values indicate a higher priority.inputRequired
- True if queued screen requires user input;
otherwise, if the system will automatically dismiss your screen, false.public final void pushGlobalScreen(Screen screen, int priority, boolean inputRequired)
Global screens appear on top of all other screens on the device, even if the current application is not in the foreground.
If no other global screens are currently displayed, your provided screen appears immediately.
If a global screen is currently displayed, or the set contains other global screens, this method uses your provided priority to determine when to display your screen. If the priority of the currently displayed screen is greater than or equal to the newly pushed screen then the new screen will be shown.
This method ensures that your provided screen is bitmap-based.
pushGlobalScreen
in interface UiEngine
screen
- Bitmap-based screen to enqueue.priority
- Priority of global screen.inputRequired
- True if queued screen requires user input;
otherwise, if the system will automatically dismiss your screen, false.public final void dismissStatus(Screen screen)
If this screen is currently showing, this method dismisses the screen, replacing it with the next screen in the queue (if one exists). If the screen is not currently showing, this method simply removes it from the queue.
The invoking application must be the same application which enqueued the screen (the application displaying the screen).
dismissStatus
in interface UiEngine
screen
- Global Screen to remove from the status queue.protected boolean acceptsForeground()
Note that, since all UI applications should be able to interact with the user, this method simply returns true.
acceptsForeground
in class Application
UiApplication
public static final UiApplication getUiApplication()
public void activate()
The system invokes this method when it brings this application to the foreground. By default, this method does nothing. Override this method to perform additional processing when being brought to the foreground.
activate
in class Application
|
|||||||||
PREV CLASS NEXT CLASS | FRAMES NO FRAMES | ||||||||
SUMMARY: NESTED | FIELD | CONSTR | METHOD | DETAIL: FIELD | CONSTR | METHOD |
Copyright 1999-2011 Research In Motion Limited. 295 Phillip Street, Waterloo, Ontario, Canada, N2L 3W8. All Rights Reserved.
Java is a trademark of Oracle America Inc. in the US and other countries.
Legal