paulirotta / Tantalum

Tantalum Cross Platform Library
12 stars 6 forks source link

Put initialization in platform specific classses. #46

Open vivainio opened 11 years ago

vivainio commented 11 years ago

Current "setProgram()" that has switching based on platform is unnecessarily complex.

Let's put the initialization functionality to platform specific classes, which does all the platform specific stuff and then all the necessary cross platform stuff (starting workers etc) . It could work like this:

TanlalumJmeRuntime.start(mymidlet, numberofthreads)

or

TantalumAndroidRuntime.start(activity, numberofthreads)

The part of the app where this would be called is never cross platform anyway.

vivainio commented 11 years ago

This can help remove the "android stubs" as well. If you want JME version of the library, you can just rm -Rf the android specific dir and you have "JME clean" codebase without stubbing.

vivainio commented 11 years ago

The jar projects would then be TantalumCore.jar, TantalumJme.jar, TantalumAndroid.jar. We can provide two separate jars that combine Core+Jme and Core+Android at build time. This is much cleaner than stubbing and having branching for two different projects in the same class.

paulirotta commented 11 years ago

In progress on the "android-refactor" branch which should be visible. Local temp ant from netbeans I'm using are not in the repo.

@kaiinkinen let's gradle it tomorrow or day after, perhaps gradle 1.5 support same time

paulirotta commented 11 years ago

Merged into master branch. Still updating gradle for the new config. Expect JAR names to change as a result

jnynas commented 11 years ago

How should you initialize the runtime currently in JME?

paulirotta commented 11 years ago

You can do this anytime, but good to do on startup.

Also close the app as below to ensure that pending flash writes complete and the USB log in the root directory of the phone memory card

public void startApp() {

    PlatformUtils.getInstance().setProgram(this, 4, PlatformUtils.MEMORY_CARD_LOG_MODE);

    …

}

protected void destroyApp(final boolean unconditional) {

    PlatformUtils.getInstance().shutdown(unconditional, "Phone sent destroyApp(" + unconditional + ")");

}

…. Log modes are

/**

 * Send log output to the standard output device, usually your IDE log

 * window

 */

public static final int NORMAL_LOG_MODE = 0;

/**

 * Open a serial port connection to terminal-emulator software opened to the

 * USB serial port on your computer. On Windows open Control Panel - System

 * - Devices to set the maximum baud rate, no parity and hardware CTS flow

 * control and to the same in terminal emulation software such as Putty

 *

 * With the release build of the Tantalum library, this setting is ignored

 * and there will not be any log output.

 */

public static final int USB_SERIAL_PORT_LOG_MODE = 1;

/**

 * Store the most recent run log data as "tantalum.log" on the phone's

 * memory card in the root directory.

 *

 * With the release build of the Tantalum library, this setting is ignored

 * and there will not be any log output.

 */

public static final int MEMORY_CARD_LOG_MODE = 2;

From: jnynas [mailto:notifications@github.com] Sent: 08 May 2013 09:14 To: TantalumMobile/Tantalum Cc: Paul Houghton Subject: Re: [Tantalum] Put initialization in platform specific classses. (#46)

How should you initialize the runtime currently in JME?

— Reply to this email directly or view it on GitHub https://github.com/TantalumMobile/Tantalum/issues/46#issuecomment-17590236 . https://github.com/notifications/beacon/3v6cPLVKpXE26hShzILlc60iV-1FWXlC5Risy0EXJMPBaRdUCTIneXOV0nOfcMJZ.gif

vivainio commented 11 years ago

@paulirotta the idea of this bug was that initialization would be something like:


TanlalumJmeRuntime.start(mymidlet, numberofthreads)
paulirotta commented 11 years ago

Done.

TantalumJME and TantalumAndroid with static convenience methods and JavaDoc

Added TantalumJME-LWUIT would not be difficult. Any interest, especially @vivainio ?