use of com.codename1.payment.PurchaseCallback in project CodenameOne by codenameone.
the class CodenameOneActivity method getPurchaseCallback.
public PurchaseCallback getPurchaseCallback() {
Object app = getApp();
PurchaseCallback pc = app instanceof PurchaseCallback ? (PurchaseCallback) app : null;
return pc;
}
use of com.codename1.payment.PurchaseCallback in project CodenameOne by codenameone.
the class Executor method main.
public static void main(final String[] argv) throws Exception {
setProxySettings();
final Properties p = new Properties();
String currentDir = System.getProperty("user.dir");
File props = new File(currentDir, "codenameone_settings.properties");
if (props.exists()) {
FileInputStream f = null;
try {
f = new FileInputStream(props);
p.load(f);
f.close();
} catch (Exception ex) {
} finally {
try {
f.close();
} catch (IOException ex) {
}
}
}
SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() {
try {
String packageName = p.getProperty("codename1.packageName");
String mainName = p.getProperty("codename1.mainName");
if (argv.length > 1) {
if (argv[1].equalsIgnoreCase("-force") || packageName == null) {
c = Class.forName(argv[0]);
} else {
c = Class.forName(packageName + "." + mainName);
}
} else {
if (packageName == null || System.getenv("FORCE_CLASS") != null) {
c = Class.forName(argv[0]);
} else {
c = Class.forName(packageName + "." + mainName);
}
}
try {
Method m = c.getDeclaredMethod("main", String[].class);
m.invoke(null, new Object[] { null });
} catch (NoSuchMethodException noMain) {
try {
Method m = c.getDeclaredMethod("startApp");
m.invoke(c.newInstance());
} catch (NoSuchMethodException noStartApp) {
if (Display.isInitialized()) {
Display.deinitialize();
}
final Method m = c.getDeclaredMethod("init", Object.class);
if (m.getExceptionTypes() != null && m.getExceptionTypes().length > 0) {
System.err.println("ERROR: the init method can't declare a throws clause");
System.exit(1);
}
app = c.newInstance();
if (app instanceof PushCallback) {
CodenameOneImplementation.setPushCallback((PushCallback) app);
}
if (app instanceof PurchaseCallback) {
CodenameOneImplementation.setPurchaseCallback((PurchaseCallback) app);
}
Display.init(null);
Display.getInstance().callSerially(new Runnable() {
@Override
public void run() {
try {
m.invoke(app, new Object[] { null });
Method start = c.getDeclaredMethod("start", new Class[0]);
if (start.getExceptionTypes() != null && start.getExceptionTypes().length > 0) {
System.err.println("ERROR: the start method can't declare a throws clause");
System.exit(1);
}
start.invoke(app, new Object[0]);
} catch (NoSuchMethodException err) {
System.out.println("Couldn't find a main or a startup in " + argv[0]);
} catch (InvocationTargetException err) {
err.getTargetException().printStackTrace();
System.exit(1);
} catch (Exception err) {
err.printStackTrace();
System.exit(1);
}
}
});
}
}
} catch (Exception err) {
err.printStackTrace();
System.exit(1);
}
}
});
}
Aggregations