From 3a311f2a45a79a19ebc4e2b66f5e92a2f390c04d Mon Sep 17 00:00:00 2001 From: mucek4 Date: Mon, 11 Jul 2011 08:12:48 +0200 Subject: First commit --- src/cgeo/geocaching/cgDistanceView.java | 45 +++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 src/cgeo/geocaching/cgDistanceView.java (limited to 'src/cgeo/geocaching/cgDistanceView.java') 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 -- cgit v1.1