diff options
author | Bananeweizen <bananeweizen@gmx.de> | 2013-05-25 11:22:30 +0200 |
---|---|---|
committer | Bananeweizen <bananeweizen@gmx.de> | 2013-05-25 11:24:49 +0200 |
commit | 9fed8d3446c0fd34df1b73e258c22bf97ecf684b (patch) | |
tree | abef3a1f9cf8bfcb9c051873dc809075d002ea99 /main/src/cgeo/geocaching/maps | |
parent | f97abf9389c3dfa292bfcff89e9a99ed7aab5a1f (diff) | |
download | cgeo-9fed8d3446c0fd34df1b73e258c22bf97ecf684b.zip cgeo-9fed8d3446c0fd34df1b73e258c22bf97ecf684b.tar.gz cgeo-9fed8d3446c0fd34df1b73e258c22bf97ecf684b.tar.bz2 |
fix #2725: Circles on the map only around physical stages
Diffstat (limited to 'main/src/cgeo/geocaching/maps')
10 files changed, 40 insertions, 50 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 89d1cdc..0af0e6c 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -1606,7 +1606,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } private CachesOverlayItemImpl getCacheItem(final Geocache cache) { - final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(cache, cache.getType()); + final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(cache, cache.getType().applyDistanceRule()); final int hashcode = new HashCodeBuilder() .append(cache.isReliableLatLon()) @@ -1686,7 +1686,7 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto } private CachesOverlayItemImpl getWaypointItem(final Waypoint waypoint) { - final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(waypoint, null); + final CachesOverlayItemImpl item = mapItemFactory.getCachesOverlayItem(waypoint, waypoint.getWaypointType().applyDistanceRule()); Drawable marker = getResources().getDrawable(!waypoint.isVisited() ? R.drawable.marker : R.drawable.marker_transparent); final Drawable[] layers = new Drawable[] { marker, diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java index 9bb4cef..74c92eb 100644 --- a/main/src/cgeo/geocaching/maps/CachesOverlay.java +++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java @@ -1,11 +1,11 @@ package cgeo.geocaching.maps; import cgeo.geocaching.CachePopup; +import cgeo.geocaching.Geocache; import cgeo.geocaching.IWaypoint; import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.WaypointPopup; -import cgeo.geocaching.Geocache; import cgeo.geocaching.cgData; import cgeo.geocaching.activity.Progress; import cgeo.geocaching.connector.gc.GCMap; @@ -58,14 +58,14 @@ public class CachesOverlay extends AbstractItemizedOverlay { mapItemFactory = mapProvider.getMapItemFactory(); } - public void updateItems(CachesOverlayItemImpl item) { + void updateItems(CachesOverlayItemImpl item) { List<CachesOverlayItemImpl> itemsPre = new ArrayList<CachesOverlayItemImpl>(); itemsPre.add(item); updateItems(itemsPre); } - public void updateItems(List<CachesOverlayItemImpl> itemsPre) { + void updateItems(List<CachesOverlayItemImpl> itemsPre) { if (itemsPre == null) { return; } @@ -86,11 +86,11 @@ public class CachesOverlay extends AbstractItemizedOverlay { } } - public boolean getCircles() { + boolean getCircles() { return displayCircles; } - public void switchCircles() { + void switchCircles() { displayCircles = !displayCircles; } @@ -130,12 +130,7 @@ public class CachesOverlay extends AbstractItemizedOverlay { final GeoPointImpl itemGeo = mapItemFactory.getGeoPointBase(itemCoord); projection.toPixels(itemGeo, center); - final CacheType type = item.getType(); - if (type == null || type == CacheType.MULTI || type == CacheType.MYSTERY || type == CacheType.VIRTUAL || type.isEvent()) { - blockedCircle.setColor(0x66000000); - blockedCircle.setStyle(Style.STROKE); - canvas.drawCircle(center.x, center.y, radius, blockedCircle); - } else { + if (item.applyDistanceRule()) { blockedCircle.setColor(0x66BB0000); blockedCircle.setStyle(Style.STROKE); canvas.drawCircle(center.x, center.y, radius, blockedCircle); @@ -143,6 +138,10 @@ public class CachesOverlay extends AbstractItemizedOverlay { blockedCircle.setColor(0x44BB0000); blockedCircle.setStyle(Style.FILL); canvas.drawCircle(center.x, center.y, radius, blockedCircle); + } else { + blockedCircle.setColor(0x66000000); + blockedCircle.setStyle(Style.STROKE); + canvas.drawCircle(center.x, center.y, radius, blockedCircle); } } canvas.setDrawFilter(removeFilter); @@ -209,9 +208,9 @@ public class CachesOverlay extends AbstractItemizedOverlay { progress.show(context, context.getResources().getString(R.string.map_live), context.getResources().getString(R.string.cache_dialog_loading_details), true, null); + CachesOverlayItemImpl item = null; // prevent concurrent changes getOverlayImpl().lock(); - CachesOverlayItemImpl item = null; try { if (index < items.size()) { item = items.get(index); diff --git a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java index 2ac66af..b26654a 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java @@ -1,21 +1,20 @@ package cgeo.geocaching.maps.google; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import com.google.android.maps.GeoPoint; import com.google.android.maps.OverlayItem; public class GoogleCacheOverlayItem extends OverlayItem implements CachesOverlayItemImpl { - final private CacheType cacheType; final private IWaypoint coord; + final private boolean applyDistanceRule; - public GoogleCacheOverlayItem(final IWaypoint coordinate, final CacheType type) { + public GoogleCacheOverlayItem(final IWaypoint coordinate, boolean applyDistanceRule) { super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), ""); - this.cacheType = type; this.coord = coordinate; + this.applyDistanceRule = applyDistanceRule; } @Override @@ -24,8 +23,8 @@ public class GoogleCacheOverlayItem extends OverlayItem implements CachesOverlay } @Override - public CacheType getType() { - return cacheType; + public boolean applyDistanceRule() { + return applyDistanceRule; } } diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapItemFactory.java b/main/src/cgeo/geocaching/maps/google/GoogleMapItemFactory.java index f40c799..c708dc5 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleMapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleMapItemFactory.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.google; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; @@ -15,7 +14,7 @@ public class GoogleMapItemFactory implements MapItemFactory { } @Override - public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, final CacheType type) { - return new GoogleCacheOverlayItem(coordinate, type); + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, boolean applyDistanceRule) { + return new GoogleCacheOverlayItem(coordinate, applyDistanceRule); } } diff --git a/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java b/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java index 5bf3ed2..03fa21f 100644 --- a/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java +++ b/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.interfaces; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; /** * Covers the common functions of the provider-specific @@ -11,6 +10,5 @@ public interface CachesOverlayItemImpl extends OverlayItemImpl { public IWaypoint getCoord(); - public CacheType getType(); - + public boolean applyDistanceRule(); } diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java b/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java index e02d472..22c6698 100644 --- a/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/interfaces/MapItemFactory.java @@ -1,13 +1,12 @@ package cgeo.geocaching.maps.interfaces; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; public interface MapItemFactory { public GeoPointImpl getGeoPointBase(final Geopoint coords); - public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint iWaypoint, final CacheType type); + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint iWaypoint, final boolean applyDistanceRule); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java index 29f13b3..27ca664 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.mapsforge; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import org.mapsforge.android.maps.overlay.OverlayItem; @@ -10,14 +9,14 @@ import org.mapsforge.core.GeoPoint; import android.graphics.drawable.Drawable; public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOverlayItemImpl { - final private CacheType cacheType; final private IWaypoint coord; + final private boolean applyDistanceRule; - public MapsforgeCacheOverlayItem(IWaypoint coordinate, final CacheType type) { + public MapsforgeCacheOverlayItem(IWaypoint coordinate, boolean applyDistanceRule) { super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), ""); - this.cacheType = type; this.coord = coordinate; + this.applyDistanceRule = applyDistanceRule; } @Override @@ -26,13 +25,13 @@ public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOver } @Override - public CacheType getType() { - return cacheType; + public Drawable getMarker(int index) { + return getMarker(); } @Override - public Drawable getMarker(int index) { - return getMarker(); + public boolean applyDistanceRule() { + return applyDistanceRule; } } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java index 10fcb03..4ade09c 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.mapsforge; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; @@ -15,8 +14,8 @@ public class MapsforgeMapItemFactory implements MapItemFactory { } @Override - public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, final CacheType type) { - return new MapsforgeCacheOverlayItem(coordinate, type); + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, boolean applyDistanceRule) { + return new MapsforgeCacheOverlayItem(coordinate, applyDistanceRule); } } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeCacheOverlayItem.java index 6b74de5..4e4a358 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeCacheOverlayItem.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeCacheOverlayItem.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.mapsforge.v024; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import org.mapsforge.android.mapsold.GeoPoint; @@ -10,14 +9,14 @@ import org.mapsforge.android.mapsold.OverlayItem; import android.graphics.drawable.Drawable; public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOverlayItemImpl { - final private CacheType cacheType; final private IWaypoint coord; + final private boolean applyDistanceRule; - public MapsforgeCacheOverlayItem(IWaypoint coordinate, final CacheType type) { + public MapsforgeCacheOverlayItem(IWaypoint coordinate, boolean applyDistanceRule) { super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), ""); - this.cacheType = type; this.coord = coordinate; + this.applyDistanceRule = applyDistanceRule; } @Override @@ -26,13 +25,13 @@ public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOver } @Override - public CacheType getType() { - return cacheType; + public Drawable getMarker(int index) { + return getMarker(); } @Override - public Drawable getMarker(int index) { - return getMarker(); + public boolean applyDistanceRule() { + return applyDistanceRule; } } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java index 5c64592..4f1d34c 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapItemFactory024.java @@ -1,7 +1,6 @@ package cgeo.geocaching.maps.mapsforge.v024; import cgeo.geocaching.IWaypoint; -import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl; import cgeo.geocaching.maps.interfaces.GeoPointImpl; @@ -15,7 +14,7 @@ public class MapsforgeMapItemFactory024 implements MapItemFactory { } @Override - public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, final CacheType type) { - return new MapsforgeCacheOverlayItem(coordinate, type); + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, boolean applyDistanceRule) { + return new MapsforgeCacheOverlayItem(coordinate, applyDistanceRule); } } |