aboutsummaryrefslogtreecommitdiffstats
path: root/main
diff options
context:
space:
mode:
authorKonrad Gräfe <konradgraefe@aol.com>2015-01-28 22:44:07 +0100
committerrsudev <rasch@munin-soft.de>2015-02-09 23:12:40 +0100
commitd69339c013d71ee2387f366163ccfd93af86800e (patch)
tree232987f2967085c0a316bc9971e03fa4370aa17e /main
parent839d0b68f7d54d4c9f3e324c188b3cc11c8c9111 (diff)
downloadcgeo-d69339c013d71ee2387f366163ccfd93af86800e.zip
cgeo-d69339c013d71ee2387f366163ccfd93af86800e.tar.gz
cgeo-d69339c013d71ee2387f366163ccfd93af86800e.tar.bz2
Fix NullPointerException when a map with no destination is opened
Diffstat (limited to 'main')
-rw-r--r--main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java22
1 files changed, 13 insertions, 9 deletions
diff --git a/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java b/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
index 51d83aa..9a6e4b9 100644
--- a/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
+++ b/main/src/cgeo/geocaching/maps/PositionAndScaleOverlay.java
@@ -22,20 +22,20 @@ public class PositionAndScaleOverlay implements GeneralOverlay {
DirectionDrawer directionDrawer = null;
DistanceDrawer distanceDrawer = null;
- public PositionAndScaleOverlay(final OverlayImpl ovlImpl, final MapViewImpl mapView, Geopoint coords, final String geocode) {
+ public PositionAndScaleOverlay(final OverlayImpl ovlImpl, final MapViewImpl mapView, final Geopoint coords, final String geocode) {
this.ovlImpl = ovlImpl;
positionDrawer = new PositionDrawer();
scaleDrawer = new ScaleDrawer();
- if (coords == null && geocode != null) {
- final Viewport bounds = DataStore.getBounds(geocode);
- if (bounds != null) {
- coords = bounds.center;
- }
- }
if (coords != null) {
directionDrawer = new DirectionDrawer(coords);
distanceDrawer = new DistanceDrawer(mapView, coords);
+ } else if (geocode != null) {
+ final Viewport bounds = DataStore.getBounds(geocode);
+ if (bounds != null) {
+ directionDrawer = new DirectionDrawer(bounds.center);
+ distanceDrawer = new DistanceDrawer(mapView, bounds.center);
+ }
}
}
@@ -74,10 +74,14 @@ public class PositionAndScaleOverlay implements GeneralOverlay {
}
private void drawInternal(final Canvas canvas, final MapProjectionImpl projection, final MapViewImpl mapView) {
- directionDrawer.drawDirection(canvas, projection);
+ if (directionDrawer != null) {
+ directionDrawer.drawDirection(canvas, projection);
+ }
positionDrawer.drawPosition(canvas, projection);
scaleDrawer.drawScale(canvas, mapView);
- distanceDrawer.drawDistance(canvas);
+ if (distanceDrawer != null) {
+ distanceDrawer.drawDistance(canvas);
+ }
}
@Override