diff options
| author | Bananeweizen <bananeweizen@gmx.de> | 2012-01-14 15:02:15 +0100 |
|---|---|---|
| committer | Bananeweizen <bananeweizen@gmx.de> | 2012-01-14 15:02:15 +0100 |
| commit | e61a40fc8a4a3d5ab5a59346eddd1c43bcc4857e (patch) | |
| tree | a2a8aec422fde537c500cf90ad70e606ba416121 /main/src/cgeo/geocaching/ui/DistanceView.java | |
| parent | 77a8bc851569ae7a82f76a0913b39006074ac56a (diff) | |
| download | cgeo-e61a40fc8a4a3d5ab5a59346eddd1c43bcc4857e.zip cgeo-e61a40fc8a4a3d5ab5a59346eddd1c43bcc4857e.tar.gz cgeo-e61a40fc8a4a3d5ab5a59346eddd1c43bcc4857e.tar.bz2 | |
refactoring: move more widget related classes into own package
Diffstat (limited to 'main/src/cgeo/geocaching/ui/DistanceView.java')
| -rw-r--r-- | main/src/cgeo/geocaching/ui/DistanceView.java | 43 |
1 files changed, 43 insertions, 0 deletions
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 |
