diff options
Diffstat (limited to 'main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java')
| -rw-r--r-- | main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java | 20 |
1 files changed, 20 insertions, 0 deletions
diff --git a/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java b/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java index 2dee713..a23d135 100644 --- a/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java +++ b/main/src/cgeo/geocaching/sorting/AbstractCacheComparator.java @@ -1,6 +1,8 @@ package cgeo.geocaching.sorting; +import cgeo.geocaching.DataStore; import cgeo.geocaching.Geocache; +import cgeo.geocaching.enumerations.LogType; import cgeo.geocaching.utils.Log; @@ -45,4 +47,22 @@ public abstract class AbstractCacheComparator implements CacheComparator { * cache2. */ protected abstract int compareCaches(final Geocache cache1, final Geocache cache2); + + /** + * Get number of overall finds for a cache. + * + * @param cache + * @return + */ + protected static int getFindsCount(Geocache cache) { + if (cache.getLogCounts().isEmpty()) { + cache.setLogCounts(DataStore.loadLogCounts(cache.getGeocode())); + } + Integer logged = cache.getLogCounts().get(LogType.FOUND_IT); + if (logged != null) { + return logged; + } + return 0; + } + } |
