diff options
Diffstat (limited to 'main/src/cgeo/geocaching/maps')
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 10 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CachesOverlay.java | 28 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/maps/PositionHistory.java | 2 |
3 files changed, 22 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 0817170..0703dd8 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -609,7 +609,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto default: // DETAILED menu.findItem(R.id.menu_strategy_detailed).setChecked(true); } - } catch (Exception e) { + } catch (RuntimeException e) { Log.e("CGeoMap.onPrepareOptionsMenu", e); } @@ -948,7 +948,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto mapView.repaintRequired(overlayPosition); } } - } catch (Exception e) { + } catch (RuntimeException e) { Log.w("Failed to update location."); } } @@ -1418,7 +1418,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } sleep(delay); - } catch (Exception e) { + } catch (InterruptedException e) { // nothing } } @@ -1501,7 +1501,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto try { mapController.setCenter(mapItemFactory.getGeoPointBase(new Geopoint(mapState[0] / 1.0e6, mapState[1] / 1.0e6))); mapController.setZoom(mapState[2]); - } catch (Exception e) { + } catch (RuntimeException e) { // nothing at all } @@ -1525,7 +1525,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto if (viewport.getLatitudeSpan() != 0 && viewport.getLongitudeSpan() != 0) { mapController.zoomToSpan((int) (viewport.getLatitudeSpan() * 1e6), (int) (viewport.getLongitudeSpan() * 1e6)); } - } catch (Exception e) { + } catch (RuntimeException e) { // nothing at all } diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java index 8e117eb..8fbb3db 100644 --- a/main/src/cgeo/geocaching/maps/CachesOverlay.java +++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java @@ -4,7 +4,6 @@ import cgeo.geocaching.CachePopup; import cgeo.geocaching.Geocache; import cgeo.geocaching.IWaypoint; import cgeo.geocaching.R; -import cgeo.geocaching.settings.Settings; import cgeo.geocaching.WaypointPopup; import cgeo.geocaching.cgData; import cgeo.geocaching.activity.Progress; @@ -19,11 +18,13 @@ import cgeo.geocaching.maps.interfaces.MapItemFactory; import cgeo.geocaching.maps.interfaces.MapProjectionImpl; import cgeo.geocaching.maps.interfaces.MapProvider; import cgeo.geocaching.maps.interfaces.MapViewImpl; +import cgeo.geocaching.settings.Settings; import cgeo.geocaching.utils.Log; import org.apache.commons.lang3.StringUtils; import android.content.Context; +import android.content.res.Resources.NotFoundException; import android.graphics.Canvas; import android.graphics.DashPathEffect; import android.graphics.Paint; @@ -121,6 +122,8 @@ public class CachesOverlay extends AbstractItemizedOverlay { try { lazyInitializeDrawingObjects(); canvas.setDrawFilter(setFilter); + final int height = canvas.getHeight(); + final int width = canvas.getWidth(); final int radius = calculateDrawingRadius(projection); final Point center = new Point(); @@ -130,16 +133,17 @@ public class CachesOverlay extends AbstractItemizedOverlay { final Geopoint itemCoord = item.getCoord().getCoords(); final GeoPointImpl itemGeo = mapItemFactory.getGeoPointBase(itemCoord); projection.toPixels(itemGeo, center); - - // dashed circle around the waypoint - blockedCircle.setColor(0x66BB0000); - blockedCircle.setStyle(Style.STROKE); - canvas.drawCircle(center.x, center.y, radius, blockedCircle); - - // filling the circle area with a transparent color - blockedCircle.setColor(0x44BB0000); - blockedCircle.setStyle(Style.FILL); - canvas.drawCircle(center.x, center.y, radius, blockedCircle); + if (center.x > -radius && center.y > -radius && center.x < width + radius && center.y < height + radius) { + // dashed circle around the waypoint + blockedCircle.setColor(0x66BB0000); + blockedCircle.setStyle(Style.STROKE); + canvas.drawCircle(center.x, center.y, radius, blockedCircle); + + // filling the circle area with a transparent color + blockedCircle.setColor(0x44BB0000); + blockedCircle.setStyle(Style.FILL); + canvas.drawCircle(center.x, center.y, radius, blockedCircle); + } } } canvas.setDrawFilter(removeFilter); @@ -243,7 +247,7 @@ public class CachesOverlay extends AbstractItemizedOverlay { } progress.dismiss(); - } catch (Exception e) { + } catch (NotFoundException e) { Log.e("CachesOverlay.onTap", e); if (progress != null) { progress.dismiss(); diff --git a/main/src/cgeo/geocaching/maps/PositionHistory.java b/main/src/cgeo/geocaching/maps/PositionHistory.java index 9b090fc..bc6779e 100644 --- a/main/src/cgeo/geocaching/maps/PositionHistory.java +++ b/main/src/cgeo/geocaching/maps/PositionHistory.java @@ -28,7 +28,7 @@ public class PositionHistory { if (coordinates.getAccuracy() >= 50f) { return; } - if (coordinates.getLatitude() == 0.0 && coordinates.getLatitude() == 0.0) { + if (coordinates.getLatitude() == 0.0 && coordinates.getLongitude() == 0.0) { return; } if (history.isEmpty()) { |
