diff options
author | blafoo <github@blafoo.de> | 2012-01-14 11:31:10 +0100 |
---|---|---|
committer | blafoo <github@blafoo.de> | 2012-01-14 11:31:10 +0100 |
commit | f2cfe1983a3a7e99efb5e230e1e7082df3573623 (patch) | |
tree | 55bcd33919da2fe14bc1b5bafbd60f0f939dd5ba /main/src/cgeo/geocaching/gcvote | |
parent | 46774378b7d391245a2e26b78209b68136e29d1c (diff) | |
download | cgeo-f2cfe1983a3a7e99efb5e230e1e7082df3573623.zip cgeo-f2cfe1983a3a7e99efb5e230e1e7082df3573623.tar.gz cgeo-f2cfe1983a3a7e99efb5e230e1e7082df3573623.tar.bz2 |
new base class cache
Diffstat (limited to 'main/src/cgeo/geocaching/gcvote')
-rw-r--r-- | main/src/cgeo/geocaching/gcvote/GCVote.java | 14 |
1 files changed, 3 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/gcvote/GCVote.java b/main/src/cgeo/geocaching/gcvote/GCVote.java index d0517f3..0d7f202 100644 --- a/main/src/cgeo/geocaching/gcvote/GCVote.java +++ b/main/src/cgeo/geocaching/gcvote/GCVote.java @@ -1,5 +1,6 @@ package cgeo.geocaching.gcvote; +import cgeo.geocaching.Cache; import cgeo.geocaching.Parameters; import cgeo.geocaching.Settings; import cgeo.geocaching.cgBase; @@ -12,7 +13,6 @@ import android.util.Log; import java.util.ArrayList; import java.util.HashMap; -import java.util.LinkedHashMap; import java.util.List; import java.util.Map; import java.util.Map.Entry; @@ -27,16 +27,8 @@ public final class GCVote { private static final Pattern patternVote = Pattern.compile("voteUser='([0-9.]+)'", Pattern.CASE_INSENSITIVE); private static final Pattern patternVoteElement = Pattern.compile("<vote ([^>]+)>", Pattern.CASE_INSENSITIVE); - private static class RatingsCache extends LinkedHashMap<String, GCVoteRating> { - private static final int MAX_CACHED_RATINGS = 1000; - - @Override - protected boolean removeEldestEntry(java.util.Map.Entry<String, GCVoteRating> eldest) { - return size() > MAX_CACHED_RATINGS; - } - } - - private static Map<String, GCVoteRating> ratingsCache = new RatingsCache(); + private static final int MAX_CACHED_RATINGS = 1000; + private static Cache<String, GCVoteRating> ratingsCache = new Cache<String, GCVoteRating>(MAX_CACHED_RATINGS); /** * Get user rating for a given guid or geocode. For a guid first the ratings cache is checked |