SMMDisplayControllerpublic class SMMDisplayController extends DisplayController This class controls which MIDlet's display is in the foreground.
Running only in the AMS Isolate (0) the controller consulted by the MIDlet
proxy list for any foreground when various state changes occur in a MIDlet.
The display controller automatically selects the next foreground if
needed.
From the user perspective when the last MIDlet the user launched is created,
that MIDlet should automatically get the foreground (see the midletCreated
and foregroundRequest methods).
A MIDlet that is paused or destroyed is treated as if it has requested the
background as described above. |
Fields Summary |
---|
private int | lastMidletSuiteIdSuite ID of the last MIDlet in foreground. | private String | lastMidletClassNameClass name of the last MIDlet in foreground. | private MIDletProxy | lastMidletInForegroundThis MIDlet should only get the foreground if it is the last MIDlet. |
Constructors Summary |
---|
public SMMDisplayController(MIDletProxyList theMIDletProxyList, int suiteId, String classname)Construct a DisplayController with a reference to the ProxyList.
super(theMIDletProxyList);
midletProxyList = theMIDletProxyList;
lastMidletSuiteId = suiteId;
lastMidletClassName = classname;
|
Methods Summary |
---|
MIDletProxy | backgroundRequest(MIDletProxy midlet)Handles MIDlet background requests.
If the MIDlet requesting to be put in the background is the foreground
MIDlet, then find a MIDlet to bring to the foreground (see the
findNextForeground method).
MIDletProxy foreground = midletProxyList.getForegroundMIDlet();
if (midlet != foreground) {
// not in the foreground, so don't change the foreground
return foreground;
}
return findNextForegroundMIDlet();
| private MIDletProxy | findNextForegroundMIDlet()Find a MIDlet that wants the foreground. If none wants the foreground
then find one that is not paused, if no find one that is paused
and wants the foreground, then find one that is paused. Only return the
"last MIDlet to have the foreground" if there are not other MIDlets.
Enumeration midlets;
// find the first task that is active and wants foreground
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_ACTIVE) {
continue;
}
if (current.wantsForeground() &&
current != getLastMidletInForeground()) {
return current;
}
}
// find the first task that is active
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_ACTIVE &&
current != getLastMidletInForeground()) {
return current;
}
}
// find the first task that is paused and wants the foreground
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_PAUSED &&
current != getLastMidletInForeground()) {
continue;
}
if (current.wantsForeground() &&
current != getLastMidletInForeground()) {
return current;
}
}
// find the first task that is paused
midlets = midletProxyList.getMIDlets();
while (midlets.hasMoreElements()) {
MIDletProxy current = (MIDletProxy)midlets.nextElement();
if (current.getMidletState() != MIDletProxy.MIDLET_PAUSED &&
current != getLastMidletInForeground()) {
return current;
}
}
return getLastMidletInForeground();
| private MIDletProxy | getLastMidletInForeground()Returns the last MIDlet to that should get the foreground.
if (lastMidletInForeground == null) {
lastMidletInForeground =
midletProxyList.findMIDletProxy(lastMidletSuiteId,
lastMidletClassName);
}
return lastMidletInForeground;
|
|