aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorBananeweizen <bananeweizen@gmx.de>2013-07-03 21:23:55 +0200
committerBananeweizen <bananeweizen@gmx.de>2013-07-03 21:23:55 +0200
commit162d4e737cdcf68667b45d43722476f605eaddd7 (patch)
tree1f3a2720238f63dd35b4ef2c0bef8139e20af471
parentd67d24bdcab48dcb21518a58c116fe23cd2356ae (diff)
downloadcgeo-162d4e737cdcf68667b45d43722476f605eaddd7.zip
cgeo-162d4e737cdcf68667b45d43722476f605eaddd7.tar.gz
cgeo-162d4e737cdcf68667b45d43722476f605eaddd7.tar.bz2
fix #2957: "load more caches" wrongly enabled
-rw-r--r--main/src/cgeo/geocaching/SearchResult.java7
-rw-r--r--main/src/cgeo/geocaching/connector/gc/GCParser.java4
2 files changed, 9 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/SearchResult.java b/main/src/cgeo/geocaching/SearchResult.java
index 4cef95e..94ce28d 100644
--- a/main/src/cgeo/geocaching/SearchResult.java
+++ b/main/src/cgeo/geocaching/SearchResult.java
@@ -193,16 +193,21 @@ public class SearchResult implements Parcelable {
result.geocodes.clear();
final ArrayList<Geocache> cachesForVote = new ArrayList<Geocache>();
final Set<Geocache> caches = cgData.loadCaches(geocodes, LoadFlags.LOAD_CACHE_OR_DB);
+ int excluded = 0;
for (Geocache cache : caches) {
// Is there any reason to exclude the cache from the list?
final boolean excludeCache = (excludeDisabled && cache.isDisabled()) ||
(excludeMine && (cache.isOwner() || cache.isFound())) ||
(!cacheType.contains(cache));
- if (!excludeCache) {
+ if (excludeCache) {
+ excluded++;
+ } else {
result.addAndPutInCache(cache);
cachesForVote.add(cache);
}
}
+ // decrease maximum number of caches by filtered ones
+ result.setTotal(result.getTotal() - excluded);
GCVote.loadRatings(cachesForVote);
return result;
}
diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java
index 8464c7d..39a8891 100644
--- a/main/src/cgeo/geocaching/connector/gc/GCParser.java
+++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java
@@ -120,6 +120,7 @@ public abstract class GCParser {
final String[] rows = page.split("<tr class=");
final int rows_count = rows.length;
+ int excludedCaches = 0;
for (int z = 1; z < rows_count; z++) {
final Geocache cache = new Geocache();
final String row = rows[z];
@@ -157,6 +158,7 @@ public abstract class GCParser {
if (Settings.isExcludeDisabledCaches() && (cache.isDisabled() || cache.isArchived())) {
// skip disabled and archived caches
+ excludedCaches++;
continue;
}
@@ -252,7 +254,7 @@ public abstract class GCParser {
try {
final String result = TextUtils.getMatch(page, GCConstants.PATTERN_SEARCH_TOTALCOUNT, false, 1, null, true);
if (null != result) {
- searchResult.setTotal(Integer.parseInt(result));
+ searchResult.setTotal(Integer.parseInt(result) - excludedCaches);
}
} catch (final NumberFormatException e) {
Log.w("GCParser.parseSearch: Failed to parse cache count");