aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/Geocache.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/Geocache.java')
-rw-r--r--main/src/cgeo/geocaching/Geocache.java42
1 files changed, 8 insertions, 34 deletions
diff --git a/main/src/cgeo/geocaching/Geocache.java b/main/src/cgeo/geocaching/Geocache.java
index e0daae1..61f13b9 100644
--- a/main/src/cgeo/geocaching/Geocache.java
+++ b/main/src/cgeo/geocaching/Geocache.java
@@ -12,11 +12,9 @@ import cgeo.geocaching.connector.gc.GCConnector;
import cgeo.geocaching.connector.gc.GCConstants;
import cgeo.geocaching.connector.gc.Tile;
import cgeo.geocaching.connector.gc.UncertainProperty;
-import cgeo.geocaching.enumerations.CacheAttribute;
import cgeo.geocaching.enumerations.CacheSize;
import cgeo.geocaching.enumerations.CacheType;
import cgeo.geocaching.enumerations.LoadFlags;
-import cgeo.geocaching.enumerations.LoadFlags.LoadFlag;
import cgeo.geocaching.enumerations.LoadFlags.RemoveFlag;
import cgeo.geocaching.enumerations.LoadFlags.SaveFlag;
import cgeo.geocaching.enumerations.LogType;
@@ -69,8 +67,8 @@ import java.util.Calendar;
import java.util.Collection;
import java.util.Collections;
import java.util.Date;
+import java.util.EnumMap;
import java.util.EnumSet;
-import java.util.HashMap;
import java.util.HashSet;
import java.util.LinkedHashSet;
import java.util.LinkedList;
@@ -88,7 +86,7 @@ public class Geocache implements ICache, IWaypoint {
private long updated = 0;
private long detailedUpdate = 0;
private long visitedDate = 0;
- private int listId = StoredList.TEMPORARY_LIST_ID;
+ private int listId = StoredList.TEMPORARY_LIST.id;
private boolean detailed = false;
private String geocode = "";
private String cacheId = "";
@@ -149,7 +147,7 @@ public class Geocache implements ICache, IWaypoint {
private List<Image> spoilers = null;
private List<Trackable> inventory = null;
- private Map<LogType, Integer> logCounts = new HashMap<>();
+ private Map<LogType, Integer> logCounts = new EnumMap<>(LogType.class);
private boolean userModifiedCoords = false;
// temporary values
private boolean statusChecked = false;
@@ -163,10 +161,6 @@ public class Geocache implements ICache, IWaypoint {
private Handler changeNotificationHandler = null;
- // Images whose URL contains one of those patterns will not be available on the Images tab
- // for opening into an external application.
- private final String[] NO_EXTERNAL = new String[]{"geocheck.org"};
-
/**
* Create a new cache. To be used everywhere except for the GPX parser
*/
@@ -251,7 +245,7 @@ public class Geocache implements ICache, IWaypoint {
if (visitedDate == 0) {
visitedDate = other.visitedDate;
}
- if (listId == StoredList.TEMPORARY_LIST_ID) {
+ if (listId == StoredList.TEMPORARY_LIST.id) {
listId = other.listId;
}
if (StringUtils.isBlank(geocode)) {
@@ -455,11 +449,7 @@ public class Geocache implements ICache, IWaypoint {
ActivityMixin.showToast(fromActivity, fromActivity.getResources().getString(R.string.err_cannot_log_visit));
return;
}
- final Intent logVisitIntent = new Intent(fromActivity, LogCacheActivity.class);
- logVisitIntent.putExtra(LogCacheActivity.EXTRAS_ID, cacheId);
- logVisitIntent.putExtra(LogCacheActivity.EXTRAS_GEOCODE, geocode);
-
- fromActivity.startActivity(logVisitIntent);
+ fromActivity.startActivity(LogCacheActivity.getLogCacheIntent(fromActivity, cacheId, geocode));
}
public void logOffline(final Activity fromActivity, final LogType logType) {
@@ -1432,7 +1422,7 @@ public class Geocache implements ICache, IWaypoint {
}
public void store(final CancellableHandler handler) {
- store(StoredList.TEMPORARY_LIST_ID, handler);
+ store(StoredList.TEMPORARY_LIST.id, handler);
}
public void store(final int listId, final CancellableHandler handler) {
@@ -1627,7 +1617,7 @@ public class Geocache implements ICache, IWaypoint {
return null;
}
- if (!forceReload && listId == StoredList.TEMPORARY_LIST_ID && (DataStore.isOffline(geocode, guid) || DataStore.isThere(geocode, guid, true, true))) {
+ if (!forceReload && listId == StoredList.TEMPORARY_LIST.id && (DataStore.isOffline(geocode, guid) || DataStore.isThere(geocode, guid, true, true))) {
final SearchResult search = new SearchResult();
final String realGeocode = StringUtils.isNotBlank(geocode) ? geocode : DataStore.getGeocodeForGuid(guid);
search.addGeocode(realGeocode);
@@ -1693,22 +1683,6 @@ public class Geocache implements ICache, IWaypoint {
return null;
}
- /**
- * check whether the cache has a given attribute
- *
- * @param attribute
- * @param yes
- * true if we are looking for the attribute_yes version, false for the attribute_no version
- * @return
- */
- public boolean hasAttribute(final CacheAttribute attribute, final boolean yes) {
- Geocache fullCache = DataStore.loadCache(getGeocode(), EnumSet.of(LoadFlag.ATTRIBUTES));
- if (fullCache == null) {
- fullCache = this;
- }
- return fullCache.getAttributes().contains(attribute.getAttributeName(yes));
- }
-
public boolean hasStaticMap() {
return StaticMapsProvider.hasStaticMap(this);
}
@@ -1728,7 +1702,7 @@ public class Geocache implements ICache, IWaypoint {
Html.fromHtml(getDescription(), new ImageGetter() {
@Override
public Drawable getDrawable(final String source) {
- if (!urls.contains(source) && !ImageUtils.containsPattern(source, NO_EXTERNAL)) {
+ if (!urls.contains(source) && ImageUtils.canBeOpenedExternally(source)) {
images.add(new Image(source, geocode));
urls.add(source);
}