Revision: 2731
http://sourceforge.net/p/swingme/code/2731
Author: yuranet
Date: 2023-04-13 16:21:54 +0000 (Thu, 13 Apr 2023)
Log Message:
-----------
removed unused code and unused threads
Modified Paths:
--------------
AndroidME/src_Android/net/yura/android/AndroidMeActivity.java
AndroidME/src_Android/net/yura/android/AndroidMeApp.java
AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
AndroidME/src_MIDP/javax/microedition/lcdui/Display.java
AndroidME/src_MIDP/javax/microedition/lcdui/Displayable.java
AndroidME/src_MIDP/javax/microedition/lcdui/TextBox.java
Modified: AndroidME/src_Android/net/yura/android/AndroidMeActivity.java
===================================================================
--- AndroidME/src_Android/net/yura/android/AndroidMeActivity.java 2023-04-01 13:18:14 UTC (rev 2730)
+++ AndroidME/src_Android/net/yura/android/AndroidMeActivity.java 2023-04-13 16:21:54 UTC (rev 2731)
@@ -60,13 +60,7 @@
Vector<String[]> jadMidlets = AndroidMeApp.getJadMidlets();
if (jadMidlets.size() == 1) {
- // Start MIDlet
- new Thread() {
- public void run() {
-// waitForDefaultView(); TODO:!!!!
- startMIDlet();
- }
- }.start();
+ startMIDlet();
}
else if (jadMidlets.size() > 1) {
ListView listView = new ListView(AndroidMeActivity.this);
@@ -91,27 +85,25 @@
}
public void startMIDlet() {
- // Needs to run on the UI thread, otherwise some of the API's will not start
- AndroidMeApp.getIntance().invokeLater(new Runnable() {
- public void run() {
- try {
- MIDlet midlet = AndroidMeApp.getMIDlet();
- Display display = Display.getDisplay(midlet);
- if (display.hiddenDisplay!=null) {
- display.setCurrent(display.hiddenDisplay);
- }
- midlet.doStartApp();
- onMidletStarted();
- }
- catch (Exception ex) {
- throw new RuntimeException("unable to start MIDlet: ", ex);
- }
+ try {
+ MIDlet midlet = AndroidMeApp.getMIDlet();
+ Display display = Display.getDisplay(midlet);
+ if (display.hiddenDisplay != null) {
+ display.setCurrent(display.hiddenDisplay);
}
- });
+ midlet.doStartApp();
+ onMidletStarted();
+ }
+ catch (Exception ex) {
+ throw new RuntimeException("unable to start MIDlet", ex);
+ }
}
+ /**
+ * hook for doing something after the midlet has been started
+ */
public void onMidletStarted() {
- // hook for doing something after the midlet has been started
+ // default implementation is empty
}
private boolean foreground;
@@ -263,8 +255,14 @@
try {
waitForDefaultView();
- AndroidMeApp.createMIDlet(midletClassName);
- startMIDlet();
+ // Needs to run on the UI thread, otherwise some of the API's will not start
+ AndroidMeApp.getIntance().invokeLater(new Runnable() {
+ public void run() {
+ AndroidMeApp.createMIDlet(midletClassName);
+ startMIDlet();
+ }
+ });
+
} catch (Throwable ex) {
Logger.warn("error starting " + midletClassName, ex);
}
Modified: AndroidME/src_Android/net/yura/android/AndroidMeApp.java
===================================================================
--- AndroidME/src_Android/net/yura/android/AndroidMeApp.java 2023-04-01 13:18:14 UTC (rev 2730)
+++ AndroidME/src_Android/net/yura/android/AndroidMeApp.java 2023-04-13 16:21:54 UTC (rev 2731)
@@ -48,21 +48,22 @@
return instance.midlet;
}
- // TODO: Async
- public static void createMIDlet(final String className) throws Exception {
+ /**
+ * Needs to run on the UI thread, otherwise some of the API's will not start
+ */
+ public static void createMIDlet(final String className) {
- // Needs to run on the UI thread, otherwise some of the API's will not start
- instance.handler.post(new Runnable() {
- public void run() {
- try {
- Class<?> midletClass = Class.forName(className);
- instance.midlet = (MIDlet) midletClass.newInstance();
- } catch (Exception ex) {
- throw new RuntimeException("unable to start MIDlet: "
- + className, ex);
- }
- }
- });
+ if (Thread.currentThread() != Looper.getMainLooper().getThread()) {
+ throw new IllegalStateException("not main thread");
+ }
+
+ try {
+ Class<?> midletClass = Class.forName(className);
+ instance.midlet = (MIDlet) midletClass.newInstance();
+ }
+ catch (Exception ex) {
+ throw new RuntimeException("unable to start MIDlet: " + className, ex);
+ }
}
public static void waitForMIDletCreation() {
@@ -106,7 +107,8 @@
String midletClassName = jadMidlets.elementAt(0)[2];
createMIDlet(midletClassName);
}
- } catch (Throwable e) {
+ }
+ catch (Throwable e) {
Logger.warn("error starting", e);
}
}
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2023-04-01 13:18:14 UTC (rev 2730)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Canvas.java 2023-04-13 16:21:54 UTC (rev 2731)
@@ -72,8 +72,12 @@
}
+ /**
+ * in MIDP-2 this controls if the system displays the {@link Command} at the bottom of the screen
+ * Only fullscreen mode is supported on android as there are no soft keys.
+ */
public void setFullScreenMode(boolean fullScreen) {
- // do nothing, is this possible on android?
+ // do nothing
}
public int getGameAction(int keyCode) {
@@ -422,13 +426,6 @@
return linearLayout;
}
- @Override
- public void initDisplayable(MIDlet midlet) {
-// JP if (this.canvasView == null) {
-// this.canvasView = new CanvasView(midlet.getActivity());
-// }
- }
-
protected javax.microedition.lcdui.Graphics getGraphics() {
return this.canvasView.graphics;
}
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Display.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Display.java 2023-04-01 13:18:14 UTC (rev 2730)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Display.java 2023-04-13 16:21:54 UTC (rev 2731)
@@ -125,20 +125,12 @@
// TextBox is special... we don't really have any UI
if (newCurrent instanceof TextBox) {
- newCurrent.initDisplayable(null);
+ ((TextBox) newCurrent).initDisplayable();
return;
}
- Displayable old = current;
current = newCurrent;
- if (old != null) {
- old.setCurrentDisplay(null);
- }
-
- newCurrent.setCurrentDisplay(Display.this);
- newCurrent.initDisplayable(Display.this.midlet);
-
View view = newCurrent.getView();
if (view != null) {
activity.setContentView(view);
@@ -156,7 +148,6 @@
// Wait for the view to be set...
//YURA: remove this AndroidMeApp.getIntance().invokeAndWait(new Thread());
}
-
}
/**
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/Displayable.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/Displayable.java 2023-04-01 13:18:14 UTC (rev 2730)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/Displayable.java 2023-04-13 16:21:54 UTC (rev 2731)
@@ -11,7 +11,6 @@
public abstract class Displayable {
protected CommandListener commandListener;
private Vector<Command> commands = new Vector<Command>();
- private Display currentDisplay;
public void addCommand(Command command) {
boolean added = false;
@@ -61,16 +60,6 @@
return h;//(h <= 0) ? AndroidMeActivity.DEFAULT_ACTIVITY.getScreenHeight() : h;
}
- public Display getCurrentDisplay() {
- return currentDisplay;
- }
-
- public void setCurrentDisplay(Display currentDisplay) {
- this.currentDisplay = currentDisplay;
- }
-
- public abstract void initDisplayable(MIDlet midlet);
-
public abstract View getView();
Modified: AndroidME/src_MIDP/javax/microedition/lcdui/TextBox.java
===================================================================
--- AndroidME/src_MIDP/javax/microedition/lcdui/TextBox.java 2023-04-01 13:18:14 UTC (rev 2730)
+++ AndroidME/src_MIDP/javax/microedition/lcdui/TextBox.java 2023-04-13 16:21:54 UTC (rev 2731)
@@ -94,8 +94,7 @@
/**
* this is called so start the text entry by AndroidME
*/
- @Override
- public void initDisplayable(MIDlet midlet) {
+ public void initDisplayable() {
// we need to call this so the keyboard is opened
if (currentCanvasView != null) {
@@ -104,7 +103,6 @@
// need to call this after we bring the keyboard up, or that does not work
textBoxView.start(this);
-
}
public int getMaxSize() {
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|