Revision: 2685
http://sourceforge.net/p/swingme/code/2685
Author: yuranet
Date: 2023-01-25 20:42:04 +0000 (Wed, 25 Jan 2023)
Log Message:
-----------
allow setting params on new controllers
Modified Paths:
--------------
iOSME/src/javax/microedition/midlet/MIDlet.java
Modified: iOSME/src/javax/microedition/midlet/MIDlet.java
===================================================================
--- iOSME/src/javax/microedition/midlet/MIDlet.java 2023-01-25 17:36:49 UTC (rev 2684)
+++ iOSME/src/javax/microedition/midlet/MIDlet.java 2023-01-25 20:42:04 UTC (rev 2685)
@@ -5,6 +5,7 @@
import net.yura.ios.iOSUtil;
import net.yura.mobile.util.Url;
import java.io.File;
+import java.lang.reflect.Method;
import java.net.URLConnection;
import java.util.Map;
import javax.microedition.io.ConnectionNotFoundException;
@@ -122,6 +123,14 @@
if (isProtoNative) {
Class<?> myClass = Class.forName(nsUrl.host());
UIViewController viewController = ((UIViewController)myClass.getMethod("alloc").invoke(null)).init();
+
+ if (nsUrl.query() != null) {
+ Map<String, String> options = Url.toHashtable(nsUrl.query());
+ for (Map.Entry<String, String> entry : options.entrySet()) {
+ setProperty(viewController, entry.getKey(), entry.getValue());
+ }
+ }
+
UINavigationController rootViewController = (UINavigationController) UIApplication.sharedApplication().keyWindow().rootViewController();
rootViewController.pushViewControllerAnimated(viewController, true);
}
@@ -297,6 +306,12 @@
return false;
}
+ private static void setProperty(Object viewController, String key, String value) throws Exception {
+ Class<?> objClass = viewController.getClass();
+ Method setter = objClass.getMethod("set" + key.substring(0, 1).toUpperCase() + key.substring(1), String.class);
+ setter.invoke(viewController, value);
+ }
+
private static boolean canSendMail() {
try {
return MFMailComposeViewController.canSendMail();
This was sent by the SourceForge.net collaborative development platform, the world's largest Open Source development site.
|