diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2015-03-17 08:37:59 +0100 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2015-03-17 08:41:06 +0100 |
commit | b2ffc2581c6630e313c4e623d0a40c8846e1e975 (patch) | |
tree | 6859e456fdb42e6468558883761c1de40b458c80 /main/src/cgeo/geocaching/maps | |
parent | 9119639276a00ef17d3ffa1a5fad0c37c1bebd78 (diff) | |
download | cgeo-b2ffc2581c6630e313c4e623d0a40c8846e1e975.zip cgeo-b2ffc2581c6630e313c4e623d0a40c8846e1e975.tar.gz cgeo-b2ffc2581c6630e313c4e623d0a40c8846e1e975.tar.bz2 |
Add missing final qualifiers in main module
Diffstat (limited to 'main/src/cgeo/geocaching/maps')
23 files changed, 146 insertions, 146 deletions
diff --git a/main/src/cgeo/geocaching/maps/AbstractItemizedOverlay.java b/main/src/cgeo/geocaching/maps/AbstractItemizedOverlay.java index 747618b..9436b2a 100644 --- a/main/src/cgeo/geocaching/maps/AbstractItemizedOverlay.java +++ b/main/src/cgeo/geocaching/maps/AbstractItemizedOverlay.java @@ -17,9 +17,9 @@ import android.graphics.drawable.Drawable; */ public abstract class AbstractItemizedOverlay implements GeneralOverlay { - private ItemizedOverlayImpl ovlImpl; + private final ItemizedOverlayImpl ovlImpl; - protected AbstractItemizedOverlay(ItemizedOverlayImpl ovlImplIn) { + protected AbstractItemizedOverlay(final ItemizedOverlayImpl ovlImplIn) { ovlImpl = ovlImplIn; } @@ -27,26 +27,26 @@ public abstract class AbstractItemizedOverlay implements GeneralOverlay { ovlImpl.superPopulate(); } - public boolean onTap(int index) { + public boolean onTap(final int index) { return ovlImpl.superOnTap(index); } - Drawable boundCenterBottom(Drawable markerIn) { + Drawable boundCenterBottom(final Drawable markerIn) { return ovlImpl.superBoundCenterBottom(markerIn); } - void setLastFocusedItemIndex(int index) { + void setLastFocusedItemIndex(final int index) { ovlImpl.superSetLastFocusedItemIndex(index); } @Override - public void draw(Canvas canvas, MapViewImpl mapView, boolean shadow) { + public void draw(final Canvas canvas, final MapViewImpl mapView, final boolean shadow) { ovlImpl.superDraw(canvas, mapView, shadow); } @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) { ovlImpl.superDrawOverlayBitmap(canvas, drawPosition, projection, drawZoomLevel); } diff --git a/main/src/cgeo/geocaching/maps/AbstractMapProvider.java b/main/src/cgeo/geocaching/maps/AbstractMapProvider.java index 620b953..bd42223 100644 --- a/main/src/cgeo/geocaching/maps/AbstractMapProvider.java +++ b/main/src/cgeo/geocaching/maps/AbstractMapProvider.java @@ -6,7 +6,7 @@ import cgeo.geocaching.maps.interfaces.MapSource; public abstract class AbstractMapProvider implements MapProvider { @Override - public void registerMapSource(MapSource mapSource) { + public void registerMapSource(final MapSource mapSource) { MapProviderFactory.registerMapSource(mapSource); } } diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index c808ffd..42e41b1 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -194,12 +194,12 @@ public class CGeoMap extends AbstractMap implements ViewFactory { */ private static final int MIN_LIVEMAP_ZOOM = 12; // Thread pooling - private static BlockingQueue<Runnable> displayQueue = new ArrayBlockingQueue<>(1); - private static ThreadPoolExecutor displayExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, displayQueue, new ThreadPoolExecutor.DiscardOldestPolicy()); - private static BlockingQueue<Runnable> downloadQueue = new ArrayBlockingQueue<>(1); - private static ThreadPoolExecutor downloadExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, downloadQueue, new ThreadPoolExecutor.DiscardOldestPolicy()); - private static BlockingQueue<Runnable> loadQueue = new ArrayBlockingQueue<>(1); - private static ThreadPoolExecutor loadExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, loadQueue, new ThreadPoolExecutor.DiscardOldestPolicy()); + private static final BlockingQueue<Runnable> displayQueue = new ArrayBlockingQueue<>(1); + private static final ThreadPoolExecutor displayExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, displayQueue, new ThreadPoolExecutor.DiscardOldestPolicy()); + private static final BlockingQueue<Runnable> downloadQueue = new ArrayBlockingQueue<>(1); + private static final ThreadPoolExecutor downloadExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, downloadQueue, new ThreadPoolExecutor.DiscardOldestPolicy()); + private static final BlockingQueue<Runnable> loadQueue = new ArrayBlockingQueue<>(1); + private static final ThreadPoolExecutor loadExecutor = new ThreadPoolExecutor(1, 1, 60, TimeUnit.SECONDS, loadQueue, new ThreadPoolExecutor.DiscardOldestPolicy()); // handlers /** Updates the titles */ @@ -382,7 +382,7 @@ public class CGeoMap extends AbstractMap implements ViewFactory { if (msg.what == UPDATE_PROGRESS) { if (waitDialog != null) { final int secondsElapsed = (int) ((System.currentTimeMillis() - detailProgressTime) / 1000); - int secondsRemaining; + final int secondsRemaining; if (detailProgress > 0) { secondsRemaining = (detailTotal - detailProgress) * secondsElapsed / detailProgress; } else { @@ -1234,7 +1234,7 @@ public class CGeoMap extends AbstractMap implements ViewFactory { showProgressHandler.sendEmptyMessage(SHOW_PROGRESS); loadThreadRun = System.currentTimeMillis(); - SearchResult searchResult; + final SearchResult searchResult; if (mapMode == MapMode.LIVE) { searchResult = isLiveEnabled ? new SearchResult() : new SearchResult(DataStore.loadStoredInViewport(mapView.getViewport(), Settings.getCacheType())); } else { diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java index 048217e..9649c0d 100644 --- a/main/src/cgeo/geocaching/maps/CachesOverlay.java +++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java @@ -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); @@ -159,8 +159,8 @@ public class CachesOverlay extends AbstractItemizedOverlay { * levels which are used to see the circles. * */ - 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(), @@ -200,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) { @@ -230,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(); @@ -251,7 +251,7 @@ public class CachesOverlay extends AbstractItemizedOverlay { } progress.dismiss(); - } catch (NotFoundException e) { + } catch (final NotFoundException e) { Log.e("CachesOverlay.onTap", e); progress.dismiss(); } @@ -260,10 +260,10 @@ public class CachesOverlay extends AbstractItemizedOverlay { } @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); } @@ -274,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); } diff --git a/main/src/cgeo/geocaching/maps/PositionDrawer.java b/main/src/cgeo/geocaching/maps/PositionDrawer.java index 6a45e62..c7d1734 100644 --- a/main/src/cgeo/geocaching/maps/PositionDrawer.java +++ b/main/src/cgeo/geocaching/maps/PositionDrawer.java @@ -28,21 +28,21 @@ public class PositionDrawer { private Paint accuracyCircle = null; private Paint historyLine = null; private Paint historyLineShadow = null; - private Point center = new Point(); - private Point left = new Point(); + private final Point center = new Point(); + private final Point left = new Point(); private Bitmap arrow = null; private int widthArrowHalf = 0; private int heightArrowHalf = 0; private PaintFlagsDrawFilter setfil = null; private PaintFlagsDrawFilter remfil = null; - private PositionHistory positionHistory = new PositionHistory(); - private MapItemFactory mapItemFactory; + private final PositionHistory positionHistory = new PositionHistory(); + private final MapItemFactory mapItemFactory; public PositionDrawer() { this.mapItemFactory = Settings.getMapProvider().getMapItemFactory(); } - void drawPosition(Canvas canvas, MapProjectionImpl projection) { + void drawPosition(final Canvas canvas, final MapProjectionImpl projection) { if (coordinates == null || location == null) { return; } @@ -76,20 +76,20 @@ public class PositionDrawer { canvas.setDrawFilter(setfil); - double latitude = coordinates.getLatitude(); - double longitude = coordinates.getLongitude(); - float accuracy = coordinates.getAccuracy(); + final double latitude = coordinates.getLatitude(); + final double longitude = coordinates.getLongitude(); + final float accuracy = coordinates.getAccuracy(); - float[] result = new float[1]; + final float[] result = new float[1]; Location.distanceBetween(latitude, longitude, latitude, longitude + 1, result); - float longitudeLineDistance = result[0]; + final float longitudeLineDistance = result[0]; final Geopoint leftCoords = new Geopoint(latitude, longitude - accuracy / longitudeLineDistance); - GeoPointImpl leftGeo = mapItemFactory.getGeoPointBase(leftCoords); + final GeoPointImpl leftGeo = mapItemFactory.getGeoPointBase(leftCoords); projection.toPixels(leftGeo, left); projection.toPixels(location, center); - int radius = center.x - left.x; + final int radius = center.x - left.x; accuracyCircle.setColor(0x66000000); accuracyCircle.setStyle(Style.STROKE); @@ -106,23 +106,23 @@ public class PositionDrawer { final ArrayList<Location> paintHistory = new ArrayList<>(positionHistory.getHistory()); paintHistory.add(coordinates); - int size = paintHistory.size(); + final int size = paintHistory.size(); if (size > 1) { int alphaCnt = size - 201; if (alphaCnt < 1) { alphaCnt = 1; } - Point pointNow = new Point(); - Point pointPrevious = new Point(); - Location prev = paintHistory.get(0); + final Point pointNow = new Point(); + final Point pointPrevious = new Point(); + final Location prev = paintHistory.get(0); projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(prev)), pointPrevious); for (int cnt = 1; cnt < size; cnt++) { - Location now = paintHistory.get(cnt); + final Location now = paintHistory.get(cnt); projection.toPixels(mapItemFactory.getGeoPointBase(new Geopoint(now)), pointNow); - int alpha; + final int alpha; if ((alphaCnt - cnt) > 0) { alpha = 255 / (alphaCnt - cnt); } @@ -147,10 +147,10 @@ public class PositionDrawer { heightArrowHalf = arrow.getHeight() / 2; } - int marginLeft = center.x - widthArrowHalf; - int marginTop = center.y - heightArrowHalf; + final int marginLeft = center.x - widthArrowHalf; + final int marginTop = center.y - heightArrowHalf; - Matrix matrix = new Matrix(); + final Matrix matrix = new Matrix(); matrix.setRotate(heading, widthArrowHalf, heightArrowHalf); matrix.postTranslate(marginLeft, marginTop); @@ -163,11 +163,11 @@ public class PositionDrawer { return positionHistory.getHistory(); } - public void setHistory(ArrayList<Location> history) { + public void setHistory(final ArrayList<Location> history) { positionHistory.setHistory(history); } - public void setHeading(float bearingNow) { + public void setHeading(final float bearingNow) { heading = bearingNow; } @@ -175,7 +175,7 @@ public class PositionDrawer { return heading; } - public void setCoordinates(Location coordinatesIn) { + public void setCoordinates(final Location coordinatesIn) { coordinates = coordinatesIn; location = mapItemFactory.getGeoPointBase(new Geopoint(coordinates)); } diff --git a/main/src/cgeo/geocaching/maps/PositionHistory.java b/main/src/cgeo/geocaching/maps/PositionHistory.java index af13740..4394eba 100644 --- a/main/src/cgeo/geocaching/maps/PositionHistory.java +++ b/main/src/cgeo/geocaching/maps/PositionHistory.java @@ -24,7 +24,7 @@ public class PositionHistory { /** * Adds the current position to the trail history to be able to show the trail on the map. */ - void rememberTrailPosition(Location coordinates) { + void rememberTrailPosition(final Location coordinates) { if (coordinates.getAccuracy() >= 50f) { return; } @@ -36,7 +36,7 @@ public class PositionHistory { return; } - Location historyRecent = history.get(history.size() - 1); + final Location historyRecent = history.get(history.size() - 1); if (historyRecent.distanceTo(coordinates) <= MINIMUM_DISTANCE_METERS) { return; } @@ -56,7 +56,7 @@ public class PositionHistory { return history; } - public void setHistory(ArrayList<Location> history) { + public void setHistory(final ArrayList<Location> history) { this.history = history; } diff --git a/main/src/cgeo/geocaching/maps/ScaleDrawer.java b/main/src/cgeo/geocaching/maps/ScaleDrawer.java index 04398b4..e905873 100644 --- a/main/src/cgeo/geocaching/maps/ScaleDrawer.java +++ b/main/src/cgeo/geocaching/maps/ScaleDrawer.java @@ -25,8 +25,8 @@ public class ScaleDrawer { private float pixelDensity = 0; public ScaleDrawer() { - DisplayMetrics metrics = new DisplayMetrics(); - WindowManager windowManager = (WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE); + final DisplayMetrics metrics = new DisplayMetrics(); + final WindowManager windowManager = (WindowManager) CgeoApplication.getInstance().getSystemService(Context.WINDOW_SERVICE); windowManager.getDefaultDisplay().getMetrics(metrics); pixelDensity = metrics.density; } @@ -36,7 +36,7 @@ public class ScaleDrawer { return scale * Math.floor(distance / scale); } - void drawScale(Canvas canvas, MapViewImpl mapView) { + void drawScale(final Canvas canvas, final MapViewImpl mapView) { final double span = mapView.getLongitudeSpan() / 1e6; final GeoPointImpl center = mapView.getMapViewCenter(); diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlay.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlay.java index 9b18c2d..3d2b83c 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlay.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlay.java @@ -21,10 +21,10 @@ import java.util.concurrent.locks.ReentrantLock; */ public class GoogleCacheOverlay extends ItemizedOverlay<GoogleCacheOverlayItem> implements ItemizedOverlayImpl { - private CachesOverlay base; - private Lock lock = new ReentrantLock(); + private final CachesOverlay base; + private final Lock lock = new ReentrantLock(); - public GoogleCacheOverlay(Context contextIn, Drawable markerIn) { + public GoogleCacheOverlay(final Context contextIn, final Drawable markerIn) { super(boundCenterBottom(markerIn)); base = new CachesOverlay(this, contextIn); } @@ -35,7 +35,7 @@ public class GoogleCacheOverlay extends ItemizedOverlay<GoogleCacheOverlayItem> } @Override - protected GoogleCacheOverlayItem createItem(int i) { + protected GoogleCacheOverlayItem createItem(final int i) { if (base == null) { return null; } @@ -53,7 +53,7 @@ public class GoogleCacheOverlay extends ItemizedOverlay<GoogleCacheOverlayItem> } @Override - protected boolean onTap(int arg0) { + protected boolean onTap(final int arg0) { if (base == null) { return false; } @@ -62,11 +62,11 @@ public class GoogleCacheOverlay extends ItemizedOverlay<GoogleCacheOverlayItem> } @Override - public void draw(Canvas canvas, MapView mapView, boolean shadow) { + public void draw(final Canvas canvas, final MapView mapView, final boolean shadow) { base.draw(canvas, castMapViewImpl(mapView), shadow); } - private static MapViewImpl castMapViewImpl(MapView mapView) { + private static MapViewImpl castMapViewImpl(final MapView mapView) { assert mapView instanceof MapViewImpl; return (MapViewImpl) mapView; } @@ -77,28 +77,28 @@ public class GoogleCacheOverlay extends ItemizedOverlay<GoogleCacheOverlayItem> } @Override - public Drawable superBoundCenterBottom(Drawable marker) { + public Drawable superBoundCenterBottom(final Drawable marker) { return ItemizedOverlay.boundCenterBottom(marker); } @Override - public void superSetLastFocusedItemIndex(int i) { + public void superSetLastFocusedItemIndex(final int i) { super.setLastFocusedIndex(i); } @Override - public boolean superOnTap(int index) { + public boolean superOnTap(final int index) { return super.onTap(index); } @Override - public void superDraw(Canvas canvas, MapViewImpl mapView, boolean shadow) { + public void superDraw(final Canvas canvas, final MapViewImpl mapView, final boolean shadow) { super.draw(canvas, (MapView) mapView, shadow); } @Override - public void superDrawOverlayBitmap(Canvas canvas, Point drawPosition, - MapProjectionImpl projection, byte drawZoomLevel) { + public void superDrawOverlayBitmap(final Canvas canvas, final Point drawPosition, + final MapProjectionImpl projection, final byte drawZoomLevel) { // Nothing to do here... } diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlayItem.java index 463aae9..977d67c 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlayItem.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleCacheOverlayItem.java @@ -10,7 +10,7 @@ public class GoogleCacheOverlayItem extends OverlayItem implements CachesOverlay final private IWaypoint coord; final private boolean applyDistanceRule; - public GoogleCacheOverlayItem(final IWaypoint coordinate, boolean applyDistanceRule) { + public GoogleCacheOverlayItem(final IWaypoint coordinate, final boolean applyDistanceRule) { super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), ""); this.coord = coordinate; diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java index 7fbfac2..3f89807 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleGeoPoint.java @@ -7,7 +7,7 @@ import com.google.android.maps.GeoPoint; public class GoogleGeoPoint extends GeoPoint implements GeoPointImpl { - public GoogleGeoPoint(int latitudeE6, int longitudeE6) { + public GoogleGeoPoint(final int latitudeE6, final int longitudeE6) { super(latitudeE6, longitudeE6); } diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapActivity.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapActivity.java index 374e7b0..04078cb 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapActivity.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapActivity.java @@ -16,7 +16,7 @@ import android.view.View; public class GoogleMapActivity extends MapActivity implements MapActivityImpl, FilteredActivity { - private AbstractMap mapBase; + private final AbstractMap mapBase; public GoogleMapActivity() { mapBase = new CGeoMap(this); @@ -33,7 +33,7 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F } @Override - protected void onCreate(Bundle icicle) { + protected void onCreate(final Bundle icicle) { mapBase.onCreate(icicle); } @@ -58,17 +58,17 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(final Menu menu) { return mapBase.onCreateOptionsMenu(menu); } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(final MenuItem item) { return mapBase.onOptionsItemSelected(item); } @Override - public boolean onPrepareOptionsMenu(Menu menu) { + public boolean onPrepareOptionsMenu(final Menu menu) { return mapBase.onPrepareOptionsMenu(menu); } @@ -78,12 +78,12 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F } @Override - public void superOnCreate(Bundle savedInstanceState) { + public void superOnCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override - public boolean superOnCreateOptionsMenu(Menu menu) { + public boolean superOnCreateOptionsMenu(final Menu menu) { return super.onCreateOptionsMenu(menu); } @@ -93,12 +93,12 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F } @Override - public boolean superOnOptionsItemSelected(MenuItem item) { + public boolean superOnOptionsItemSelected(final MenuItem item) { return super.onOptionsItemSelected(item); } @Override - public void navigateUp(View view) { + public void navigateUp(final View view) { ActivityMixin.navigateUp(this); } @@ -118,12 +118,12 @@ public class GoogleMapActivity extends MapActivity implements MapActivityImpl, F } @Override - public boolean superOnPrepareOptionsMenu(Menu menu) { + public boolean superOnPrepareOptionsMenu(final Menu menu) { return super.onPrepareOptionsMenu(menu); } @Override - public void showFilterMenu(View view) { + public void showFilterMenu(final View view) { // do nothing, the filter bar only shows the global filter } } diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapController.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapController.java index ea95676..a533a76 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapController.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapController.java @@ -8,34 +8,34 @@ import com.google.android.maps.MapController; public class GoogleMapController implements MapControllerImpl { - private MapController mapController; + private final MapController mapController; - public GoogleMapController(MapController mapControllerIn) { + public GoogleMapController(final MapController mapControllerIn) { mapController = mapControllerIn; } @Override - public void animateTo(GeoPointImpl geoPoint) { + public void animateTo(final GeoPointImpl geoPoint) { mapController.animateTo(castToGeoPointImpl(geoPoint)); } - private static GeoPoint castToGeoPointImpl(GeoPointImpl geoPoint) { + private static GeoPoint castToGeoPointImpl(final GeoPointImpl geoPoint) { assert geoPoint instanceof GeoPoint; return (GeoPoint) geoPoint; } @Override - public void setCenter(GeoPointImpl geoPoint) { + public void setCenter(final GeoPointImpl geoPoint) { mapController.setCenter(castToGeoPointImpl(geoPoint)); } @Override - public void setZoom(int mapzoom) { + public void setZoom(final int mapzoom) { mapController.setZoom(mapzoom); } @Override - public void zoomToSpan(int latSpanE6, int lonSpanE6) { + public void zoomToSpan(final int latSpanE6, final int lonSpanE6) { mapController.zoomToSpan(latSpanE6, lonSpanE6); } diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java index 5fedf69..a35eda8 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapItemFactory.java @@ -14,7 +14,7 @@ public class GoogleMapItemFactory implements MapItemFactory { } @Override - public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, boolean applyDistanceRule) { + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, final boolean applyDistanceRule) { return new GoogleCacheOverlayItem(coordinate, applyDistanceRule); } } diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProjection.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProjection.java index 901a369..8a03bbb 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProjection.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProjection.java @@ -10,14 +10,14 @@ import android.graphics.Point; public class GoogleMapProjection implements MapProjectionImpl { - private Projection projection; + private final Projection projection; - public GoogleMapProjection(Projection projectionIn) { + public GoogleMapProjection(final Projection projectionIn) { projection = projectionIn; } @Override - public void toPixels(GeoPointImpl leftGeo, Point left) { + public void toPixels(final GeoPointImpl leftGeo, final Point left) { projection.toPixels((GeoPoint) leftGeo, left); } diff --git a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProvider.java b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProvider.java index 884e076..8c9dd4d 100644 --- a/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProvider.java +++ b/main/src/cgeo/geocaching/maps/google/v1/GoogleMapProvider.java @@ -83,7 +83,7 @@ public final class GoogleMapProvider extends AbstractMapProvider { private static final class GoogleSatelliteSource extends AbstractGoogleMapSource { - public GoogleSatelliteSource(MapProvider mapProvider, String name) { + public GoogleSatelliteSource(final MapProvider mapProvider, final String name) { super(GOOGLE_SATELLITE_ID, mapProvider, name); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlay.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlay.java index b9e40d7..02e4243 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlay.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlay.java @@ -18,10 +18,10 @@ import java.util.concurrent.locks.ReentrantLock; public class MapsforgeCacheOverlay extends ItemizedOverlay<MapsforgeCacheOverlayItem> implements ItemizedOverlayImpl { - private CachesOverlay base; - private Lock lock = new ReentrantLock(); + private final CachesOverlay base; + private final Lock lock = new ReentrantLock(); - public MapsforgeCacheOverlay(Context contextIn, Drawable markerIn) { + public MapsforgeCacheOverlay(final Context contextIn, final Drawable markerIn) { super(boundCenterBottom(markerIn)); base = new CachesOverlay(this, contextIn); } @@ -32,7 +32,7 @@ public class MapsforgeCacheOverlay extends ItemizedOverlay<MapsforgeCacheOverlay } @Override - protected MapsforgeCacheOverlayItem createItem(int i) { + protected MapsforgeCacheOverlayItem createItem(final int i) { if (base == null) { return null; } @@ -50,7 +50,7 @@ public class MapsforgeCacheOverlay extends ItemizedOverlay<MapsforgeCacheOverlay } @Override - protected boolean onTap(int arg0) { + protected boolean onTap(final int arg0) { if (base == null) { return false; } @@ -59,8 +59,8 @@ public class MapsforgeCacheOverlay extends ItemizedOverlay<MapsforgeCacheOverlay } @Override - protected void drawOverlayBitmap(Canvas canvas, Point drawPosition, - Projection projection, byte drawZoomLevel) { + protected void drawOverlayBitmap(final Canvas canvas, final Point drawPosition, + final Projection projection, final byte drawZoomLevel) { base.drawOverlayBitmap(canvas, drawPosition, new MapsforgeMapProjection(projection), drawZoomLevel); } @@ -70,28 +70,28 @@ public class MapsforgeCacheOverlay extends ItemizedOverlay<MapsforgeCacheOverlay } @Override - public Drawable superBoundCenterBottom(Drawable marker) { + public Drawable superBoundCenterBottom(final Drawable marker) { return ItemizedOverlay.boundCenterBottom(marker); } @Override - public void superSetLastFocusedItemIndex(int i) { + public void superSetLastFocusedItemIndex(final int i) { // nothing to do } @Override - public boolean superOnTap(int index) { + public boolean superOnTap(final int index) { return super.onTap(index); } @Override - public void superDraw(Canvas canvas, MapViewImpl mapView, boolean shadow) { + public void superDraw(final Canvas canvas, final MapViewImpl mapView, final boolean shadow) { // nothing to do here... } @Override - public void superDrawOverlayBitmap(Canvas canvas, Point drawPosition, - MapProjectionImpl projection, byte drawZoomLevel) { + public void superDrawOverlayBitmap(final Canvas canvas, final Point drawPosition, + final MapProjectionImpl projection, final byte drawZoomLevel) { super.drawOverlayBitmap(canvas, drawPosition, (Projection) projection.getImpl(), drawZoomLevel); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java index 27ca664..4a1b080 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java @@ -12,7 +12,7 @@ public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOver final private IWaypoint coord; final private boolean applyDistanceRule; - public MapsforgeCacheOverlayItem(IWaypoint coordinate, boolean applyDistanceRule) { + public MapsforgeCacheOverlayItem(final IWaypoint coordinate, final boolean applyDistanceRule) { super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), ""); this.coord = coordinate; @@ -25,7 +25,7 @@ public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOver } @Override - public Drawable getMarker(int index) { + public Drawable getMarker(final int index) { return getMarker(); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java index 298cb90..25269e6 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeGeoPoint.java @@ -9,7 +9,7 @@ public class MapsforgeGeoPoint extends GeoPoint implements GeoPointImpl { private static final long serialVersionUID = 1L; - public MapsforgeGeoPoint(int latitudeE6, int longitudeE6) { + public MapsforgeGeoPoint(final int latitudeE6, final int longitudeE6) { super(latitudeE6, longitudeE6); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java index 94213ba..5220e05 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapActivity.java @@ -16,7 +16,7 @@ import android.view.View; public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl, FilteredActivity { - private AbstractMap mapBase; + private final AbstractMap mapBase; public MapsforgeMapActivity() { mapBase = new CGeoMap(this); @@ -28,7 +28,7 @@ public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl } @Override - protected void onCreate(Bundle icicle) { + protected void onCreate(final Bundle icicle) { mapBase.onCreate(icicle); } @@ -53,17 +53,17 @@ public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl } @Override - public boolean onCreateOptionsMenu(Menu menu) { + public boolean onCreateOptionsMenu(final Menu menu) { return mapBase.onCreateOptionsMenu(menu); } @Override - public boolean onOptionsItemSelected(MenuItem item) { + public boolean onOptionsItemSelected(final MenuItem item) { return mapBase.onOptionsItemSelected(item); } @Override - public boolean onPrepareOptionsMenu(Menu menu) { + public boolean onPrepareOptionsMenu(final Menu menu) { return mapBase.onPrepareOptionsMenu(menu); } @@ -73,12 +73,12 @@ public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl } @Override - public void superOnCreate(Bundle savedInstanceState) { + public void superOnCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); } @Override - public boolean superOnCreateOptionsMenu(Menu menu) { + public boolean superOnCreateOptionsMenu(final Menu menu) { return super.onCreateOptionsMenu(menu); } @@ -88,7 +88,7 @@ public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl } @Override - public boolean superOnOptionsItemSelected(MenuItem item) { + public boolean superOnOptionsItemSelected(final MenuItem item) { return super.onOptionsItemSelected(item); } @@ -108,17 +108,17 @@ public class MapsforgeMapActivity extends MapActivity implements MapActivityImpl } @Override - public boolean superOnPrepareOptionsMenu(Menu menu) { + public boolean superOnPrepareOptionsMenu(final Menu menu) { return super.onPrepareOptionsMenu(menu); } @Override - public void navigateUp(View view) { + public void navigateUp(final View view) { ActivityMixin.navigateUp(this); } @Override - public void showFilterMenu(View view) { + public void showFilterMenu(final View view) { // do nothing, the filter bar only shows the global filter } } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java index 8b2e1e9..cfce07d 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java @@ -8,26 +8,26 @@ import org.mapsforge.core.GeoPoint; public class MapsforgeMapController implements MapControllerImpl { - private MapController mapController; - private int maxZoomLevel; + private final MapController mapController; + private final int maxZoomLevel; - public MapsforgeMapController(MapController mapControllerIn, int maxZoomLevelIn) { + public MapsforgeMapController(final MapController mapControllerIn, final int maxZoomLevelIn) { mapController = mapControllerIn; maxZoomLevel = maxZoomLevelIn; } @Override - public void animateTo(GeoPointImpl geoPoint) { + public void animateTo(final GeoPointImpl geoPoint) { mapController.setCenter(castToGeoPoint(geoPoint)); } - private static GeoPoint castToGeoPoint(GeoPointImpl geoPoint) { + private static GeoPoint castToGeoPoint(final GeoPointImpl geoPoint) { assert geoPoint instanceof GeoPoint; return (GeoPoint) geoPoint; } @Override - public void setCenter(GeoPointImpl geoPoint) { + public void setCenter(final GeoPointImpl geoPoint) { mapController.setCenter(castToGeoPoint(geoPoint)); } @@ -36,19 +36,19 @@ public class MapsforgeMapController implements MapControllerImpl { * mapzoom-1 is used to be compatible with Google Maps zoom levels */ @Override - public void setZoom(int mapzoom) { + public void setZoom(final int mapzoom) { // Google Maps and OSM Maps use different zoom levels for the same view. // All OSM Maps zoom levels are offset by 1 so they match Google Maps. mapController.setZoom(Math.min(mapzoom - 1, maxZoomLevel)); } @Override - public void zoomToSpan(int latSpanE6, int lonSpanE6) { + public void zoomToSpan(final int latSpanE6, final int lonSpanE6) { if (latSpanE6 != 0 && lonSpanE6 != 0) { // calculate zoomlevel - int distDegree = Math.max(latSpanE6, lonSpanE6); - int zoomLevel = (int) Math.floor(Math.log(360.0 * 1e6 / distDegree) / Math.log(2)); + final int distDegree = Math.max(latSpanE6, lonSpanE6); + final int zoomLevel = (int) Math.floor(Math.log(360.0 * 1e6 / distDegree) / Math.log(2)); mapController.setZoom(zoomLevel + 1); } } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java index ccfd023..8adf4ad 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapItemFactory.java @@ -14,7 +14,7 @@ public class MapsforgeMapItemFactory implements MapItemFactory { } @Override - public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, boolean applyDistanceRule) { + public CachesOverlayItemImpl getCachesOverlayItem(final IWaypoint coordinate, final boolean applyDistanceRule) { return new MapsforgeCacheOverlayItem(coordinate, applyDistanceRule); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProjection.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProjection.java index 68d7123..a042eca 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProjection.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapProjection.java @@ -10,14 +10,14 @@ import android.graphics.Point; public class MapsforgeMapProjection implements MapProjectionImpl { - private Projection projection; + private final Projection projection; - public MapsforgeMapProjection(Projection projectionIn) { + public MapsforgeMapProjection(final Projection projectionIn) { projection = projectionIn; } @Override - public void toPixels(GeoPointImpl leftGeo, Point left) { + public void toPixels(final GeoPointImpl leftGeo, final Point left) { projection.toPixels((GeoPoint) leftGeo, left); } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapSource.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapSource.java index 861e567..23e9a23 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapSource.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapSource.java @@ -9,7 +9,7 @@ class MapsforgeMapSource extends AbstractMapSource { private final MapGeneratorInternal generator; - public MapsforgeMapSource(final String id, MapProvider mapProvider, String name, MapGeneratorInternal generator) { + public MapsforgeMapSource(final String id, final MapProvider mapProvider, final String name, final MapGeneratorInternal generator) { super(id, mapProvider, name); this.generator = generator; } |