From 15c43ea435b878ef96d7ba6857aad851a373d6e7 Mon Sep 17 00:00:00 2001 From: Samuel Tardieu Date: Sat, 22 Oct 2011 11:46:58 +0200 Subject: Split cache loading in offline + online modes Also, add a new "loading elevation data" step in progress dialog. This closes #701. --- main/src/cgeo/geocaching/cgBase.java | 35 ++++++++++++++++++++++------------- 1 file changed, 22 insertions(+), 13 deletions(-) (limited to 'main/src') diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 5775e7b..61eaaba 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -997,6 +997,18 @@ public class cgBase { } public static cgCacheWrap parseCache(final String page, final int reason, final Handler handler) { + final cgCacheWrap caches = parseCacheFromText(page, reason, handler); + if (!caches.cacheList.isEmpty()) { + final cgCache cache = caches.cacheList.get(0); + getExtraOnlineInfo(cache, page, handler); + cache.updated = System.currentTimeMillis(); + cache.detailedUpdate = cache.updated; + cache.detailed = true; + } + return caches; + } + + static cgCacheWrap parseCacheFromText(final String page, final int reason, final Handler handler) { sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_details); if (StringUtils.isBlank(page)) { @@ -1278,11 +1290,6 @@ public class cgBase { Log.w(Settings.tag, "cgeoBase.parseCache: Failed to parse cache log count"); } - // cache logs - sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_logs); - - loadLogsFromDetails(page, cache); - int wpBegin = 0; int wpEnd = 0; @@ -1411,25 +1418,27 @@ public class cgBase { } } + caches.cacheList.add(cache); + + return caches; + } + + private static void getExtraOnlineInfo(final cgCache cache, final String page, final Handler handler) { + sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_logs); + loadLogsFromDetails(page, cache); + + sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_elevation); if (cache.coords != null) { cache.elevation = getElevation(cache.coords); } sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_gcvote); - final cgRating rating = GCVote.getRating(cache.guid, cache.geocode); if (rating != null) { cache.rating = rating.rating; cache.votes = rating.votes; cache.myVote = rating.myVote; } - - cache.updated = System.currentTimeMillis(); - cache.detailedUpdate = System.currentTimeMillis(); - cache.detailed = true; - caches.cacheList.add(cache); - - return caches; } /** -- cgit v1.1