1 2 20 21 package javax.microedition.midlet; 22 23 import javax.microedition.lcdui.Display; 24 25 import com.barteo.emulator.MIDletAccess; 26 import com.barteo.emulator.MIDletBridge; 27 28 public abstract class MIDlet 29 { 30 private boolean destroyed; 31 32 class MIDletAccessor extends MIDletAccess 33 { 34 public MIDletAccessor(MIDlet amidlet) 35 { 36 super(amidlet); 37 } 38 39 public void startApp() throws MIDletStateChangeException 40 { 41 MIDletBridge.setCurrentMIDlet(midlet); 42 getDisplayAccess().updateCommands(); 43 midlet.startApp(); 44 } 45 46 public void pauseApp() 47 { 48 midlet.pauseApp(); 49 } 50 51 public void destroyApp(boolean unconditional) throws MIDletStateChangeException 52 { 53 if (!destroyed) { 54 midlet.destroyApp(unconditional); 55 } 56 getDisplayAccess().clean(); 57 } 58 } 59 60 61 protected MIDlet() 62 { 63 MIDletBridge.setAccess(this, new MIDletAccessor(this)); 64 65 Display.getDisplay(this); 67 destroyed = false; 68 } 69 70 71 protected abstract void startApp() throws MIDletStateChangeException; 72 73 protected abstract void pauseApp(); 74 75 protected abstract void destroyApp(boolean unconditional) throws MIDletStateChangeException; 76 77 78 public final String getAppProperty(String key) 79 { 80 return MIDletBridge.getAppProperty(key); 81 } 82 83 84 public final void notifyDestroyed() 85 { 86 destroyed = true; 87 MIDletBridge.notifyDestroyed(); 88 } 89 90 91 public final void notifyPaused() 92 { 93 } 94 95 } 96 | Popular Tags |