diff options
author | rsudev <rasch@munin-soft.de> | 2011-11-15 23:10:33 +0100 |
---|---|---|
committer | rsudev <rasch@munin-soft.de> | 2011-11-15 23:10:33 +0100 |
commit | 082cde2c609dedaef1b970f3e2af71395ef2c543 (patch) | |
tree | fe59151e083d024903e12dadcf96b476ff6f8aeb /main/src/cgeo/geocaching | |
parent | afb9a89209cf2e64eca726549f0da93a1da5ff80 (diff) | |
download | cgeo-082cde2c609dedaef1b970f3e2af71395ef2c543.zip cgeo-082cde2c609dedaef1b970f3e2af71395ef2c543.tar.gz cgeo-082cde2c609dedaef1b970f3e2af71395ef2c543.tar.bz2 |
Mapsource refactor little cleanup:
Rename singleton method to getInstance
Bugfix for ordinal from mapsourceId
Diffstat (limited to 'main/src/cgeo/geocaching')
-rw-r--r-- | main/src/cgeo/geocaching/maps/MapProviderFactory.java | 24 |
1 files changed, 12 insertions, 12 deletions
diff --git a/main/src/cgeo/geocaching/maps/MapProviderFactory.java b/main/src/cgeo/geocaching/maps/MapProviderFactory.java index 707eb64..95be0f3 100644 --- a/main/src/cgeo/geocaching/maps/MapProviderFactory.java +++ b/main/src/cgeo/geocaching/maps/MapProviderFactory.java @@ -33,7 +33,7 @@ public class MapProviderFactory { } } - private static MapProviderFactory getFactory() { + private static MapProviderFactory getInstance() { if (null == instance) { initInstance(); } @@ -41,15 +41,15 @@ public class MapProviderFactory { } public static SortedMap<Integer, String> getMapSources() { - return getFactory().mapSources; + return getInstance().mapSources; } public static boolean IsValidSourceId(int sourceId) { - return getFactory().mapSources.containsKey(sourceId); + return getInstance().mapSources.containsKey(sourceId); } public static boolean IsSameProvider(int sourceId1, int sourceId2) { - for (MapProvider mp : getFactory().mapProviders) { + for (MapProvider mp : getInstance().mapProviders) { if (mp.IsMySource(sourceId1) && mp.IsMySource(sourceId2)) { return true; } @@ -58,18 +58,18 @@ public class MapProviderFactory { } public static MapProvider getMapProvider(int sourceId) { - for (MapProvider mp : getFactory().mapProviders) { + for (MapProvider mp : getInstance().mapProviders) { if (mp.IsMySource(sourceId)) { return mp; } } - return getFactory().mapProviders[0]; + return getInstance().mapProviders[0]; } public static int getSourceOrdinalFromId(int sourceId) { - int sourceOrdinal = 1; - for (int key : getFactory().mapSources.keySet()) { + int sourceOrdinal = 0; + for (int key : getInstance().mapSources.keySet()) { if (sourceId == key) { return sourceOrdinal; } @@ -79,19 +79,19 @@ public class MapProviderFactory { } public static int getSourceIdFromOrdinal(int sourceOrdinal) { - int count = 1; - for (int key : getFactory().mapSources.keySet()) { + int count = 0; + for (int key : getInstance().mapSources.keySet()) { if (sourceOrdinal == count) { return key; } count++; } - return getFactory().mapSources.firstKey(); + return getInstance().mapSources.firstKey(); } public static void addMapviewMenuItems(Menu parentMenu, int groupId, int currentSource) { - SortedMap<Integer, String> mapSources = getFactory().mapSources; + SortedMap<Integer, String> mapSources = getInstance().mapSources; for (int key : mapSources.keySet()) { parentMenu.add(groupId, key, 0, mapSources.get(key)).setCheckable(true).setChecked(key == currentSource); |