aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorrsudev <rsudev@googlemail.com>2011-08-11 20:46:20 +0200
committerrsudev <rsudev@googlemail.com>2011-08-11 20:46:20 +0200
commit9f567d48e0d8b1db8216e833ade05787e314d9d1 (patch)
treea4f57422619eae5d50b7b964192b7901e27edbb8
parent5bc477b7b5d08f7bf635bf48b42134705df9cab2 (diff)
downloadcgeo-9f567d48e0d8b1db8216e833ade05787e314d9d1.zip
cgeo-9f567d48e0d8b1db8216e833ade05787e314d9d1.tar.gz
cgeo-9f567d48e0d8b1db8216e833ade05787e314d9d1.tar.bz2
Fix issue #124 part 2 (ClassCast)
-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
3 files changed, 16 insertions, 9 deletions
diff --git a/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java b/src/cgeo/geocaching/mapcommon/cgMapMyOverlay.java
index 708ad3e..a27efee 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 9ea03e5..5802239 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) {