aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2011-11-08 14:21:08 +0100
committerSamuel Tardieu <sam@rfc1149.net>2011-11-08 15:32:57 +0100
commit5ce29151e122a140915e2971ba7219381f4fcc43 (patch)
treea74c90d57dc9c64bc1088bfb7fc03f4ad0fd27e1 /main/src/cgeo/geocaching
parent7b7d1f4d6da3503ba13d93f6efb699fc4b285699 (diff)
downloadcgeo-5ce29151e122a140915e2971ba7219381f4fcc43.zip
cgeo-5ce29151e122a140915e2971ba7219381f4fcc43.tar.gz
cgeo-5ce29151e122a140915e2971ba7219381f4fcc43.tar.bz2
Do not use deprecated methods
Diffstat (limited to 'main/src/cgeo/geocaching')
-rw-r--r--main/src/cgeo/geocaching/Settings.java15
-rw-r--r--main/src/cgeo/geocaching/StaticMapsProvider.java8
-rw-r--r--main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java2
-rw-r--r--main/src/cgeo/geocaching/cgBase.java21
-rw-r--r--main/src/cgeo/geocaching/cgCacheListAdapter.java10
-rw-r--r--main/src/cgeo/geocaching/cgCoord.java2
-rw-r--r--main/src/cgeo/geocaching/cgData.java12
-rw-r--r--main/src/cgeo/geocaching/cgeo.java22
-rw-r--r--main/src/cgeo/geocaching/cgeoapplication.java6
-rw-r--r--main/src/cgeo/geocaching/cgeodetail.java8
-rw-r--r--main/src/cgeo/geocaching/cgeopopup.java12
-rw-r--r--main/src/cgeo/geocaching/filter/cgFilterByType.java2
-rw-r--r--main/src/cgeo/geocaching/maps/CGeoMap.java7
-rw-r--r--main/src/cgeo/geocaching/maps/CachesOverlay.java8
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java9
-rw-r--r--main/src/cgeo/geocaching/maps/google/GoogleMapFactory.java3
-rw-r--r--main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java3
-rw-r--r--main/src/cgeo/geocaching/maps/interfaces/MapFactory.java3
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java9
-rw-r--r--main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapFactory.java3
20 files changed, 87 insertions, 78 deletions
diff --git a/main/src/cgeo/geocaching/Settings.java b/main/src/cgeo/geocaching/Settings.java
index 4da2314..3d96baf 100644
--- a/main/src/cgeo/geocaching/Settings.java
+++ b/main/src/cgeo/geocaching/Settings.java
@@ -1,5 +1,6 @@
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;
@@ -275,14 +276,18 @@ public final class Settings {
return sharedPrefs.getString(KEY_COOKIE_STORE, null);
}
- public static String setCacheType(final String cacheTypeIn) {
+ public static CacheType setCacheType(final CacheType cacheType) {
editSharedSettings(new PrefRunnable() {
@Override
public void edit(Editor edit) {
- edit.putString(KEY_CACHE_TYPE, cacheTypeIn);
+ if (cacheType == null) {
+ edit.remove(KEY_CACHE_TYPE);
+ } else {
+ edit.putString(KEY_CACHE_TYPE, cacheType.id);
+ }
}
});
- return cacheTypeIn;
+ return cacheType;
}
public static void setLiveMap(final boolean live) {
@@ -806,8 +811,8 @@ public final class Settings {
return sharedPrefs.getString(KEY_WEBDEVICE_NAME, null);
}
- public static String getCacheType() {
- return sharedPrefs.getString(KEY_CACHE_TYPE, null);
+ public static CacheType getCacheType() {
+ return CacheType.getById(sharedPrefs.getString(KEY_CACHE_TYPE, null));
}
public static int getWayPointsThreshold() {
diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java
index 5a968c2..2a5725e 100644
--- a/main/src/cgeo/geocaching/StaticMapsProvider.java
+++ b/main/src/cgeo/geocaching/StaticMapsProvider.java
@@ -105,13 +105,11 @@ public class StaticMapsProvider {
}
private static String getMarkerUrl(final cgCache cache) {
- String type;
+ String type = cache.getCacheType().id;
if (cache.isFound()) {
- type = cache.getType() + "_found";
+ type += "_found";
} else if (cache.isDisabled()) {
- type = cache.getType() + "_disabled";
- } else {
- type = cache.getType();
+ type += "_disabled";
}
return cgBase.urlencode_rfc3986(MARKERS_URL + "marker_cache_" + type + ".png");
diff --git a/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java b/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java
index 8a4b02e..63d95f4 100644
--- a/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java
+++ b/main/src/cgeo/geocaching/apps/cache/WhereYouGoApp.java
@@ -13,6 +13,6 @@ class WhereYouGoApp extends AbstractGeneralApp implements GeneralApp {
@Override
public boolean isEnabled(cgCache cache) {
- return cache != null && cache.getType() != null && cache.getType().equalsIgnoreCase(CacheType.WHERIGO.id);
+ return cache != null && cache.getCacheType() == CacheType.WHERIGO;
}
}
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java
index 46d0d93..1cdc30e 100644
--- a/main/src/cgeo/geocaching/cgBase.java
+++ b/main/src/cgeo/geocaching/cgBase.java
@@ -99,7 +99,7 @@ public class cgBase {
cacheIDs.put(ct.id, ct.guid);
}
}
- public final static Map<String, String> cacheTypesInv = new HashMap<String, String>();
+ public final static Map<CacheType, String> cacheTypesInv = new HashMap<CacheType, String>();
public final static Map<String, String> cacheIDsChoices = new HashMap<String, String>();
public final static Map<CacheSize, String> cacheSizesInv = new HashMap<CacheSize, String>();
public final static Map<WaypointType, String> waypointTypes = new HashMap<WaypointType, String>();
@@ -255,7 +255,7 @@ public class cgBase {
for (CacheType ct : CacheType.values()) {
String l10n = res.getString(ct.stringId);
- cacheTypesInv.put(ct.id, l10n);
+ cacheTypesInv.put(ct, l10n);
cacheIDsChoices.put(l10n, ct.guid);
}
@@ -1141,7 +1141,7 @@ public class cgBase {
cache.setFound(BaseUtils.matches(page, GCConstants.PATTERN_FOUND) || BaseUtils.matches(page, GCConstants.PATTERN_FOUND_ALTERNATIVE));
// cache type
- cache.setCacheType(CacheType.getByPattern(BaseUtils.getMatch(page, GCConstants.PATTERN_TYPE, true, cache.getType())));
+ cache.setCacheType(CacheType.getByPattern(BaseUtils.getMatch(page, GCConstants.PATTERN_TYPE, true, cache.getCacheType().id)));
// on watchlist
cache.setOnWatchlist(BaseUtils.matches(page, GCConstants.PATTERN_WATCHLIST));
@@ -1601,7 +1601,7 @@ public class cgBase {
if (cache.getSize() == null) {
Log.e(Settings.tag, "size not parsed correctly");
}
- if (StringUtils.isBlank(cache.getType())) {
+ if (cache.getCacheType() == null || cache.getCacheType() == CacheType.UNKNOWN) {
Log.e(Settings.tag, "type not parsed correctly");
}
if (cache.getCoords() == null) {
@@ -2094,7 +2094,7 @@ public class cgBase {
return search;
}
- public cgSearch searchByHistory(final String cacheType) {
+ public cgSearch searchByHistory(final CacheType cacheType) {
if (app == null) {
Log.e(Settings.tag, "cgeoBase.searchByHistory: No application found");
return null;
@@ -2295,7 +2295,7 @@ public class cgBase {
return users;
}
- public static List<cgCache> filterSearchResults(final cgSearch search, final cgCacheWrap caches, final boolean excludeDisabled, final boolean excludeMine, final String cacheType) {
+ public static List<cgCache> filterSearchResults(final cgSearch search, final cgCacheWrap caches, final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType) {
List<cgCache> cacheList = new ArrayList<cgCache>();
if (caches != null) {
if (caches.error != null) {
@@ -2312,7 +2312,7 @@ public class cgBase {
// Is there any reason to exclude the cache from the list?
final boolean excludeCache = (excludeDisabled && cache.isDisabled()) ||
(excludeMine && (cache.isOwn() || cache.isFound())) ||
- (cacheType != null && !cacheType.equals(cache.getType()));
+ (cacheType != null && cacheType != cache.getCacheType());
if (!excludeCache) {
search.addGeocode(cache.getGeocode());
cacheList.add(cache);
@@ -3194,7 +3194,8 @@ public class cgBase {
return out;
}
- public static int getCacheIcon(final String type) {
+ public static int getCacheIcon(final CacheType cacheType) {
+ final String type = cacheType.id;
fillIconsMap();
Integer iconId = gcIcons.get("type_" + type);
if (iconId != null) {
@@ -3204,12 +3205,14 @@ public class cgBase {
return gcIcons.get("type_traditional");
}
- public static int getCacheMarkerIcon(final String type, final boolean own, final boolean found, final boolean disabled) {
+ public static int getCacheMarkerIcon(final CacheType cacheType, final boolean own, final boolean found, final boolean disabled) {
fillIconsMap();
int icon = -1;
String iconTxt = null;
+ final String type = cacheType != null ? cacheType.id : null;
+
if (StringUtils.isNotBlank(type)) {
if (own) {
iconTxt = type + "-own";
diff --git a/main/src/cgeo/geocaching/cgCacheListAdapter.java b/main/src/cgeo/geocaching/cgCacheListAdapter.java
index 6acdca2..b28c202 100644
--- a/main/src/cgeo/geocaching/cgCacheListAdapter.java
+++ b/main/src/cgeo/geocaching/cgCacheListAdapter.java
@@ -61,7 +61,7 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
private boolean sort = true;
private int checked = 0;
private boolean selectMode = false;
- final private static Map<String, Drawable> gcIconDrawables = new HashMap<String, Drawable>();
+ final private static Map<CacheType, Drawable> gcIconDrawables = new HashMap<CacheType, Drawable>();
final private Set<cgCompassMini> compasses = new LinkedHashSet<cgCompassMini>();
final private Set<cgDistanceView> distances = new LinkedHashSet<cgDistanceView>();
final private int[] ratingBcgs = new int[3];
@@ -84,7 +84,7 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
activity.getWindowManager().getDefaultDisplay().getMetrics(metrics);
pixelDensity = metrics.density;
- for (final String cacheType : cgBase.cacheTypesInv.keySet()) {
+ for (final CacheType cacheType : cgBase.cacheTypesInv.keySet()) {
gcIconDrawables.put(cacheType, activity.getResources().getDrawable(cgBase.getCacheIcon(cacheType)));
}
@@ -434,10 +434,10 @@ public class cgCacheListAdapter extends ArrayAdapter<cgCache> {
}
holder.text.setText(cache.getNameSp(), TextView.BufferType.SPANNABLE);
- if (gcIconDrawables.containsKey(cache.getType())) { // cache icon
- holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIconDrawables.get(cache.getType()), null, null, null);
+ if (gcIconDrawables.containsKey(cache.getCacheType())) { // cache icon
+ holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIconDrawables.get(cache.getCacheType()), null, null, null);
} else { // unknown cache type, "mystery" icon
- holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIconDrawables.get(CacheType.MYSTERY.id), null, null, null);
+ holder.text.setCompoundDrawablesWithIntrinsicBounds(gcIconDrawables.get(CacheType.MYSTERY), null, null, null);
}
if (holder.inventory.getChildCount() > 0) {
diff --git a/main/src/cgeo/geocaching/cgCoord.java b/main/src/cgeo/geocaching/cgCoord.java
index 5227883..c7b6cfe 100644
--- a/main/src/cgeo/geocaching/cgCoord.java
+++ b/main/src/cgeo/geocaching/cgCoord.java
@@ -33,7 +33,7 @@ public class cgCoord implements IBasicCache, IWaypoint {
coords = cache.getCoords();
name = cache.getName();
type = "cache";
- typeSpec = cache.getType();
+ typeSpec = cache.getCacheType().id;
difficulty = cache.getDifficulty();
terrain = cache.getTerrain();
size = cache.getSize();
diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java
index d77b3c0..761fb0c 100644
--- a/main/src/cgeo/geocaching/cgData.java
+++ b/main/src/cgeo/geocaching/cgData.java
@@ -2648,7 +2648,7 @@ public class cgData {
return geocodes;
}
- public List<String> loadBatchOfHistoricGeocodes(boolean detailedOnly, String cachetype) {
+ public List<String> loadBatchOfHistoricGeocodes(final boolean detailedOnly, final CacheType cachetype) {
init();
List<String> geocodes = new ArrayList<String>();
@@ -2661,7 +2661,7 @@ public class cgData {
}
if (cachetype != null) {
specifySql.append(" and type = \"");
- specifySql.append(cachetype);
+ specifySql.append(cachetype.id);
specifySql.append('"');
}
@@ -2698,15 +2698,15 @@ public class cgData {
return geocodes;
}
- public List<String> getCachedInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public List<String> getCachedInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cachetype) {
return getInViewport(false, centerLat, centerLon, spanLat, spanLon, cachetype);
}
- public List<String> getStoredInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public List<String> getStoredInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cachetype) {
return getInViewport(true, centerLat, centerLon, spanLat, spanLon, cachetype);
}
- public List<String> getInViewport(boolean stored, Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public List<String> getInViewport(final boolean stored, final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cachetype) {
if (centerLat == null || centerLon == null || spanLat == null || spanLon == null) {
return null;
}
@@ -2746,7 +2746,7 @@ public class cgData {
// cachetype limitation
if (cachetype != null) {
where.append(" and type = \"");
- where.append(cachetype);
+ where.append(cachetype.id);
where.append('"');
}
diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java
index 3cbb46c..afa789a 100644
--- a/main/src/cgeo/geocaching/cgeo.java
+++ b/main/src/cgeo/geocaching/cgeo.java
@@ -349,10 +349,10 @@ public class cgeo extends AbstractActivity {
menu.add(1, 3, 0, res.getString(R.string.mystery));
// then add all other cache types sorted alphabetically
- Map<String, String> allTypes = new HashMap<String, String>(cgBase.cacheTypesInv);
- allTypes.remove(CacheType.TRADITIONAL.id);
- allTypes.remove(CacheType.MULTI.id);
- allTypes.remove(CacheType.MYSTERY.id);
+ Map<CacheType, String> allTypes = new HashMap<CacheType, String>(cgBase.cacheTypesInv);
+ allTypes.remove(CacheType.TRADITIONAL);
+ allTypes.remove(CacheType.MULTI);
+ allTypes.remove(CacheType.MYSTERY);
List<String> sorted = new ArrayList<String>(allTypes.values());
Collections.sort(sorted);
for (String choice : sorted) {
@@ -364,7 +364,7 @@ public class cgeo extends AbstractActivity {
boolean foundItem = false;
int itemCount = menu.size();
if (Settings.getCacheType() != null) {
- String typeTitle = cgBase.cacheTypesInv.get(Settings.getCacheType());
+ final String typeTitle = cgBase.cacheTypesInv.get(Settings.getCacheType());
if (typeTitle != null) {
for (int i = 0; i < itemCount; i++) {
if (menu.getItem(i).getTitle().equals(typeTitle)) {
@@ -395,19 +395,15 @@ public class cgeo extends AbstractActivity {
cgeocaches.startActivityOffline(context);
return true;
} else if (id > 0) {
- String itemTitle = item.getTitle().toString();
- String choice = null;
- for (Entry<String, String> entry : cgBase.cacheTypesInv.entrySet()) {
+ final String itemTitle = item.getTitle().toString();
+ CacheType choice = null;
+ for (Entry<CacheType, String> entry : cgBase.cacheTypesInv.entrySet()) {
if (entry.getValue().equalsIgnoreCase(itemTitle)) {
choice = entry.getKey();
break;
}
}
- if (choice == null) {
- Settings.setCacheType(null);
- } else {
- Settings.setCacheType(choice);
- }
+ Settings.setCacheType(choice);
setFilterTitle();
return true;
diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java
index 6b9aca4..b039060 100644
--- a/main/src/cgeo/geocaching/cgeoapplication.java
+++ b/main/src/cgeo/geocaching/cgeoapplication.java
@@ -452,17 +452,17 @@ public class cgeoapplication extends Application {
return getStorage().loadHistoryOfSearchedLocations();
}
- public cgSearch getHistoryOfCaches(boolean detailedOnly, String cachetype) {
+ public cgSearch getHistoryOfCaches(final boolean detailedOnly, final CacheType cachetype) {
final List<String> geocodes = getStorage().loadBatchOfHistoricGeocodes(detailedOnly, cachetype);
return new cgSearch(geocodes);
}
- public cgSearch getCachedInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public cgSearch getCachedInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cachetype) {
final List<String> geocodes = getStorage().getCachedInViewport(centerLat, centerLon, spanLat, spanLon, cachetype);
return new cgSearch(geocodes);
}
- public cgSearch getStoredInViewport(Long centerLat, Long centerLon, Long spanLat, Long spanLon, String cachetype) {
+ public cgSearch getStoredInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cachetype) {
final List<String> geocodes = getStorage().getStoredInViewport(centerLat, centerLon, spanLat, spanLon, cachetype);
return new cgSearch(geocodes);
}
diff --git a/main/src/cgeo/geocaching/cgeodetail.java b/main/src/cgeo/geocaching/cgeodetail.java
index b52660a..de7c735 100644
--- a/main/src/cgeo/geocaching/cgeodetail.java
+++ b/main/src/cgeo/geocaching/cgeodetail.java
@@ -727,7 +727,7 @@ public class cgeodetail extends AbstractActivity {
detailsList.removeAllViews();
// actionbar icon, default mystery
- ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(cgBase.getCacheIcon(cache.getType())), null, null, null);
+ ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(cgBase.getCacheIcon(cache.getCacheType())), null, null, null);
// cache name (full name)
itemLayout = (RelativeLayout) inflater.inflate(R.layout.cache_item, null);
@@ -749,10 +749,10 @@ public class cgeodetail extends AbstractActivity {
itemName.setText(res.getString(R.string.cache_type));
- if (cgBase.cacheTypesInv.containsKey(cache.getType())) { // cache icon
- itemValue.setText(cgBase.cacheTypesInv.get(cache.getType()));
+ if (cgBase.cacheTypesInv.containsKey(cache.getCacheType())) { // cache icon
+ itemValue.setText(cgBase.cacheTypesInv.get(cache.getCacheType()));
} else {
- itemValue.setText(cgBase.cacheTypesInv.get(CacheType.MYSTERY.id)); // TODO: or UNKNOWN?
+ itemValue.setText(cgBase.cacheTypesInv.get(CacheType.MYSTERY)); // TODO: or UNKNOWN?
}
detailsList.addView(itemLayout);
diff --git a/main/src/cgeo/geocaching/cgeopopup.java b/main/src/cgeo/geocaching/cgeopopup.java
index 58477d0..1574775 100644
--- a/main/src/cgeo/geocaching/cgeopopup.java
+++ b/main/src/cgeo/geocaching/cgeopopup.java
@@ -230,7 +230,7 @@ public class cgeopopup extends AbstractActivity {
detailsList.removeAllViews();
// actionbar icon
- ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(cgBase.getCacheIcon(cache.getType())), null, null, null);
+ ((TextView) findViewById(R.id.actionbar_title)).setCompoundDrawablesWithIntrinsicBounds(getResources().getDrawable(cgBase.getCacheIcon(cache.getCacheType())), null, null, null);
// cache type
itemLayout = (RelativeLayout) inflater.inflate(R.layout.cache_item, null);
@@ -238,19 +238,19 @@ public class cgeopopup extends AbstractActivity {
itemValue = (TextView) itemLayout.findViewById(R.id.value);
itemName.setText(res.getString(R.string.cache_type));
- if (cgBase.cacheTypesInv.containsKey(cache.getType())) { // cache icon
+ if (cgBase.cacheTypesInv.containsKey(cache.getCacheType())) { // cache icon
if (cache.getSize() != null) {
- itemValue.setText(cgBase.cacheTypesInv.get(cache.getType())
+ itemValue.setText(cgBase.cacheTypesInv.get(cache.getCacheType())
+ " (" + res.getString(cache.getSize().stringId) + ")");
} else {
- itemValue.setText(cgBase.cacheTypesInv.get(cache.getType()));
+ itemValue.setText(cgBase.cacheTypesInv.get(cache.getCacheType()));
}
} else {
if (cache.getSize() != null) {
- itemValue.setText(cgBase.cacheTypesInv.get(CacheType.MYSTERY.id)
+ itemValue.setText(cgBase.cacheTypesInv.get(CacheType.MYSTERY)
+ " (" + res.getString(cache.getSize().stringId) + ")");
} else {
- itemValue.setText(cgBase.cacheTypesInv.get(CacheType.MYSTERY.id));
+ itemValue.setText(cgBase.cacheTypesInv.get(CacheType.MYSTERY));
}
}
detailsList.addView(itemLayout);
diff --git a/main/src/cgeo/geocaching/filter/cgFilterByType.java b/main/src/cgeo/geocaching/filter/cgFilterByType.java
index 6683988..2a021d0 100644
--- a/main/src/cgeo/geocaching/filter/cgFilterByType.java
+++ b/main/src/cgeo/geocaching/filter/cgFilterByType.java
@@ -14,7 +14,7 @@ public class cgFilterByType extends cgFilter {
@Override
boolean applyFilter(final cgCache cache) {
- return cacheType.id.equals(cache.getType());
+ return cacheType == cache.getCacheType();
}
@Override
diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java
index f3d26f1..4945e69 100644
--- a/main/src/cgeo/geocaching/maps/CGeoMap.java
+++ b/main/src/cgeo/geocaching/maps/CGeoMap.java
@@ -17,6 +17,7 @@ import cgeo.geocaching.cgeoapplication;
import cgeo.geocaching.cgeocaches;
import cgeo.geocaching.activity.ActivityMixin;
import cgeo.geocaching.apps.cache.navi.NavigationAppFactory;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.WaypointType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl;
@@ -1395,7 +1396,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
items.add(getWaypointItem(new cgCoord(oneWaypoint), oneWaypoint.getWaypointType()));
}
}
- items.add(getCacheItem(new cgCoord(cacheOne), cacheOne.getType(), cacheOne.isOwn(), cacheOne.isFound(), cacheOne.isDisabled()));
+ items.add(getCacheItem(new cgCoord(cacheOne), cacheOne.getCacheType(), cacheOne.isOwn(), cacheOne.isFound(), cacheOne.isDisabled()));
}
overlayCaches.updateItems(items);
@@ -1438,7 +1439,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
* true for disabled
* @return
*/
- private CachesOverlayItemImpl getCacheItem(cgCoord cgCoord, String type, boolean own, boolean found, boolean disabled) {
+ private CachesOverlayItemImpl getCacheItem(final cgCoord cgCoord, final CacheType type, final boolean own, final boolean found, final boolean disabled) {
return getItem(cgCoord, cgBase.getCacheMarkerIcon(type, own, found, disabled), type);
}
@@ -1466,7 +1467,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory
* cacheType, this will influence the style of the circles drawn around it
* @return
*/
- private CachesOverlayItemImpl getItem(cgCoord cgCoord, int icon, final String cacheType) {
+ private CachesOverlayItemImpl getItem(cgCoord cgCoord, int icon, final CacheType cacheType) {
coordinates.add(cgCoord);
CachesOverlayItemImpl item = Settings.getMapFactory().getCachesOverlayItem(cgCoord, cacheType);
diff --git a/main/src/cgeo/geocaching/maps/CachesOverlay.java b/main/src/cgeo/geocaching/maps/CachesOverlay.java
index 19f2bdc..ba091db 100644
--- a/main/src/cgeo/geocaching/maps/CachesOverlay.java
+++ b/main/src/cgeo/geocaching/maps/CachesOverlay.java
@@ -157,8 +157,8 @@ public class CachesOverlay extends AbstractItemizedOverlay {
projection.toPixels(leftGeo, left);
int radius = center.x - left.x;
- final String type = item.getType();
- if (type == null || CacheType.MULTI.id.equals(type) || CacheType.MYSTERY.id.equals(type) || CacheType.VIRTUAL.id.equals(type)) {
+ final CacheType type = item.getType();
+ if (type == null || type == CacheType.MULTI || type == CacheType.MYSTERY || type == CacheType.VIRTUAL) {
blockedCircle.setColor(0x66000000);
blockedCircle.setStyle(Style.STROKE);
canvas.drawCircle(center.x, center.y, radius, blockedCircle);
@@ -280,9 +280,9 @@ public class CachesOverlay extends AbstractItemizedOverlay {
String cacheType;
if (cgBase.cacheTypesInv.containsKey(coordinate.getTypeSpec())) {
- cacheType = cgBase.cacheTypesInv.get(coordinate.getTypeSpec());
+ cacheType = cgBase.cacheTypesInv.get(CacheType.getById(coordinate.getTypeSpec()));
} else {
- cacheType = cgBase.cacheTypesInv.get(CacheType.MYSTERY.id);
+ cacheType = cgBase.cacheTypesInv.get(CacheType.MYSTERY);
}
dialog.setMessage(Html.fromHtml(item.getTitle()) + "\n\ngeocode: " + coordinate.getGeocode().toUpperCase() + "\ntype: " + cacheType);
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java
index 2e6531f..5f41c54 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleCacheOverlayItem.java
@@ -1,16 +1,17 @@
package cgeo.geocaching.maps.google;
import cgeo.geocaching.cgCoord;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl;
import com.google.android.maps.GeoPoint;
import com.google.android.maps.OverlayItem;
public class GoogleCacheOverlayItem extends OverlayItem implements CachesOverlayItemImpl {
- private String cacheType = null;
- private cgCoord coord;
+ final private CacheType cacheType;
+ final private cgCoord coord;
- public GoogleCacheOverlayItem(cgCoord coordinate, String type) {
+ public GoogleCacheOverlayItem(final cgCoord coordinate, final CacheType type) {
super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), "");
this.cacheType = type;
@@ -21,7 +22,7 @@ public class GoogleCacheOverlayItem extends OverlayItem implements CachesOverlay
return coord;
}
- public String getType() {
+ public CacheType getType() {
return cacheType;
}
diff --git a/main/src/cgeo/geocaching/maps/google/GoogleMapFactory.java b/main/src/cgeo/geocaching/maps/google/GoogleMapFactory.java
index f933ae1..55f6837 100644
--- a/main/src/cgeo/geocaching/maps/google/GoogleMapFactory.java
+++ b/main/src/cgeo/geocaching/maps/google/GoogleMapFactory.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.maps.google;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCoord;
import cgeo.geocaching.cgUser;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
@@ -36,7 +37,7 @@ public class GoogleMapFactory implements MapFactory {
}
@Override
- public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final String type) {
+ public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final CacheType type) {
GoogleCacheOverlayItem baseItem = new GoogleCacheOverlayItem(coordinate, type);
return baseItem;
}
diff --git a/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java b/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java
index 59e79a0..e2bf552 100644
--- a/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java
+++ b/main/src/cgeo/geocaching/maps/interfaces/CachesOverlayItemImpl.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.maps.interfaces;
import cgeo.geocaching.cgCoord;
+import cgeo.geocaching.enumerations.CacheType;
/**
* Covers the common functions of the provider-specific
@@ -13,6 +14,6 @@ public interface CachesOverlayItemImpl extends OverlayItemImpl {
public cgCoord getCoord();
- public String getType();
+ public CacheType getType();
}
diff --git a/main/src/cgeo/geocaching/maps/interfaces/MapFactory.java b/main/src/cgeo/geocaching/maps/interfaces/MapFactory.java
index f5e1e94..814703c 100644
--- a/main/src/cgeo/geocaching/maps/interfaces/MapFactory.java
+++ b/main/src/cgeo/geocaching/maps/interfaces/MapFactory.java
@@ -2,6 +2,7 @@ package cgeo.geocaching.maps.interfaces;
import cgeo.geocaching.cgCoord;
import cgeo.geocaching.cgUser;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.geopoint.Geopoint;
import android.app.Activity;
@@ -24,7 +25,7 @@ public interface MapFactory {
public GeoPointImpl getGeoPointBase(final Geopoint coords);
- public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final String type);
+ public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final CacheType type);
public OtherCachersOverlayItemImpl getOtherCachersOverlayItemBase(Context context,
cgUser userOne);
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java
index c3d9d25..ccc0e78 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeCacheOverlayItem.java
@@ -1,6 +1,7 @@
package cgeo.geocaching.maps.mapsforge;
import cgeo.geocaching.cgCoord;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl;
import org.mapsforge.android.maps.GeoPoint;
@@ -9,10 +10,10 @@ import org.mapsforge.android.maps.OverlayItem;
import android.graphics.drawable.Drawable;
public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOverlayItemImpl {
- private String cacheType = null;
- private cgCoord coord;
+ final private CacheType cacheType;
+ final private cgCoord coord;
- public MapsforgeCacheOverlayItem(cgCoord coordinate, String type) {
+ public MapsforgeCacheOverlayItem(cgCoord coordinate, final CacheType type) {
super(new GeoPoint(coordinate.getCoords().getLatitudeE6(), coordinate.getCoords().getLongitudeE6()), coordinate.getName(), "");
this.cacheType = type;
@@ -23,7 +24,7 @@ public class MapsforgeCacheOverlayItem extends OverlayItem implements CachesOver
return coord;
}
- public String getType() {
+ public CacheType getType() {
return cacheType;
}
diff --git a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapFactory.java b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapFactory.java
index 2176ae0..dabd91b 100644
--- a/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapFactory.java
+++ b/main/src/cgeo/geocaching/maps/mapsforge/MapsforgeMapFactory.java
@@ -3,6 +3,7 @@ package cgeo.geocaching.maps.mapsforge;
import cgeo.geocaching.R;
import cgeo.geocaching.cgCoord;
import cgeo.geocaching.cgUser;
+import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.geopoint.Geopoint;
import cgeo.geocaching.maps.interfaces.CachesOverlayItemImpl;
import cgeo.geocaching.maps.interfaces.GeoPointImpl;
@@ -35,7 +36,7 @@ public class MapsforgeMapFactory implements MapFactory {
}
@Override
- public CachesOverlayItemImpl getCachesOverlayItem(cgCoord coordinate, String type) {
+ public CachesOverlayItemImpl getCachesOverlayItem(final cgCoord coordinate, final CacheType type) {
MapsforgeCacheOverlayItem baseItem = new MapsforgeCacheOverlayItem(coordinate, type);
return baseItem;
}