diff options
author | rsudev <rasch@munin-soft.de> | 2011-11-15 22:04:20 +0100 |
---|---|---|
committer | rsudev <rasch@munin-soft.de> | 2011-11-15 22:04:20 +0100 |
commit | afb9a89209cf2e64eca726549f0da93a1da5ff80 (patch) | |
tree | ddd96b3e03722e3e32861a3e7944a8c7cbf4265f /main/src/cgeo/geocaching/Settings.java | |
parent | 2d9773fa90cba4bafff3bd71b9b7d3baaaff4766 (diff) | |
download | cgeo-afb9a89209cf2e64eca726549f0da93a1da5ff80.zip cgeo-afb9a89209cf2e64eca726549f0da93a1da5ff80.tar.gz cgeo-afb9a89209cf2e64eca726549f0da93a1da5ff80.tar.bz2 |
Implementing #179, refactor maps to single source, last part
Diffstat (limited to 'main/src/cgeo/geocaching/Settings.java')
-rw-r--r-- | main/src/cgeo/geocaching/Settings.java | 58 |
1 files changed, 13 insertions, 45 deletions
diff --git a/main/src/cgeo/geocaching/Settings.java b/main/src/cgeo/geocaching/Settings.java index 2007493..822bd04 100644 --- a/main/src/cgeo/geocaching/Settings.java +++ b/main/src/cgeo/geocaching/Settings.java @@ -2,9 +2,8 @@ package cgeo.geocaching; import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.geopoint.Geopoint; -import cgeo.geocaching.maps.google.GoogleMapFactory; -import cgeo.geocaching.maps.interfaces.MapFactory; -import cgeo.geocaching.maps.mapsforge.MapsforgeMapFactory; +import cgeo.geocaching.maps.MapProviderFactory; +import cgeo.geocaching.maps.interfaces.MapProvider; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutablePair; @@ -81,32 +80,6 @@ public final class Settings { void edit(final Editor edit); } - public enum mapSourceEnum { - googleMap, - googleSat, - mapsforgeMapnik, - mapsforgeOsmarender, - mapsforgeCycle, - mapsforgeOffline; - - static mapSourceEnum fromInt(int id) { - final mapSourceEnum[] values = mapSourceEnum.values(); - if (id >= 0 && id < values.length) { - return values[id]; - } else { - return googleMap; - } - } - - public boolean isGoogleMapSource() { - if (googleMap == this || googleSat == this) { - return true; - } - - return false; - } - } - public enum coordInputFormatEnum { Plain, Deg, @@ -134,7 +107,7 @@ public final class Settings { private static String password = null; // maps - private static MapFactory mapFactory = null; + private static MapProvider mapProvider = null; private Settings() { // this class is not to be instantiated; @@ -328,16 +301,11 @@ public final class Settings { }); } - public static MapFactory getMapFactory() { - if (mapFactory == null) { - if (getMapSource().isGoogleMapSource()) { - mapFactory = new GoogleMapFactory(); - } - else { - mapFactory = new MapsforgeMapFactory(); - } + public static MapProvider getMapProvider() { + if (mapProvider == null) { + mapProvider = MapProviderFactory.getMapProvider(getMapSource()); } - return mapFactory; + return mapProvider; } public static String getMapFile() { @@ -705,19 +673,19 @@ public final class Settings { }); } - public static mapSourceEnum getMapSource() { - return mapSourceEnum.fromInt(sharedPrefs.getInt(KEY_MAP_SOURCE, 0)); + public static int getMapSource() { + return sharedPrefs.getInt(KEY_MAP_SOURCE, 0); } - public static void setMapSource(final mapSourceEnum newMapSource) { - if (getMapSource().isGoogleMapSource() != newMapSource.isGoogleMapSource()) { - mapFactory = null; + public static void setMapSource(final int newMapSource) { + if (!MapProviderFactory.IsSameProvider(getMapSource(), newMapSource)) { + mapProvider = null; } editSharedSettings(new PrefRunnable() { @Override public void edit(Editor edit) { - edit.putInt(KEY_MAP_SOURCE, newMapSource.ordinal()); + edit.putInt(KEY_MAP_SOURCE, newMapSource); } }); } |