Good suggestions, Peli. Thanks. For now I had decided to "wrap" the
OpenIntents code segments in dedicated open and close tags as in

/* // <xOpenIntents>
import org.openintents.OpenIntents;
import org.openintents.hardware.SensorManagerSimulator;
import org.openintents.hardware.Sensors;
import org.openintents.provider.Hardware;
*/ // </xOpenIntents>

such that a global editor substitution of /* // <xOpenIntents> by /
**/ // <xOpenIntents> and */ // </xOpenIntents> by /**/ // </
xOpenIntents> (and vice versa) will activate or deactivate all
OpenIntents code segments. This scales to any number of OpenIntents
code segments without adding effort (for five code segments one might
still argue that it is overkill to do this via global substitution,
but I prefer it). I never trust a compiler to really remove logically
unused branches, so for me this is the next-best-thing for lack of a
precompiler, but perhaps I am paranoid. Or was it pAndroid? :-)



On Sep 10, 8:23 am, Peli <[EMAIL PROTECTED]> wrote:
> Thank you for the great feedback!
>
> In the mean-time I've updated the documentation 
> here:http://code.google.com/p/openintents/wiki/SensorSimulator
>
> Yes, a Java Precompiler would indeed come handy in cases like this.
> Maybe you can reduce the number of places where you have to comment
> out code to a single place, by putting all relevant code into methods
> of a single class, and in the five places in your code use if-else
> with a final boolean. Then the code in the unused if-branch will be
> stripped off completely by the compiler.
>
> For example:
> -------------------------
> MySensorsClass.init();  // Optionally initialize
>
> if (MySensorsClass.useSensorSimulator) {
>   ... time-critical code A ...} else {
>
>   ... time-critical code B ...
>
> }
>
> // and somewhere else
> class MySensorsClass {
>     // Either use this block
>   /* *+/     // (<- the '+' ensures that this block is commented out)
>   static final boolean useSensorSimulator = true;
>   static init() {
>     call OI code
>   }
>   static prepareMenus() {
>     call OI code
>   }
>   /* */
>
>   // or use this block
>   /*  */    // (<- no '+' here so this block is in use)
>   static final boolean useSensorSimulator = false;
>   static init() {
>     // do nothing
>   }
>   static prepareMenus() {
>     // do nothing
>   }
>   /* */}
>
> --------------------
>
> Then it would be just a matter of moving the "+" around from the first
> to the second comment block and adding or removing the lib.
>
> Peli

--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to android-developers@googlegroups.com
To unsubscribe from this group, send email to
[EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/android-developers?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to