diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2011-11-16 16:39:18 +0100 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2011-11-16 17:48:08 +0100 |
commit | 981442890950c5202db7abdfc21f74dbbb6ca1e1 (patch) | |
tree | 03d4d21b4ab00d1b3411489cb41bc28a2ce173d9 /main | |
parent | fbb406bd9239ef0ebd0479b9b7b1bb20266c6991 (diff) | |
download | cgeo-981442890950c5202db7abdfc21f74dbbb6ca1e1.zip cgeo-981442890950c5202db7abdfc21f74dbbb6ca1e1.tar.gz cgeo-981442890950c5202db7abdfc21f74dbbb6ca1e1.tar.bz2 |
Use an activity where it is required
If we only have a context, we should start a new activity stack.
This is not the case if we have an activity (and we do).
Diffstat (limited to 'main')
-rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 22 |
1 files changed, 13 insertions, 9 deletions
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index bbbb913..069db23 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -1869,8 +1869,12 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory return imageView; } + private static Intent newIntent(final Context context) { + return new Intent(context, Settings.getMapProvider().getMapClass()); + } + public static void startActivitySearch(final Activity fromActivity, final cgSearch search, final String title, boolean detail) { - Intent mapIntent = new Intent(fromActivity, Settings.getMapProvider().getMapClass()); + final Intent mapIntent = newIntent(fromActivity); mapIntent.putExtra(EXTRAS_DETAIL, detail); mapIntent.putExtra(EXTRAS_SEARCH, search); if (StringUtils.isNotBlank(title)) { @@ -1879,12 +1883,12 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory fromActivity.startActivity(mapIntent); } - public static void startActivityLiveMap(final Context context) { - context.startActivity(new Intent(context, Settings.getMapProvider().getMapClass())); + public static void startActivityLiveMap(final Activity fromActivity) { + fromActivity.startActivity(newIntent(fromActivity)); } - public static void startActivityCoords(final Context context, final Geopoint coords, final WaypointType type, final String title) { - Intent mapIntent = new Intent(context, Settings.getMapProvider().getMapClass()); + public static void startActivityCoords(final Activity fromActivity, final Geopoint coords, final WaypointType type, final String title) { + final Intent mapIntent = newIntent(fromActivity); mapIntent.putExtra(EXTRAS_DETAIL, false); mapIntent.putExtra(EXTRAS_LATITUDE, coords.getLatitude()); mapIntent.putExtra(EXTRAS_LONGITUDE, coords.getLongitude()); @@ -1894,14 +1898,14 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory if (StringUtils.isNotBlank(title)) { mapIntent.putExtra(EXTRAS_MAP_TITLE, title); } - context.startActivity(mapIntent); + fromActivity.startActivity(mapIntent); } - public static void startActivityGeoCode(final Context context, final String geocode) { - Intent mapIntent = new Intent(context, Settings.getMapProvider().getMapClass()); + public static void startActivityGeoCode(final Activity fromActivity, final String geocode) { + final Intent mapIntent = newIntent(fromActivity); mapIntent.putExtra(EXTRAS_DETAIL, false); mapIntent.putExtra(EXTRAS_GEOCODE, geocode); mapIntent.putExtra(EXTRAS_MAP_TITLE, geocode); - context.startActivity(mapIntent); + fromActivity.startActivity(mapIntent); } } |