aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <Bananeweizen@gmx.de>2011-08-11 11:57:23 -0700
committerBananeweizen <Bananeweizen@gmx.de>2011-08-11 11:57:23 -0700
commitbbaad718eca730232ff1751a64d1335bc1031c52 (patch)
tree2a74f03ed0da9d4ebb89f881a63a9398ae9f613a
parenta69110de4c96441bd2d659d7db1760da1203873b (diff)
parent3e24489a74d186d1d0f297d12a6aff73f0c455dd (diff)
downloadcgeo-bbaad718eca730232ff1751a64d1335bc1031c52.zip
cgeo-bbaad718eca730232ff1751a64d1335bc1031c52.tar.gz
cgeo-bbaad718eca730232ff1751a64d1335bc1031c52.tar.bz2
Merge pull request #160 from rsudev/master
Fixing issue #124 - problems in mapview switch
-rw-r--r--src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java4
-rw-r--r--src/cgeo/geocaching/mapcommon/cgMapOverlay.java9
-rw-r--r--src/cgeo/geocaching/mapcommon/cgeomap.java12
-rw-r--r--src/cgeo/geocaching/mapsforge/mfMapView.java30
4 files changed, 40 insertions, 15 deletions
diff --git a/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java b/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java
index ebaa6ce..cbf065c 100644
--- a/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java
+++ b/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java
@@ -40,10 +40,12 @@ public class cgMapMyOverlay implements OverlayBase {
private Point historyPointN = new Point();
private Point historyPointP = new Point();
private Activity activity;
+ private MapFactory mapFactory = null;
public cgMapMyOverlay(cgSettings settingsIn, Activity activity) {
settings = settingsIn;
this.activity = activity;
+ this.mapFactory = settings.getMapFactory();
}
public void setCoordinates(Location coordinatesIn) {
@@ -72,8 +74,6 @@ public class cgMapMyOverlay implements OverlayBase {
if (coordinates == null || location == null) return;
- MapFactory mapFactory = settings.getMapFactory();
-
if (accuracyCircle == null) {
accuracyCircle = new Paint();
accuracyCircle.setAntiAlias(true);
diff --git a/src/cgeo/geocaching/mapcommon/cgMapOverlay.java b/src/cgeo/geocaching/mapcommon/cgMapOverlay.java
index e5e6e46..b7d2141 100644
--- a/src/cgeo/geocaching/mapcommon/cgMapOverlay.java
+++ b/src/cgeo/geocaching/mapcommon/cgMapOverlay.java
@@ -44,6 +44,7 @@ public class cgMapOverlay extends ItemizedOverlayBase implements OverlayBase {
private PaintFlagsDrawFilter setfil = null;
private PaintFlagsDrawFilter remfil = null;
private cgSettings settings;
+ private MapFactory mapFactory = null;
public cgMapOverlay(cgSettings settingsIn, ItemizedOverlayImpl ovlImpl, Context contextIn, Boolean fromDetailIn) {
super(ovlImpl);
@@ -53,8 +54,10 @@ public class cgMapOverlay extends ItemizedOverlayBase implements OverlayBase {
context = contextIn;
fromDetail = fromDetailIn;
+
+ mapFactory = settings.getMapFactory();
}
-
+
public void updateItems(CacheOverlayItemImpl item) {
ArrayList<CacheOverlayItemImpl> itemsPre = new ArrayList<CacheOverlayItemImpl>();
itemsPre.add(item);
@@ -104,8 +107,6 @@ public class cgMapOverlay extends ItemizedOverlayBase implements OverlayBase {
private void drawInternal(Canvas canvas, MapProjectionImpl projection) {
- MapFactory mapFactory = settings.getMapFactory();
-
if (displayCircles) {
if (blockedCircle == null) {
blockedCircle = new Paint();
@@ -156,6 +157,7 @@ public class cgMapOverlay extends ItemizedOverlayBase implements OverlayBase {
@Override
public boolean onTap(int index) {
+
try {
if (items.size() <= index) {
return false;
@@ -221,6 +223,7 @@ public class cgMapOverlay extends ItemizedOverlayBase implements OverlayBase {
}
public void infoDialog(int index) {
+
final CacheOverlayItemImpl item = items.get(index);
final cgCoord coordinate = item.getCoord();
diff --git a/src/cgeo/geocaching/mapcommon/cgeomap.java b/src/cgeo/geocaching/mapcommon/cgeomap.java
index 2322d3a..56a1678 100644
--- a/src/cgeo/geocaching/mapcommon/cgeomap.java
+++ b/src/cgeo/geocaching/mapcommon/cgeomap.java
@@ -643,6 +643,10 @@ public class cgeomap extends MapBase {
boolean mapRestartRequired = switchMapSource(mapSource);
if (mapRestartRequired) {
+ // close old mapview
+ activity.finish();
+
+ // prepare information to restart a similar view
Intent mapIntent = new Intent(activity, settings.getMapFactory().getMapClass());
mapIntent.putExtra("detail", fromDetailIntent);
@@ -657,10 +661,10 @@ public class cgeomap extends MapBase {
mapState[1] = mapCenter.getLongitudeE6();
mapState[2] = mapView.getMapZoomLevel();
mapIntent.putExtra("mapstate", mapState);
-
+
+ // start the new map
activity.startActivity(mapIntent);
-
- activity.finish();
+
}
return true;
@@ -696,7 +700,7 @@ public class cgeomap extends MapBase {
prefsEdit.putInt("mapsource", settings.mapSource.ordinal());
prefsEdit.commit();
-
+
boolean mapRestartRequired = settings.mapSource.isGoogleMapSource()!= settings.mapSourceUsed.isGoogleMapSource();
if (!mapRestartRequired) {
diff --git a/src/cgeo/geocaching/mapsforge/mfMapView.java b/src/cgeo/geocaching/mapsforge/mfMapView.java
index 4d7b31c..de4bd1a 100644
--- a/src/cgeo/geocaching/mapsforge/mfMapView.java
+++ b/src/cgeo/geocaching/mapsforge/mfMapView.java
@@ -89,23 +89,41 @@ public class mfMapView extends MapView implements MapViewImpl {
@Override
public int getLatitudeSpan() {
+
+ int span = 0;
Projection projection = getProjection();
- GeoPoint low = projection.fromPixels(0, 0);
- GeoPoint high = projection.fromPixels(0, getHeight());
+ if (projection != null && getHeight() > 0) {
+
+ GeoPoint low = projection.fromPixels(0, 0);
+ GeoPoint high = projection.fromPixels(0, getHeight());
- return Math.abs(high.getLatitudeE6() - low.getLatitudeE6());
+ if (low != null && high != null) {
+ span = Math.abs(high.getLatitudeE6() - low.getLatitudeE6());
+ }
+ }
+
+ return span;
}
@Override
public int getLongitudeSpan() {
+
+ int span = 0;
+
Projection projection = getProjection();
- GeoPoint low = projection.fromPixels(0, 0);
- GeoPoint high = projection.fromPixels(getWidth(), 0);
+ if (projection != null && getWidth() > 0) {
+ GeoPoint low = projection.fromPixels(0, 0);
+ GeoPoint high = projection.fromPixels(getWidth(), 0);
+
+ if (low != null && high != null) {
+ span = Math.abs(high.getLongitudeE6() - low.getLongitudeE6());
+ }
+ }
- return Math.abs(high.getLongitudeE6() - low.getLongitudeE6());
+ return span;
}
@Override