aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-01-06 19:55:41 +0100
committerBananeweizen <bananeweizen@gmx.de>2013-01-06 19:55:41 +0100
commita1db955beb5d0675161311eb80ba7d3cd4783bd0 (patch)
tree46594005f0718dccde475938d503e3aefc384af9
parent55447b57ab4c34c28e8af900c2ec8f74918f111c (diff)
downloadcgeo-a1db955beb5d0675161311eb80ba7d3cd4783bd0.zip
cgeo-a1db955beb5d0675161311eb80ba7d3cd4783bd0.tar.gz
cgeo-a1db955beb5d0675161311eb80ba7d3cd4783bd0.tar.bz2
fix: OC connector didn't set timestamp of cache
* lead to "updated 15000 days ago"
-rw-r--r--main/src/cgeo/geocaching/cgCache.java7
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java4
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java1
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OCXMLClient.java12
-rw-r--r--main/src/cgeo/geocaching/connector/oc/OkapiClient.java4
5 files changed, 15 insertions, 13 deletions
diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java
index 19df7e3..919ad06 100644
--- a/main/src/cgeo/geocaching/cgCache.java
+++ b/main/src/cgeo/geocaching/cgCache.java
@@ -1632,4 +1632,11 @@ public class cgCache implements ICache, IWaypoint {
}
return result;
}
+
+ public void setDetailedUpdatedNow() {
+ final long now = System.currentTimeMillis();
+ setUpdated(now);
+ setDetailedUpdate(now);
+ setDetailed(true);
+ }
}
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 91b0ddd..c42008b 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -306,9 +306,7 @@ public abstract class GCParser {
if (searchResult != null && !searchResult.getGeocodes().isEmpty()) {
final cgCache cache = searchResult.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB);
getExtraOnlineInfo(cache, page, handler);
- cache.setUpdated(System.currentTimeMillis());
- cache.setDetailedUpdate(cache.getUpdated());
- cache.setDetailed(true);
+ cache.setDetailedUpdatedNow();
if (CancellableHandler.isCancelled(handler)) {
return null;
}
diff --git a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
index d0c0e16..97797c9 100644
--- a/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
+++ b/main/src/cgeo/geocaching/connector/oc/OC11XMLParser.java
@@ -216,6 +216,7 @@ public class OC11XMLParser {
&& !cache.isArchived()
&& caches.size() < CACHE_PARSE_LIMIT) {
cache.setCoords(coords);
+ cache.setDetailedUpdatedNow();
caches.put(cache.getCacheId(), cache);
}
}
diff --git a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
index 26b42e3..88ba5a1 100644
--- a/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
+++ b/main/src/cgeo/geocaching/connector/oc/OCXMLClient.java
@@ -13,12 +13,12 @@ import cgeo.geocaching.utils.Log;
import ch.boye.httpclientandroidlib.HttpResponse;
-import org.apache.commons.collections.CollectionUtils;
import org.apache.commons.lang3.StringUtils;
import java.io.IOException;
import java.io.InputStream;
import java.util.Collection;
+import java.util.Collections;
import java.util.Locale;
import java.util.zip.GZIPInputStream;
@@ -42,18 +42,16 @@ public class OCXMLClient {
Collection<cgCache> caches = OC11XMLParser.parseCaches(new GZIPInputStream(data));
if (caches.iterator().hasNext()) {
cgCache cache = caches.iterator().next();
- cache.setDetailed(true);
cgData.saveCache(cache, LoadFlags.SAVE_ALL);
return cache;
}
return null;
} catch (IOException e) {
- Log.e("Error parsing cache '" + geoCode + "': " + e.toString());
+ Log.e("Error parsing cache '" + geoCode + "'", e);
return null;
}
}
- @SuppressWarnings("unchecked")
public static Collection<cgCache> getCachesAround(final Geopoint center, final double distance) {
try {
final Parameters params = getOCXmlQueryParameters(false, false);
@@ -63,13 +61,13 @@ public class OCXMLClient {
final InputStream data = request(ConnectorFactory.getConnector("OCXXX"), SERVICE_CACHE, params);
if (data == null) {
- return CollectionUtils.EMPTY_COLLECTION;
+ return Collections.emptyList();
}
return OC11XMLParser.parseCaches(new GZIPInputStream(data));
} catch (IOException e) {
- Log.e("Error parsing nearby search result: " + e.toString());
- return CollectionUtils.EMPTY_COLLECTION;
+ Log.e("Error parsing nearby search result", e);
+ return Collections.emptyList();
}
}
diff --git a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
index 1121cc5..55a33e9 100644
--- a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
+++ b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java
@@ -167,9 +167,7 @@ final public class OkapiClient {
cache.setLogs(parseLogs(response.getJSONArray(CACHE_LATEST_LOGS)));
cache.setHidden(parseDate(response.getString(CACHE_HIDDEN)));
- cache.setUpdated(System.currentTimeMillis());
- cache.setDetailedUpdate(cache.getUpdated());
- cache.setDetailed(true);
+ cache.setDetailedUpdatedNow();
// save full detailed caches
cgData.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB));
} catch (JSONException e) {