diff options
author | rsudev <rasch@munin-soft.de> | 2013-07-06 18:41:43 +0200 |
---|---|---|
committer | rsudev <rasch@munin-soft.de> | 2013-07-06 18:41:43 +0200 |
commit | d500f3f0637b60da4f50c32a64de3eaa0ffd3f79 (patch) | |
tree | 4e7780eab6a3c3e6001b050ebfc676813595f950 /main/src/cgeo | |
parent | e3034d9ecc3b5ed4f849b167bc687d6d086e0d82 (diff) | |
download | cgeo-d500f3f0637b60da4f50c32a64de3eaa0ffd3f79.zip cgeo-d500f3f0637b60da4f50c32a64de3eaa0ffd3f79.tar.gz cgeo-d500f3f0637b60da4f50c32a64de3eaa0ffd3f79.tar.bz2 |
Fixes #2925, Cache logbook not updated correctly
CacheLogbookViewCreater was running on a stale Geocache instance
Diffstat (limited to 'main/src/cgeo')
-rw-r--r-- | main/src/cgeo/geocaching/CacheDetailActivity.java | 8 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java | 27 |
2 files changed, 25 insertions, 10 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 9c03401..5ac348c 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -2409,10 +2409,10 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc return new DescriptionViewCreator(); case LOGS: - return new CacheLogsViewCreator(this, cache, true); + return new CacheLogsViewCreator(this, true); case LOGSFRIENDS: - return new CacheLogsViewCreator(this, cache, false); + return new CacheLogsViewCreator(this, false); case WAYPOINTS: return new WaypointsViewCreator(); @@ -2471,4 +2471,8 @@ public class CacheDetailActivity extends AbstractViewPagerActivity<CacheDetailAc offlineRefresh.setClickable(true); } + public Geocache getCache() { + return cache; + } + } diff --git a/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java b/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java index a785681..8da711e 100644 --- a/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java +++ b/main/src/cgeo/geocaching/ui/logs/CacheLogsViewCreator.java @@ -23,24 +23,35 @@ import java.util.Map.Entry; public class CacheLogsViewCreator extends LogsViewCreator { private final boolean allLogs; - private final Geocache cache; private final Resources res = cgeoapplication.getInstance().getResources(); - public CacheLogsViewCreator(CacheDetailActivity cacheDetailActivity, final Geocache cache, boolean allLogs) { + public CacheLogsViewCreator(CacheDetailActivity cacheDetailActivity, boolean allLogs) { super(cacheDetailActivity); - this.cache = cache; this.allLogs = allLogs; } + /** + * May return null! + * + * @return + */ + private Geocache getCache() { + if (this.activity instanceof CacheDetailActivity) { + CacheDetailActivity details = (CacheDetailActivity) this.activity; + return details.getCache(); + } + return null; + } + @Override protected List<LogEntry> getLogs() { - return allLogs ? cache.getLogs() : cache.getFriendsLogs(); + return allLogs ? getCache().getLogs() : getCache().getFriendsLogs(); } @Override protected void addHeaderView() { // adds the log counts - final Map<LogType, Integer> logCounts = cache.getLogCounts(); + final Map<LogType, Integer> logCounts = getCache().getLogCounts(); if (logCounts != null) { final List<Entry<LogType, Integer>> sortedLogCounts = new ArrayList<Entry<LogType, Integer>>(logCounts.size()); for (final Entry<LogType, Integer> entry : logCounts.entrySet()) { @@ -85,17 +96,17 @@ public class CacheLogsViewCreator extends LogsViewCreator { @Override protected boolean isValid() { - return cache != null; + return getCache() != null; } @Override protected String getGeocode() { - return cache.getGeocode(); + return getCache().getGeocode(); } @Override protected UserActionsClickListener createUserActionsListener() { - return new UserActionsClickListener(cache); + return new UserActionsClickListener(getCache()); } }
\ No newline at end of file |