diff options
Diffstat (limited to 'main/src/cgeo/geocaching/connector')
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCMap.java | 9 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCParser.java | 15 |
2 files changed, 13 insertions, 11 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCMap.java b/main/src/cgeo/geocaching/connector/gc/GCMap.java index aabeb56..6c94150 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCMap.java +++ b/main/src/cgeo/geocaching/connector/gc/GCMap.java @@ -69,6 +69,7 @@ public class GCMap { throw new JSONException("No data inside JSON"); } + final ArrayList<Geocache> caches = new ArrayList<Geocache>(); for (int j = 0; j < dataArray.length(); j++) { final Geocache cache = new Geocache(); @@ -93,9 +94,9 @@ public class GCMap { JSONObject ownerObj = dataObject.getJSONObject("owner"); cache.setOwnerDisplayName(ownerObj.getString("text")); - result.addAndPutInCache(cache); - + caches.add(cache); } + result.addAndPutInCache(caches); } catch (JSONException e) { result.setError(StatusCode.UNKNOWN_ERROR); } catch (ParseException e) { @@ -200,6 +201,7 @@ public class GCMap { } } + final ArrayList<Geocache> caches = new ArrayList<Geocache>(); for (Entry<String, List<UTFGridPosition>> entry : positions.entrySet()) { String id = entry.getKey(); List<UTFGridPosition> pos = entry.getValue(); @@ -231,9 +233,10 @@ public class GCMap { exclude = true; } if (!exclude) { - searchResult.addAndPutInCache(cache); + caches.add(cache); } } + searchResult.addAndPutInCache(caches); Log.d("Retrieved " + searchResult.getCount() + " caches for tile " + tile.toString()); } catch (RuntimeException e) { diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index f05bc04..62ccb14 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -121,6 +121,7 @@ public abstract class GCParser { final int rows_count = rows.length; int excludedCaches = 0; + final ArrayList<Geocache> caches = new ArrayList<Geocache>(); for (int z = 1; z < rows_count; z++) { final Geocache cache = new Geocache(); final String row = rows[z]; @@ -261,8 +262,9 @@ public abstract class GCParser { Log.w("GCParser.parseSearch: Failed to parse favorite count"); } - searchResult.addAndPutInCache(cache); + caches.add(cache); } + searchResult.addAndPutInCache(caches); // total caches found try { @@ -324,8 +326,8 @@ public abstract class GCParser { // get direction images if (Settings.getLoadDirImg()) { - final Set<Geocache> caches = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); - for (final Geocache cache : caches) { + final Set<Geocache> cachesReloaded = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); + for (final Geocache cache : cachesReloaded) { if (cache.getCoords() == null && StringUtils.isNotEmpty(cache.getDirectionImg())) { DirectionImage.getDrawable(cache.getDirectionImg()); } @@ -748,15 +750,12 @@ public abstract class GCParser { } cache.setDetailedUpdatedNow(); - searchResult.addAndPutInCache(cache); + searchResult.addAndPutInCache(Collections.singletonList(cache)); return searchResult; } private static String getNumberString(final String numberWithPunctuation) { - if (numberWithPunctuation == null) { - return null; - } - return numberWithPunctuation.replaceAll("[.,]", ""); + return StringUtils.replaceChars(numberWithPunctuation, ".,", ""); } public static SearchResult searchByNextPage(final SearchResult search, boolean showCaptcha, RecaptchaReceiver recaptchaReceiver) { |
