diff options
author | campbeb <bpcampbell@gmail.com> | 2012-02-20 18:31:36 +0900 |
---|---|---|
committer | campbeb <bpcampbell@gmail.com> | 2012-02-20 18:31:36 +0900 |
commit | bcf280d3ccd9e19d294250e5bc74bd4a66eaf9a2 (patch) | |
tree | e63994959fc00c4d31ba9da56009144b77d1d7c5 /main/src/cgeo/geocaching/cgeowaypointadd.java | |
parent | 8700ff18cc4d5a6d136e35e6e07aa4f70ddaaf63 (diff) | |
download | cgeo-bcf280d3ccd9e19d294250e5bc74bd4a66eaf9a2.zip cgeo-bcf280d3ccd9e19d294250e5bc74bd4a66eaf9a2.tar.gz cgeo-bcf280d3ccd9e19d294250e5bc74bd4a66eaf9a2.tar.bz2 |
Move strings to resources and only set list selection on initial setup.
Diffstat (limited to 'main/src/cgeo/geocaching/cgeowaypointadd.java')
-rw-r--r-- | main/src/cgeo/geocaching/cgeowaypointadd.java | 22 |
1 files changed, 9 insertions, 13 deletions
diff --git a/main/src/cgeo/geocaching/cgeowaypointadd.java b/main/src/cgeo/geocaching/cgeowaypointadd.java index e8136e2..04d51a9 100644 --- a/main/src/cgeo/geocaching/cgeowaypointadd.java +++ b/main/src/cgeo/geocaching/cgeowaypointadd.java @@ -44,8 +44,6 @@ public class cgeowaypointadd extends AbstractActivity { private boolean own = true; ArrayList<WaypointType> wpTypes = null; String distanceUnit = ""; - private static final String[] distanceUnits = { "m", "km", "ft", "yd", "mi" }; - /** * number of waypoints that the corresponding cache has until now @@ -228,16 +226,14 @@ public class cgeowaypointadd extends AbstractActivity { Spinner distanceUnitSelector = (Spinner) findViewById(R.id.distanceUnit); - ArrayAdapter<String> unitAdapter = new ArrayAdapter<String>(this, android.R.layout.simple_spinner_item, distanceUnits); - unitAdapter.setDropDownViewResource(android.R.layout.simple_spinner_dropdown_item); - distanceUnitSelector.setAdapter(unitAdapter); - - if (Settings.isUseMetricUnits()) { - distanceUnitSelector.setSelection(0); // m - distanceUnit = cgeowaypointadd.distanceUnits[0]; - } else { - distanceUnitSelector.setSelection(2); // ft - distanceUnit = cgeowaypointadd.distanceUnits[2]; + if (StringUtils.isBlank(distanceUnit)) { + if (Settings.isUseMetricUnits()) { + distanceUnitSelector.setSelection(0); // m + distanceUnit = res.getStringArray(R.array.distance_units)[0]; + } else { + distanceUnitSelector.setSelection(2); // ft + distanceUnit = res.getStringArray(R.array.distance_units)[2]; + } } distanceUnitSelector.setOnItemSelectedListener(new changeDistanceUnit(this)); @@ -340,7 +336,7 @@ public class cgeowaypointadd extends AbstractActivity { @Override public void onItemSelected(AdapterView<?> arg0, View arg1, int arg2, long arg3) { - unitView.distanceUnit = cgeowaypointadd.distanceUnits[arg2]; + unitView.distanceUnit = (String) arg0.getItemAtPosition(arg2); } @Override |