ForegroundEventListenerpublic class ForegroundEventListener extends Object implements com.sun.midp.events.EventListenerListener for LCDUI events (user inputs, etc). |
Fields Summary |
---|
private DisplayContainer | displayContainerActive displays. | private com.sun.midp.events.EventQueue | eventQueueCached reference to the MIDP event queue. |
Constructors Summary |
---|
public ForegroundEventListener(com.sun.midp.events.EventQueue theEventQueue, DisplayContainer theDisplayContainer)The constructor for the foreground event handler for LCDUI.
eventQueue = theEventQueue;
displayContainer = theDisplayContainer;
/*
* All events handled by this object are of NativeEventClass
* and are instance specific events assosiated with some display Id.
* So this listener is able to find an appropriate DisplayEventConsumer
* associated with the displayId field of NativeEvent and
* to call methods of found consumer.
*/
eventQueue.registerEventListener(EventTypes.FOREGROUND_NOTIFY_EVENT,
this);
eventQueue.registerEventListener(EventTypes.BACKGROUND_NOTIFY_EVENT,
this);
|
Methods Summary |
---|
public boolean | preprocess(com.sun.midp.events.Event event, com.sun.midp.events.Event waitingEvent)Preprocess an event that is being posted to the event queue.
return true;
| public void | process(com.sun.midp.events.Event event)Process an event.
NativeEvent nativeEvent = (NativeEvent)event;
/*
* Find ForegroundEventConsumer instance by nativeEvent.intParam4
* and (if not null) call ForegroundEventConsumer methods ...
*/
ForegroundEventConsumer fc =
displayContainer.findForegroundEventConsumer(
nativeEvent.intParam4);
if (fc != null) {
switch (event.getType()) {
case EventTypes.FOREGROUND_NOTIFY_EVENT:
fc.handleDisplayForegroundNotifyEvent();
return;
case EventTypes.BACKGROUND_NOTIFY_EVENT:
fc.handleDisplayBackgroundNotifyEvent();
return;
default:
if (Logging.REPORT_LEVEL <= Logging.WARNING) {
Logging.report(Logging.WARNING, LogChannels.LC_CORE,
"unknown system event (" +
event.getType() + ")");
}
}
}
|
|