blob: 9610e4f1aa02ce832ed496ecdd18fa6f49f3818b (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
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);
}
}
|