MIDletSwitcherpublic class MIDletSwitcher extends javax.microedition.lcdui.List implements CommandListenerThe Graphical MIDlet swicher.
Switcher provides a simple user interface to select MIDlets to
bring into foreground from the list of running midlets. |
Fields Summary |
---|
private int | mcountNumber of midlets in minfo. | private RunningMIDletSuiteInfo[] | minfoMIDlet information, class, name, icon; one per MIDlet. | private final int | pitchNumber of reserved elements in minfo array. | ApplicationManager | managerApplication Manager. | AppManagerUI | managerUIApplication Manager main form. | Display | displayDisplay for the Manager MIDlet. | private Command | fgCmdCommand object for "Bring to foreground". |
Constructors Summary |
---|
MIDletSwitcher(AppManagerUI managerUI, ApplicationManager manager, Display display)Create and initialize a new MIDlet Switcher.
super("", Choice.IMPLICIT);
this.manager = manager;
this.managerUI = managerUI;
this.display = display;
mcount = 0;
minfo = new RunningMIDletSuiteInfo[Constants.MAX_ISOLATES];
setSelectCommand(fgCmd);
setFitPolicy(TEXT_WRAP_OFF);
setCommandListener(this); // Listen for the selection
|
Methods Summary |
---|
synchronized void | append(RunningMIDletSuiteInfo msi)Append launched suite info to the list.
checkInfoArraySize();
minfo[mcount++] = msi;
append(msi.displayName, msi.icon);
| private void | checkInfoArraySize()Ensures that info array has enough capacity.
if ((mcount+pitch < minfo.length) || (mcount >= minfo.length)) {
RunningMIDletSuiteInfo[] n =
new RunningMIDletSuiteInfo[mcount+pitch];
System.arraycopy(minfo, 0, n, 0, mcount);
minfo = n;
}
| public synchronized void | commandAction(Command c, Displayable s)Respond to a command issued on any Screen.
if (c == fgCmd) {
//bring to foreground appropriate midlet
int ind = getSelectedIndex();
if (ind != -1) {
manager.moveToForeground(minfo[ind]);
}
display.setCurrent(managerUI);
}
| synchronized boolean | hasItems()If switcher hase any items.
equivalent statement - if there is any launched MIDlet
return (mcount > 0);
| synchronized void | remove(MIDletSuiteInfo msi)Remove suite info from the list.
int pos = -1;
for (int i = 0; i < mcount; i++) {
if (minfo[i] == msi) {
pos = i;
break;
}
}
if (pos >= 0) {
for (int i = pos+1; i < mcount; i++) {
minfo[i-1] = minfo[i];
}
mcount--;
checkInfoArraySize();
delete(pos);
}
|
|