aboutsummaryrefslogtreecommitdiffstats
path: root/src/cgeo/geocaching/cgDistanceView.java
diff options
context:
space:
mode:
authormucek4 <tomaz@gorenc.org>2011-07-11 08:12:48 +0200
committermucek4 <tomaz@gorenc.org>2011-07-11 08:12:48 +0200
commit3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d (patch)
tree6109c451668d4517785e8225c06230b7f02d1414 /src/cgeo/geocaching/cgDistanceView.java
downloadcgeo-3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d.zip
cgeo-3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d.tar.gz
cgeo-3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d.tar.bz2
First commit
Diffstat (limited to 'src/cgeo/geocaching/cgDistanceView.java')
-rw-r--r--src/cgeo/geocaching/cgDistanceView.java45
1 files changed, 45 insertions, 0 deletions
diff --git a/src/cgeo/geocaching/cgDistanceView.java b/src/cgeo/geocaching/cgDistanceView.java
new file mode 100644
index 0000000..9610e4f
--- /dev/null
+++ b/src/cgeo/geocaching/cgDistanceView.java
@@ -0,0 +1,45 @@
+package cgeo.geocaching;
+
+import android.content.Context;
+import android.util.AttributeSet;
+import android.widget.TextView;
+
+public class cgDistanceView extends TextView {
+ private cgBase base = null;
+ private Double cacheLat = null;
+ private Double cacheLon = null;
+
+ public cgDistanceView(Context context) {
+ super(context);
+ }
+
+ public cgDistanceView(Context context, AttributeSet attrs) {
+ super(context, attrs);
+ }
+
+ public cgDistanceView(Context context, AttributeSet attrs, int defStyle) {
+ super(context, attrs, defStyle);
+ }
+
+ public void setContent(cgBase baseIn, Double cacheLatIn, Double cacheLonIn) {
+ base = baseIn;
+ cacheLat = cacheLatIn;
+ cacheLon = cacheLonIn;
+ }
+
+ public void update(Double latitude, Double longitude) {
+ if (cacheLat == null || cacheLon == null) return;
+ if (latitude == null || longitude == null) return;
+ if (base == null) return;
+
+ setText(base.getHumanDistance(cgBase.getDistance(latitude, longitude, cacheLat, cacheLon)));
+ }
+
+ public void setDistance(Double distance) {
+ setText("~" + base.getHumanDistance(distance));
+ }
+
+ public void clear() {
+ setText(null);
+ }
+} \ No newline at end of file