diff options
author | campbeb <bpcampbell@gmail.com> | 2012-03-24 12:39:22 +0900 |
---|---|---|
committer | campbeb <bpcampbell@gmail.com> | 2012-03-24 12:39:22 +0900 |
commit | e945fe68d5f0482f326a920bf91eccb0272ec1ec (patch) | |
tree | 884cf91afaa1476f6f583c86b95950c0592861a2 /main/src/cgeo/geocaching/cgBase.java | |
parent | 51f56540932d83cb81549b817fccbca495e54c5a (diff) | |
download | cgeo-e945fe68d5f0482f326a920bf91eccb0272ec1ec.zip cgeo-e945fe68d5f0482f326a920bf91eccb0272ec1ec.tar.gz cgeo-e945fe68d5f0482f326a920bf91eccb0272ec1ec.tar.bz2 |
Add method to refresh cache and some cleanup
Diffstat (limited to 'main/src/cgeo/geocaching/cgBase.java')
-rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 16 |
1 files changed, 12 insertions, 4 deletions
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 0d39608..928bb2c 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -384,6 +384,9 @@ public class cgBase { if (CancellableHandler.isCancelled(handler)) { return null; } + // update progress message so user knows we're still working. Otherwise it will remain on whatever was set + // in getExtraOnlineInfo (which could be logs, gcvote, or elevation) + sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_render); // save full detailed caches cgeoapplication.getInstance().saveCache(cache, EnumSet.of(SaveFlag.SAVE_DB)); } @@ -1761,20 +1764,20 @@ public class cgBase { return params; } - public static void storeCache(Activity activity, cgCache origCache, String geocode, int listId, CancellableHandler handler) { + public static void storeCache(Activity activity, cgCache origCache, String geocode, int listId, boolean forceRedownload, CancellableHandler handler) { try { cgCache cache; // get cache details, they may not yet be complete if (origCache != null) { - // only reload the cache, if it was already stored or has not all details (by checking the description) + // only reload the cache if it was already stored or doesn't have full details (by checking the description) if (origCache.getListId() >= StoredList.STANDARD_LIST_ID || StringUtils.isBlank(origCache.getDescription())) { - final SearchResult search = searchByGeocode(origCache.getGeocode(), null, listId, false, null); + final SearchResult search = searchByGeocode(origCache.getGeocode(), null, listId, false, handler); cache = search.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); } else { cache = origCache; } } else if (StringUtils.isNotBlank(geocode)) { - final SearchResult search = searchByGeocode(geocode, null, listId, false, null); + final SearchResult search = searchByGeocode(geocode, null, listId, forceRedownload, handler); cache = search.getFirstCacheFromResult(LoadFlags.LOAD_CACHE_OR_DB); } else { cache = null; @@ -1847,6 +1850,11 @@ public class cgBase { } } + public static void refreshCache(Activity activity, String geocode, int listId, CancellableHandler handler) { + cgeoapplication.getInstance().removeCache(geocode, EnumSet.of(RemoveFlag.REMOVE_CACHE)); + storeCache(activity, null, geocode, listId, true, handler); + } + public static void dropCache(final cgCache cache, final Handler handler) { try { cgeoapplication.getInstance().markDropped(cache.getGeocode()); |