It has to do with one of my requirements to allow the user to specify in
the app's preferences to display only a subset of the units. If I pick SI
(System International), then all I get are meters, kilograms, Newtons,
degrees C, etc. If I specify English, then I get feet, slugs, pounds, and
degrees F. I am not sure if there are others unit groupings that may become
important. So, in a SI preference, the first position in the length spinner
will have meters, whereas the English preference will have feet. If both
systems are chosen, the the first position of the length spinner may be
feet or meters (haven't decided yet). I guess I could try to relax this
requirement, but then I run the risk of pissing off the (pick any country
outside the US and GB) by allowing a stinking dirty "foot" to be part of
the spinner...;) I can hear the comments on my app page now....BTW, I loved
reading your blog comments to users!

Using the indices of the spinner seems fraught with some other dangerous
side effects. For example, if I store the index from the length spinner in
the sqlite table for one of the measurements, and the order of the length
units change for some reason, then that data is corrupted. Using something
like an enum to fix the index value of feet feels like a better solution,
but then I run into the problems of utilizing all the platform's benefits
of a simple string array and coming up with a simple way of relating that
array's values to my "hard coded" indices. I also find the need to create a
bunch of units classes (length, mass, speed, acceleration, temperature,
pressure, etc.) to get the functionality I need and adding that to
 spinneradapters to get the strings like lots of extra code when a simple
xml string array will work for the most part. But that path seems the be
the only way to go.

Perhaps I am over thinking this?

Mark


On Thu, Dec 6, 2012 at 9:49 AM, TreKing <[email protected]> wrote:

> On Thu, Dec 6, 2012 at 10:18 AM, Mark Phillips <[email protected]
> > wrote:
>
>> I initially thought to just put arrays in strings.xml for the various
>> units (length, mass, temperature, etc) to simplify the code and
>> translations. However, I end up with a lot of string testing to see which
>> unit was selected.
>
>
> If you have arrays of string, why are you testing the strings themselves
> instead of the indices?
>
>
> -------------------------------------------------------------------------------------------------
> TreKing <http://sites.google.com/site/rezmobileapps/treking> - Chicago
> transit tracking app for Android-powered devices
>
>  --
> You received this message because you are subscribed to the Google
> Groups "Android Developers" group.
> To post to this group, send email to [email protected]
> 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

-- 
You received this message because you are subscribed to the Google
Groups "Android Developers" group.
To post to this group, send email to [email protected]
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