From e61a40fc8a4a3d5ab5a59346eddd1c43bcc4857e Mon Sep 17 00:00:00 2001 From: Bananeweizen Date: Sat, 14 Jan 2012 15:02:15 +0100 Subject: refactoring: move more widget related classes into own package --- main/src/cgeo/geocaching/ui/DistanceView.java | 43 +++++++++++++++++++++++++++ 1 file changed, 43 insertions(+) create mode 100644 main/src/cgeo/geocaching/ui/DistanceView.java (limited to 'main/src/cgeo/geocaching/ui/DistanceView.java') diff --git a/main/src/cgeo/geocaching/ui/DistanceView.java b/main/src/cgeo/geocaching/ui/DistanceView.java new file mode 100644 index 0000000..49c90b7 --- /dev/null +++ b/main/src/cgeo/geocaching/ui/DistanceView.java @@ -0,0 +1,43 @@ +package cgeo.geocaching.ui; + +import cgeo.geocaching.cgBase; +import cgeo.geocaching.geopoint.Geopoint; + +import android.content.Context; +import android.util.AttributeSet; +import android.widget.TextView; + +public class DistanceView extends TextView { + private Geopoint cacheCoords = null; + + public DistanceView(Context context) { + super(context); + } + + public DistanceView(Context context, AttributeSet attrs) { + super(context, attrs); + } + + public DistanceView(Context context, AttributeSet attrs, int defStyle) { + super(context, attrs, defStyle); + } + + public void setContent(final Geopoint cacheCoordsIn) { + cacheCoords = cacheCoordsIn; + } + + public void update(final Geopoint coords) { + if (cacheCoords == null || coords == null) { + return; + } + setText(cgBase.getHumanDistance(coords.distanceTo(cacheCoords))); + } + + public void setDistance(Float distance) { + setText("~" + cgBase.getHumanDistance(distance)); + } + + public void clear() { + setText(null); + } +} \ No newline at end of file -- cgit v1.1