aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/maps/CachesOverlay.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/maps/CachesOverlay.java')
-rw-r--r--main/src/cgeo/geocaching/maps/CachesOverlay.java46
1 files changed, 21 insertions, 25 deletions
diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java
index 3c6109e..9649c0d 100644
--- a/main/src/cgeo/geocaching/maps/CachesOverlay.java
+++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java
@@ -10,7 +10,7 @@ import cgeo.geocaching.activity.Progress;
import cgeo.geocaching.connector.gc.GCMap;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
-import cgeo.geocaching.geopoint.Geopoint;
+import cgeo.geocaching.location.Geopoint;
import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
import cgeo.geocaching.maps.interfaces.ItemizedOverlayImpl;
@@ -43,13 +43,13 @@ public class CachesOverlay extends AbstractItemizedOverlay {
private List<CachesOverlayItemImpl> items = new ArrayList<>();
private Context context = null;
private boolean displayCircles = false;
- private Progress progress = new Progress();
+ private final Progress progress = new Progress();
private Paint blockedCircle = null;
private PaintFlagsDrawFilter setFilter = null;
private PaintFlagsDrawFilter removeFilter = null;
private MapItemFactory mapItemFactory = null;
- public CachesOverlay(ItemizedOverlayImpl ovlImpl, Context contextIn) {
+ public CachesOverlay(final ItemizedOverlayImpl ovlImpl, final Context contextIn) {
super(ovlImpl);
populate();
@@ -60,19 +60,19 @@ public class CachesOverlay extends AbstractItemizedOverlay {
mapItemFactory = mapProvider.getMapItemFactory();
}
- void updateItems(CachesOverlayItemImpl item) {
- List<CachesOverlayItemImpl> itemsPre = new ArrayList<>();
+ void updateItems(final CachesOverlayItemImpl item) {
+ final List<CachesOverlayItemImpl> itemsPre = new ArrayList<>();
itemsPre.add(item);
updateItems(itemsPre);
}
- void updateItems(List<CachesOverlayItemImpl> itemsPre) {
+ void updateItems(final List<CachesOverlayItemImpl> itemsPre) {
if (itemsPre == null) {
return;
}
- for (CachesOverlayItemImpl item : itemsPre) {
+ for (final CachesOverlayItemImpl item : itemsPre) {
item.setMarker(boundCenterBottom(item.getMarker(0)));
}
@@ -97,7 +97,7 @@ public class CachesOverlay extends AbstractItemizedOverlay {
}
@Override
- public void draw(Canvas canvas, MapViewImpl mapView, boolean shadow) {
+ public void draw(final Canvas canvas, final MapViewImpl mapView, final boolean shadow) {
drawInternal(canvas, mapView.getMapProjection());
@@ -105,15 +105,15 @@ public class CachesOverlay extends AbstractItemizedOverlay {
}
@Override
- public void drawOverlayBitmap(Canvas canvas, Point drawPosition,
- MapProjectionImpl projection, byte drawZoomLevel) {
+ public void drawOverlayBitmap(final Canvas canvas, final Point drawPosition,
+ final MapProjectionImpl projection, final byte drawZoomLevel) {
drawInternal(canvas, projection);
super.drawOverlayBitmap(canvas, drawPosition, projection, drawZoomLevel);
}
- private void drawInternal(Canvas canvas, MapProjectionImpl projection) {
+ private void drawInternal(final Canvas canvas, final MapProjectionImpl projection) {
if (!displayCircles || items.isEmpty()) {
return;
}
@@ -129,7 +129,7 @@ public class CachesOverlay extends AbstractItemizedOverlay {
final int radius = calculateDrawingRadius(projection);
final Point center = new Point();
- for (CachesOverlayItemImpl item : items) {
+ for (final CachesOverlayItemImpl item : items) {
if (item.applyDistanceRule()) {
final Geopoint itemCoord = item.getCoord().getCoords();
final GeoPointImpl itemGeo = mapItemFactory.getGeoPointBase(itemCoord);
@@ -158,11 +158,9 @@ public class CachesOverlay extends AbstractItemizedOverlay {
* reality and therefore the minor changes due to the projection will not make any visible difference at the zoom
* levels which are used to see the circles.
*
- * @param projection
- * @return
*/
- private int calculateDrawingRadius(MapProjectionImpl projection) {
- float[] distanceArray = new float[1];
+ private int calculateDrawingRadius(final MapProjectionImpl projection) {
+ final float[] distanceArray = new float[1];
final Geopoint itemCoord = items.get(0).getCoord().getCoords();
Location.distanceBetween(itemCoord.getLatitude(), itemCoord.getLongitude(),
@@ -202,7 +200,7 @@ public class CachesOverlay extends AbstractItemizedOverlay {
}
@Override
- public boolean onTap(int index) {
+ public boolean onTap(final int index) {
try {
if (items.size() <= index) {
@@ -232,7 +230,7 @@ public class CachesOverlay extends AbstractItemizedOverlay {
if (StringUtils.equalsIgnoreCase(coordType, "cache") && StringUtils.isNotBlank(coordinate.getGeocode())) {
final Geocache cache = DataStore.loadCache(coordinate.getGeocode(), LoadFlags.LOAD_CACHE_OR_DB);
if (cache != null) {
- RequestDetailsThread requestDetailsThread = new RequestDetailsThread(cache);
+ final RequestDetailsThread requestDetailsThread = new RequestDetailsThread(cache);
if (!requestDetailsThread.requestRequired()) {
// don't show popup if we have enough details
progress.dismiss();
@@ -253,21 +251,19 @@ public class CachesOverlay extends AbstractItemizedOverlay {
}
progress.dismiss();
- } catch (NotFoundException e) {
+ } catch (final NotFoundException e) {
Log.e("CachesOverlay.onTap", e);
- if (progress != null) {
- progress.dismiss();
- }
+ progress.dismiss();
}
return true;
}
@Override
- public CachesOverlayItemImpl createItem(int index) {
+ public CachesOverlayItemImpl createItem(final int index) {
try {
return items.get(index);
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.e("CachesOverlay.createItem", e);
}
@@ -278,7 +274,7 @@ public class CachesOverlay extends AbstractItemizedOverlay {
public int size() {
try {
return items.size();
- } catch (Exception e) {
+ } catch (final Exception e) {
Log.e("CachesOverlay.size", e);
}