diff options
| author | Michael Keppler <michael.keppler@gmx.de> | 2014-04-25 14:23:03 +0200 |
|---|---|---|
| committer | Michael Keppler <michael.keppler@gmx.de> | 2014-04-25 14:23:15 +0200 |
| commit | 530440bbb9ce55f96395055abe86dcdcac3ca2a6 (patch) | |
| tree | bbcfc8fee5872a8fccece03b2b3d76ecb2025679 /main/src/cgeo/geocaching/connector | |
| parent | 31ea44fe5261808f827741296029384ca517df4f (diff) | |
| download | cgeo-530440bbb9ce55f96395055abe86dcdcac3ca2a6.zip cgeo-530440bbb9ce55f96395055abe86dcdcac3ca2a6.tar.gz cgeo-530440bbb9ce55f96395055abe86dcdcac3ca2a6.tar.bz2 | |
fix #3791: have logs separated from caches
Diffstat (limited to 'main/src/cgeo/geocaching/connector')
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCParser.java | 17 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/oc/OkapiClient.java | 2 |
2 files changed, 10 insertions, 9 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index 56d434d..0549b3f 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -36,6 +36,7 @@ import cgeo.geocaching.utils.SynchronizedDateFormat; import cgeo.geocaching.utils.TextUtils; import ch.boye.httpclientandroidlib.HttpResponse; + import org.apache.commons.collections4.CollectionUtils; import org.apache.commons.lang3.StringEscapeUtils; import org.apache.commons.lang3.StringUtils; @@ -723,9 +724,6 @@ public abstract class GCParser { cache.parseWaypointsFromNote(); - // logs - cache.setLogs(getLogsFromDetails(page, false)); - // last check for necessary cache conditions if (StringUtils.isBlank(cache.getGeocode())) { searchResult.setError(StatusCode.UNKNOWN_ERROR); @@ -734,6 +732,7 @@ public abstract class GCParser { cache.setDetailedUpdatedNow(); searchResult.addAndPutInCache(Collections.singletonList(cache)); + DataStore.saveLogsWithoutTransaction(cache.getGeocode(), getLogsFromDetails(page, false)); return searchResult; } @@ -1831,16 +1830,18 @@ public abstract class GCParser { //cache.setLogs(loadLogsFromDetails(page, cache, false)); if (Settings.isFriendLogsWanted()) { CancellableHandler.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_logs); - final List<LogEntry> allLogs = cache.getLogs(); final List<LogEntry> friendLogs = getLogsFromDetails(page, true); - if (friendLogs != null) { + if (friendLogs != null && !friendLogs.isEmpty()) { + // create new list, as the existing log list is immutable + ArrayList<LogEntry> mergedLogs = new ArrayList<LogEntry>(cache.getLogs()); for (final LogEntry log : friendLogs) { - if (allLogs.contains(log)) { - allLogs.get(allLogs.indexOf(log)).friend = true; + if (mergedLogs.contains(log)) { + mergedLogs.get(mergedLogs.indexOf(log)).friend = true; } else { - cache.getLogs().add(log); + mergedLogs.add(log); } } + DataStore.saveLogsWithoutTransaction(cache.getGeocode(), mergedLogs); } } diff --git a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java index 712bb26..3c93488 100644 --- a/main/src/cgeo/geocaching/connector/oc/OkapiClient.java +++ b/main/src/cgeo/geocaching/connector/oc/OkapiClient.java @@ -372,7 +372,6 @@ final class OkapiClient { } cache.setAttributes(parseAttributes(response.getJSONArray(CACHE_ATTRNAMES), response.optJSONArray(CACHE_ATTR_ACODES))); - cache.setLogs(parseLogs(response.getJSONArray(CACHE_LATEST_LOGS))); //TODO: Store license per cache //cache.setLicense(response.getString("attribution_note")); cache.setWaypoints(parseWaypoints(response.getJSONArray(CACHE_WPTS)), false); @@ -388,6 +387,7 @@ final class OkapiClient { cache.setDetailedUpdatedNow(); // save full detailed caches DataStore.saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB)); + DataStore.saveLogsWithoutTransaction(cache.getGeocode(), parseLogs(response.getJSONArray(CACHE_LATEST_LOGS))); } catch (final JSONException e) { Log.e("OkapiClient.parseCache", e); } |
