diff options
Diffstat (limited to 'main/src')
3 files changed, 20 insertions, 26 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; + } + } diff --git a/main/src/cgeo/geocaching/sorting/FindsComparator.java b/main/src/cgeo/geocaching/sorting/FindsComparator.java index b147fad..d2aebe3 100644 --- a/main/src/cgeo/geocaching/sorting/FindsComparator.java +++ b/main/src/cgeo/geocaching/sorting/FindsComparator.java @@ -1,8 +1,6 @@ package cgeo.geocaching.sorting; -import cgeo.geocaching.DataStore; import cgeo.geocaching.Geocache; -import cgeo.geocaching.enumerations.LogType; public class FindsComparator extends AbstractCacheComparator { @@ -18,15 +16,4 @@ public class FindsComparator extends AbstractCacheComparator { return finds2 - finds1; } - private 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; - } - } diff --git a/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java b/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java index b5edf17..2c42146 100644 --- a/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java +++ b/main/src/cgeo/geocaching/sorting/PopularityRatioComparator.java @@ -3,9 +3,7 @@ */ package cgeo.geocaching.sorting; -import cgeo.geocaching.DataStore; import cgeo.geocaching.Geocache; -import cgeo.geocaching.enumerations.LogType; /** * sorts caches by popularity ratio (favorites per find in %). @@ -41,15 +39,4 @@ public class PopularityRatioComparator extends AbstractCacheComparator { return 0; } - - private 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; - } } |
