diff options
| author | Bananeweizen <Bananeweizen@gmx.de> | 2013-03-28 21:46:09 +0100 |
|---|---|---|
| committer | Bananeweizen <Bananeweizen@gmx.de> | 2013-03-28 21:46:09 +0100 |
| commit | b3c74231b10ad15ed00b4107cf9f456c74978d51 (patch) | |
| tree | 4566d85cd090e6f1770f002729b287339f4847f8 /main/src/cgeo/geocaching/ui | |
| parent | 47417b7f7ce4d9ef20178a7809db8ee3336817c0 (diff) | |
| download | cgeo-b3c74231b10ad15ed00b4107cf9f456c74978d51.zip cgeo-b3c74231b10ad15ed00b4107cf9f456c74978d51.tar.gz cgeo-b3c74231b10ad15ed00b4107cf9f456c74978d51.tar.bz2 | |
fix #2583: coordinates format switching for waypoints
Diffstat (limited to 'main/src/cgeo/geocaching/ui')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java b/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java new file mode 100644 index 0000000..afadb33 --- /dev/null +++ b/main/src/cgeo/geocaching/ui/CoordinatesFormatSwitcher.java @@ -0,0 +1,38 @@ +package cgeo.geocaching.ui; + +import cgeo.geocaching.geopoint.Geopoint; +import cgeo.geocaching.geopoint.GeopointFormatter; + +import android.view.View; +import android.view.View.OnClickListener; +import android.widget.TextView; + +/** + * view click listener to automatically switch different coordinate formats + * + */ +public class CoordinatesFormatSwitcher implements OnClickListener { + + private static GeopointFormatter.Format[] availableFormats = new GeopointFormatter.Format[] { + GeopointFormatter.Format.LAT_LON_DECMINUTE, + GeopointFormatter.Format.LAT_LON_DECSECOND, + GeopointFormatter.Format.LAT_LON_DECDEGREE + }; + + private int position = 0; + + private final Geopoint coordinates; + + public CoordinatesFormatSwitcher(final Geopoint coordinates) { + this.coordinates = coordinates; + } + + @Override + public void onClick(View view) { + position = (position + 1) % availableFormats.length; + TextView textView = (TextView) view; + // rotate coordinate formats on click + textView.setText(coordinates.format(availableFormats[position])); + } + +}
\ No newline at end of file |
