diff options
Diffstat (limited to 'main/src')
7 files changed, 39 insertions, 8 deletions
diff --git a/main/src/cgeo/geocaching/activity/AbstractActivity.java b/main/src/cgeo/geocaching/activity/AbstractActivity.java index df21a8c..36b6d01 100644 --- a/main/src/cgeo/geocaching/activity/AbstractActivity.java +++ b/main/src/cgeo/geocaching/activity/AbstractActivity.java @@ -96,7 +96,7 @@ public abstract class AbstractActivity extends FragmentActivity implements IAbst // create view variables ButterKnife.inject(this); } - + private void initializeCommonFields() { // initialize commonly used members res = this.getResources(); diff --git a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlay.java b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlay.java index 21d78a0..3339650 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlay.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlay.java @@ -63,7 +63,12 @@ public class GoogleCacheOverlay extends ItemizedOverlay<GoogleCacheOverlayItem> @Override public void draw(Canvas canvas, MapView mapView, boolean shadow) { - base.draw(canvas, (MapViewImpl) mapView, shadow); + base.draw(canvas, castMapViewImpl(mapView), shadow); + } + + private static MapViewImpl castMapViewImpl(MapView mapView) { + assert mapView instanceof MapViewImpl; + return (MapViewImpl) mapView; } @Override diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapController.java b/main/src/cgeo/geocaching/maps/google/GoogleMapController.java index fdd971c..096cd61 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleMapController.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleMapController.java @@ -16,12 +16,17 @@ public class GoogleMapController implements MapControllerImpl { @Override public void animateTo(GeoPointImpl geoPoint) { - mapController.animateTo((GeoPoint) geoPoint); + mapController.animateTo(castToGeoPointImpl(geoPoint)); + } + + private static GeoPoint castToGeoPointImpl(GeoPointImpl geoPoint) { + assert geoPoint instanceof GeoPoint; + return (GeoPoint) geoPoint; } @Override public void setCenter(GeoPointImpl geoPoint) { - mapController.setCenter((GeoPoint) geoPoint); + mapController.setCenter(castToGeoPointImpl(geoPoint)); } @Override diff --git a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java index e937773..0a5cf69 100644 --- a/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java +++ b/main/src/cgeo/geocaching/maps/google/GoogleOverlay.java @@ -28,6 +28,7 @@ public class GoogleOverlay extends Overlay implements OverlayImpl { super.draw(canvas, mapView, shadow); if (overlayBase != null) { + assert mapView instanceof MapViewImpl; overlayBase.draw(canvas, (MapViewImpl) mapView, shadow); } } diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java index 5aaecc8..8b2e1e9 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapController.java @@ -18,12 +18,17 @@ public class MapsforgeMapController implements MapControllerImpl { @Override public void animateTo(GeoPointImpl geoPoint) { - mapController.setCenter((GeoPoint) geoPoint); + mapController.setCenter(castToGeoPoint(geoPoint)); + } + + private static GeoPoint castToGeoPoint(GeoPointImpl geoPoint) { + assert geoPoint instanceof GeoPoint; + return (GeoPoint) geoPoint; } @Override public void setCenter(GeoPointImpl geoPoint) { - mapController.setCenter((GeoPoint) geoPoint); + mapController.setCenter(castToGeoPoint(geoPoint)); } /** diff --git a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapController.java b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapController.java index 573f65e..db33d56 100644 --- a/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapController.java +++ b/main/src/cgeo/geocaching/maps/mapsforge/v024/MapsforgeMapController.java @@ -18,12 +18,17 @@ public class MapsforgeMapController implements MapControllerImpl { @Override public void animateTo(GeoPointImpl geoPoint) { - mapController.setCenter((GeoPoint) geoPoint); + mapController.setCenter(castToGeoPointImpl(geoPoint)); + } + + private static GeoPoint castToGeoPointImpl(GeoPointImpl geoPoint) { + assert geoPoint instanceof GeoPoint; + return (GeoPoint) geoPoint; } @Override public void setCenter(GeoPointImpl geoPoint) { - mapController.setCenter((GeoPoint) geoPoint); + mapController.setCenter(castToGeoPointImpl(geoPoint)); } /** diff --git a/main/src/cgeo/geocaching/settings/RegisterSend2CgeoPreference.java b/main/src/cgeo/geocaching/settings/RegisterSend2CgeoPreference.java index 094b8f5..3e838ab 100644 --- a/main/src/cgeo/geocaching/settings/RegisterSend2CgeoPreference.java +++ b/main/src/cgeo/geocaching/settings/RegisterSend2CgeoPreference.java @@ -40,6 +40,11 @@ public class RegisterSend2CgeoPreference extends Preference { private Handler webAuthHandler = new Handler() { @Override public void handleMessage(Message msg) { + // satisfy static code analysis + if (activity == null) { + return; + } + try { if (progressDialog != null && progressDialog.isShowing()) { progressDialog.dismiss(); @@ -70,6 +75,11 @@ public class RegisterSend2CgeoPreference extends Preference { setOnPreferenceClickListener(new OnPreferenceClickListener() { @Override public boolean onPreferenceClick(Preference preference) { + // satisfy static code analysis + if (activity == null) { + return true; + } + final String deviceName = Settings.getWebDeviceName(); final String deviceCode = Settings.getWebDeviceCode(); |
