diff options
author | blafoo <github@blafoo.de> | 2011-12-21 15:41:01 +0100 |
---|---|---|
committer | blafoo <github@blafoo.de> | 2011-12-25 09:21:34 +0100 |
commit | 0f0a896d59d6acea0882ea9bcb113b294a008155 (patch) | |
tree | d6593a399ac704da2dae1ab9231c638223beefdb /main/src/cgeo/geocaching | |
parent | fa52fefb4b7440eb1011ba412eaa43e7700ff0ef (diff) | |
download | cgeo-0f0a896d59d6acea0882ea9bcb113b294a008155.zip cgeo-0f0a896d59d6acea0882ea9bcb113b294a008155.tar.gz cgeo-0f0a896d59d6acea0882ea9bcb113b294a008155.tar.bz2 |
Refactored/renamed cgSearch/cgWrapCache
Diffstat (limited to 'main/src/cgeo/geocaching')
30 files changed, 418 insertions, 414 deletions
diff --git a/main/src/cgeo/geocaching/CacheDetailActivity.java b/main/src/cgeo/geocaching/CacheDetailActivity.java index 6faa603..7ca8137 100644 --- a/main/src/cgeo/geocaching/CacheDetailActivity.java +++ b/main/src/cgeo/geocaching/CacheDetailActivity.java @@ -106,7 +106,7 @@ public class CacheDetailActivity extends AbstractActivity { private cgGeo geolocation; private cgCache cache; private final Progress progress = new Progress(); - private cgSearch search; + private SearchResult search; private final LocationUpdater locationUpdater = new LocationUpdater(); private String contextMenuUser = null; private int contextMenuWPIndex = -1; @@ -563,8 +563,8 @@ public class CacheDetailActivity extends AbstractActivity { return; } - if (cgeoapplication.getError(search) != null) { - showToast(res.getString(R.string.err_dwld_details_failed_reason) + " " + cgeoapplication.getError(search) + "."); + if (SearchResult.getError(search) != null) { + showToast(res.getString(R.string.err_dwld_details_failed_reason) + " " + SearchResult.getError(search) + "."); finish(); return; diff --git a/main/src/cgeo/geocaching/ParseResult.java b/main/src/cgeo/geocaching/ParseResult.java new file mode 100644 index 0000000..af99320 --- /dev/null +++ b/main/src/cgeo/geocaching/ParseResult.java @@ -0,0 +1,56 @@ +package cgeo.geocaching; + +import cgeo.geocaching.enumerations.CacheType; +import cgeo.geocaching.enumerations.LoadFlags; + +import java.util.ArrayList; +import java.util.List; + +/** + * Search result including list of caches + */ +public class ParseResult extends SearchResult { + + public List<cgCache> cacheList = new ArrayList<cgCache>(); + + public ParseResult() { + super(); + } + + public ParseResult(SearchResult searchResult) { + super(searchResult); + } + + public ParseResult(ParseResult parseResult) { + super(parseResult); + cacheList.addAll(parseResult.cacheList); + } + + public ParseResult(final List<String> geocodes) { + super(geocodes); + cgeoapplication app = cgeoapplication.getInstance(); + for (String geocode : geocodes) { + cacheList.add(app.getCacheByGeocode(geocode, LoadFlags.LOADALL)); + } + } + + public static ParseResult filterParseResults(final ParseResult parseResult, final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType) { + + ParseResult result = new ParseResult(parseResult); + + if (parseResult != null) { + for (final cgCache cache : parseResult.cacheList) { + // Is there any reason to exclude the cache from the list? + final boolean excludeCache = (excludeDisabled && cache.isDisabled()) || + (excludeMine && (cache.isOwn() || cache.isFound())) || + (cacheType != CacheType.ALL && cacheType != cache.getType()); + if (!excludeCache) { + result.addGeocode(cache.getGeocode()); + result.cacheList.add(cache); + } + } + } + + return result; + } +}
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/SearchResult.java b/main/src/cgeo/geocaching/SearchResult.java new file mode 100644 index 0000000..790ebd8 --- /dev/null +++ b/main/src/cgeo/geocaching/SearchResult.java @@ -0,0 +1,169 @@ +package cgeo.geocaching; + +import cgeo.geocaching.enumerations.StatusCode; + +import android.os.Parcel; +import android.os.Parcelable; + +import java.util.ArrayList; +import java.util.Collections; +import java.util.List; + +public class SearchResult implements Parcelable { + + final private List<String> geocodes; + public StatusCode error = null; // 13 + public String url = ""; // 7 + public String[] viewstates = null; // 9 + public int totalCnt = 0; // 9 + + final public static Parcelable.Creator<SearchResult> CREATOR = new Parcelable.Creator<SearchResult>() { + public SearchResult createFromParcel(Parcel in) { + return new SearchResult(in); + } + + public SearchResult[] newArray(int size) { + return new SearchResult[size]; + } + }; + + public SearchResult() { + this((List<String>) null); + } + + public SearchResult(SearchResult searchResult) { + if (searchResult != null) { + this.geocodes = new ArrayList<String>(searchResult.geocodes); + this.error = searchResult.error; + this.url = searchResult.url; + this.viewstates = searchResult.viewstates; + this.totalCnt = searchResult.totalCnt; + } else { + this.geocodes = new ArrayList<String>(); + } + } + + public SearchResult(final List<String> geocodes) { + if (geocodes == null) { + this.geocodes = new ArrayList<String>(); + } else { + this.geocodes = new ArrayList<String>(geocodes.size()); + this.geocodes.addAll(geocodes); + } + } + + public SearchResult(final Parcel in) { + geocodes = new ArrayList<String>(); + in.readStringList(geocodes); + error = (StatusCode) in.readSerializable(); + url = in.readString(); + final int length = in.readInt(); + if (length >= 0) { + viewstates = new String[length]; + in.readStringArray(viewstates); + } + totalCnt = in.readInt(); + } + + @Override + public void writeToParcel(final Parcel out, final int flags) { + out.writeStringList(geocodes); + out.writeSerializable(error); + out.writeString(url); + if (viewstates == null) { + out.writeInt(-1); + } else { + out.writeInt(viewstates.length); + out.writeStringArray(viewstates); + } + out.writeInt(totalCnt); + } + + @Override + public int describeContents() { + return 0; + } + + public List<String> getGeocodes() { + return Collections.unmodifiableList(geocodes); + } + + public int getCount() { + return geocodes.size(); + } + + public void addGeocode(final String geocode) { + geocodes.add(geocode); + } + + public static StatusCode getError(final SearchResult search) { + if (search == null) { + return null; + } + + return search.error; + } + + public static boolean setError(final SearchResult search, final StatusCode error) { + if (search == null) { + return false; + } + + search.error = error; + + return true; + } + + public static String getUrl(final SearchResult search) { + if (search == null) { + return null; + } + + return search.url; + } + + public static boolean setUrl(final SearchResult search, String url) { + if (search == null) { + return false; + } + + search.url = url; + + return true; + } + + public static String[] getViewstates(final SearchResult search) { + if (search == null) { + return null; + } + + return search.viewstates; + } + + public static boolean setViewstates(final SearchResult search, String[] viewstates) { + if (cgBase.isEmpty(viewstates) || search == null) { + return false; + } + + search.viewstates = viewstates; + + return true; + } + + public static int getTotal(final SearchResult search) { + if (search == null) { + return 0; + } + + return search.totalCnt; + } + + public static int getCount(final SearchResult search) { + if (search == null) { + return 0; + } + + return search.getCount(); + } + +} diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java index 84dce21..1a80b07 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleMapsApp.java @@ -4,7 +4,7 @@ import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.geopoint.Geopoint; @@ -29,7 +29,7 @@ class GoogleMapsApp extends AbstractNavigationApp { public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (cache == null && waypoint == null && coords == null) { return false; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java index e6578b0..d30318d 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/GoogleNavigationApp.java @@ -4,7 +4,7 @@ import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.geopoint.Geopoint; @@ -30,7 +30,7 @@ class GoogleNavigationApp extends AbstractNavigationApp { @Override public boolean invoke(final cgGeo geo, final Activity activity, final Resources res, final cgCache cache, - final cgSearch search, final cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, final cgWaypoint waypoint, final Geopoint coords) { if (activity == null) { return false; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java index fdab474..75cad9c 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/InternalMap.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.enumerations.WaypointType; import cgeo.geocaching.geopoint.Geopoint; @@ -21,7 +21,7 @@ class InternalMap extends AbstractInternalMap { @Override public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (search != null) { CGeoMap.startActivitySearch(activity, search, cache != null ? cache.getGeocode() : null, true); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java index 544ad33..cec1597 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/LocusApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.apps.AbstractLocusApp; import cgeo.geocaching.geopoint.Geopoint; @@ -27,7 +27,7 @@ class LocusApp extends AbstractLocusApp implements NavigationApp { */ @Override public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (cache == null && waypoint == null && coords == null) { return false; diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java index f52cc42..757141e 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.apps.App; import cgeo.geocaching.geopoint.Geopoint; @@ -14,6 +14,6 @@ interface NavigationApp extends App { public boolean invoke(final cgGeo geo, final Activity activity, final Resources res, final cgCache cache, - final cgSearch search, final cgWaypoint waypoint, + final SearchResult search, final cgWaypoint waypoint, final Geopoint coords); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java index 56bcb5d..b29d42c 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/NavigationAppFactory.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.apps.AbstractAppFactory; import cgeo.geocaching.geopoint.Geopoint; @@ -55,7 +55,7 @@ public final class NavigationAppFactory extends AbstractAppFactory { public static boolean onMenuItemSelected(final MenuItem item, final cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint destination) { + final SearchResult search, cgWaypoint waypoint, final Geopoint destination) { NavigationApp app = (NavigationApp) getAppFromMenuItem(item, apps); if (app != null) { try { diff --git a/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java index 0d99644..51e17c6 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/OruxMapsApp.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.geopoint.Geopoint; @@ -22,7 +22,7 @@ class OruxMapsApp extends AbstractNavigationApp { @Override public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (cache == null && waypoint == null && coords == null) { return false; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java index bc88853..ca47d3e 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/RMapsApp.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.GeopointFormatter.Format; @@ -25,7 +25,7 @@ class RMapsApp extends AbstractNavigationApp { @Override public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (cache == null && waypoint == null && coords == null) { return false; } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java b/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java index 130668b..f66c199 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/RadarApp.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.geopoint.Geopoint; @@ -34,7 +34,7 @@ class RadarApp extends AbstractNavigationApp { @Override public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (cache != null) { return navigateTo(activity, cache.getCoords()); } diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java index 0b3f7b9..a0284e3 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/StaticMapApp.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeosmaps; import cgeo.geocaching.activity.ActivityMixin; @@ -28,7 +28,7 @@ class StaticMapApp extends AbstractNavigationApp { @Override public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (cache == null || cache.getListId() == 0) { ActivityMixin.showToast(activity, res.getString(R.string.err_detail_no_map_static)); diff --git a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java index 9130d64..c88e54d 100644 --- a/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java +++ b/main/src/cgeo/geocaching/apps/cache/navi/StreetviewApp.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cache.navi; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.activity.ActivityMixin; import cgeo.geocaching.geopoint.Geopoint; @@ -28,7 +28,7 @@ class StreetviewApp extends AbstractNavigationApp { public boolean invoke(cgGeo geo, Activity activity, Resources res, cgCache cache, - final cgSearch search, cgWaypoint waypoint, final Geopoint coords) { + final SearchResult search, cgWaypoint waypoint, final Geopoint coords) { if (cache == null && waypoint == null && coords == null) { return false; } diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java index 2788d2b..08f8cf8 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java +++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cachelist; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.apps.App; import android.app.Activity; @@ -14,6 +14,6 @@ interface CacheListApp extends App { boolean invoke(final cgGeo geo, final List<cgCache> caches, final Activity activity, final Resources res, - final cgSearch search); + final SearchResult search); } diff --git a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java index 46ceb8b..47503d8 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java +++ b/main/src/cgeo/geocaching/apps/cachelist/CacheListAppFactory.java @@ -4,7 +4,7 @@ import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.apps.AbstractAppFactory; import org.apache.commons.lang3.ArrayUtils; @@ -64,7 +64,7 @@ public final class CacheListAppFactory extends AbstractAppFactory { public static boolean onMenuItemSelected(final MenuItem item, final cgGeo geo, final List<cgCache> caches, final Activity activity, final Resources res, - final cgSearch search) { + final SearchResult search) { CacheListApp app = (CacheListApp) getAppFromMenuItem(item, apps); if (app != null) { try { diff --git a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java index 3038872..f5b1f51 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java +++ b/main/src/cgeo/geocaching/apps/cachelist/InternalCacheListMap.java @@ -3,7 +3,7 @@ package cgeo.geocaching.apps.cachelist; import cgeo.geocaching.R; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.apps.AbstractApp; import cgeo.geocaching.maps.CGeoMap; @@ -25,7 +25,7 @@ class InternalCacheListMap extends AbstractApp implements CacheListApp { } @Override - public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, Resources res, final cgSearch search) { + public boolean invoke(cgGeo geo, List<cgCache> caches, Activity activity, Resources res, final SearchResult search) { CGeoMap.startActivitySearch(activity, search, null, false); return true; } diff --git a/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java b/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java index eddd6ac..705014c 100644 --- a/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java +++ b/main/src/cgeo/geocaching/apps/cachelist/LocusCacheListApp.java @@ -2,7 +2,7 @@ package cgeo.geocaching.apps.cachelist; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.apps.AbstractLocusApp; import org.apache.commons.collections.CollectionUtils; @@ -26,7 +26,7 @@ class LocusCacheListApp extends AbstractLocusApp implements CacheListApp { */ @Override public boolean invoke(cgGeo geo, List<cgCache> cacheList, Activity activity, Resources res, - final cgSearch search) { + final SearchResult search) { if (CollectionUtils.isEmpty(cacheList)) { return false; } diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 286dbe5..a41a7b9 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -411,22 +411,21 @@ public class cgBase { } } - private static cgCacheWrap parseSearch(final cgSearchThread thread, final String url, final String pageContent, final boolean showCaptcha) { + private static ParseResult parseSearch(final cgSearchThread thread, final String url, final String pageContent, final boolean showCaptcha) { if (StringUtils.isBlank(pageContent)) { Log.e(Settings.tag, "cgeoBase.parseSearch: No page given"); return null; } - final cgCacheWrap caches = new cgCacheWrap(); final List<String> cids = new ArrayList<String>(); final List<String> guids = new ArrayList<String>(); String recaptchaChallenge = null; String recaptchaText = null; String page = pageContent; - caches.url = url; - - caches.viewstates = getViewstates(page); + final ParseResult parseResult = new ParseResult(); + parseResult.url = url; + parseResult.viewstates = getViewstates(page); // recaptcha if (showCaptcha) { @@ -448,7 +447,7 @@ public class cgBase { if (!page.contains("SearchResultsTable")) { // there are no results. aborting here avoids a wrong error log in the next parsing step - return caches; + return parseResult; } int startPos = page.indexOf("<div id=\"ctl00_ContentBody_ResultsPanel\""); @@ -583,14 +582,14 @@ public class cgBase { } } - caches.cacheList.add(cache); + parseResult.cacheList.add(cache); } // total caches found try { String result = BaseUtils.getMatch(page, GCConstants.PATTERN_SEARCH_TOTALCOUNT, false, 1, null, true); if (null != result) { - caches.totalCnt = Integer.parseInt(result); + parseResult.totalCnt = Integer.parseInt(result); } } catch (NumberFormatException e) { Log.w(Settings.tag, "cgeoBase.parseSearch: Failed to parse cache count"); @@ -612,13 +611,13 @@ public class cgBase { final Parameters params = new Parameters( "__EVENTTARGET", "", "__EVENTARGUMENT", ""); - if (ArrayUtils.isNotEmpty(caches.viewstates)) { - params.put("__VIEWSTATE", caches.viewstates[0]); - if (caches.viewstates.length > 1) { - for (int i = 1; i < caches.viewstates.length; i++) { - params.put("__VIEWSTATE" + i, caches.viewstates[i]); + if (ArrayUtils.isNotEmpty(parseResult.viewstates)) { + params.put("__VIEWSTATE", parseResult.viewstates[0]); + if (parseResult.viewstates.length > 1) { + for (int i = 1; i < parseResult.viewstates.length; i++) { + params.put("__VIEWSTATE" + i, parseResult.viewstates[i]); } - params.put("__VIEWSTATEFIELDCOUNT", "" + caches.viewstates.length); + params.put("__VIEWSTATEFIELDCOUNT", "" + parseResult.viewstates.length); } } for (String cid : cids) { @@ -637,13 +636,13 @@ public class cgBase { if (coordinates.contains("You have not agreed to the license agreement. The license agreement is required before you can start downloading GPX or LOC files from Geocaching.com")) { Log.i(Settings.tag, "User has not agreed to the license agreement. Can\'t download .loc file."); - caches.error = StatusCode.UNAPPROVED_LICENSE; + parseResult.error = StatusCode.UNAPPROVED_LICENSE; - return caches; + return parseResult; } } - LocParser.parseLoc(caches, coordinates); + LocParser.parseLoc(parseResult, coordinates); } catch (Exception e) { Log.e(Settings.tag, "cgBase.parseSearch.CIDs: " + e.toString()); } @@ -652,7 +651,7 @@ public class cgBase { // get direction images if (Settings.getLoadDirImg()) { - for (cgCache oneCache : caches.cacheList) { + for (cgCache oneCache : parseResult.cacheList) { if (oneCache.getCoords() == null && StringUtils.isNotEmpty(oneCache.getDirectionImg())) { cgDirectionImg.getDrawable(oneCache.getGeocode(), oneCache.getDirectionImg()); } @@ -669,7 +668,7 @@ public class cgBase { if (MapUtils.isNotEmpty(ratings)) { // save found cache coordinates - for (cgCache cache : caches.cacheList) { + for (cgCache cache : parseResult.cacheList) { if (ratings.containsKey(cache.getGuid())) { GCVoteRating rating = ratings.get(cache.getGuid()); @@ -685,17 +684,17 @@ public class cgBase { } } - return caches; + return parseResult; } - public static cgCacheWrap parseMapJSON(final String uri, final String data) { + public static ParseResult parseMapJSON(final String uri, final String data) { if (StringUtils.isEmpty(data)) { Log.e(Settings.tag, "cgeoBase.parseMapJSON: No page given"); return null; } - final cgCacheWrap caches = new cgCacheWrap(); - caches.url = uri; + final ParseResult parseResult = new ParseResult(); + parseResult.url = uri; try { final JSONObject yoDawg = new JSONObject(data); @@ -758,25 +757,25 @@ public class cgBase { cacheToAdd.setType(CacheType.UNKNOWN); } - caches.cacheList.add(cacheToAdd); + parseResult.cacheList.add(cacheToAdd); } } } else { Log.w(Settings.tag, "There are no caches in viewport"); } - caches.totalCnt = caches.cacheList.size(); + parseResult.totalCnt = parseResult.cacheList.size(); } } catch (Exception e) { Log.e(Settings.tag, "cgBase.parseMapJSON", e); } - return caches; + return parseResult; } - public static cgCacheWrap parseCache(final String page, final int listId, final CancellableHandler handler) { - final cgCacheWrap caches = parseCacheFromText(page, listId, handler); - if (caches != null && !caches.cacheList.isEmpty()) { - final cgCache cache = caches.cacheList.get(0); + public static ParseResult parseCache(final String page, final int listId, final CancellableHandler handler) { + final ParseResult parseResult = parseCacheFromText(page, listId, handler); + if (parseResult != null && !parseResult.cacheList.isEmpty()) { + final cgCache cache = parseResult.cacheList.get(0); getExtraOnlineInfo(cache, page, handler); cache.setUpdated(System.currentTimeMillis()); cache.setDetailedUpdate(cache.getUpdated()); @@ -785,10 +784,10 @@ public class cgBase { if (CancellableHandler.isCancelled(handler)) { return null; } - return caches; + return parseResult; } - static cgCacheWrap parseCacheFromText(final String page, final int listId, final CancellableHandler handler) { + static ParseResult parseCacheFromText(final String page, final int listId, final CancellableHandler handler) { sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_details); if (StringUtils.isBlank(page)) { @@ -796,21 +795,21 @@ public class cgBase { return null; } - final cgCacheWrap caches = new cgCacheWrap(); + final ParseResult parseResult = new ParseResult(); if (page.contains("Cache is Unpublished")) { - caches.error = StatusCode.UNPUBLISHED_CACHE; - return caches; + parseResult.error = StatusCode.UNPUBLISHED_CACHE; + return parseResult; } if (page.contains("Sorry, the owner of this listing has made it viewable to Premium Members only.")) { - caches.error = StatusCode.PREMIUM_ONLY; - return caches; + parseResult.error = StatusCode.PREMIUM_ONLY; + return parseResult; } if (page.contains("has chosen to make this cache listing visible to Premium Members only.")) { - caches.error = StatusCode.PREMIUM_ONLY; - return caches; + parseResult.error = StatusCode.PREMIUM_ONLY; + return parseResult; } final cgCache cache = new cgCache(); @@ -1171,9 +1170,9 @@ public class cgBase { } } - caches.cacheList.add(cache); + parseResult.cacheList.add(cache); - return caches; + return parseResult; } private static void getExtraOnlineInfo(final cgCache cache, final String page, final CancellableHandler handler) { @@ -1728,10 +1727,10 @@ public class cgBase { params.put("tx", cacheType.guid); } - public static cgSearch searchByNextPage(cgSearchThread thread, final cgSearch search, int listId, boolean showCaptcha) { - final String[] viewstates = cgeoapplication.getViewstates(search); + public static ParseResult searchByNextPage(cgSearchThread thread, final ParseResult search, int listId, boolean showCaptcha) { + final String[] viewstates = SearchResult.getViewstates(search); - final String url = cgeoapplication.getUrl(search); + final String url = SearchResult.getUrl(search); if (StringUtils.isBlank(url)) { Log.e(Settings.tag, "cgeoBase.searchByNextPage: No url found"); @@ -1759,7 +1758,7 @@ public class cgBase { } else if (loginState == StatusCode.NO_LOGIN_INFO_STORED) { Log.i(Settings.tag, "Working as guest."); } else { - cgeoapplication.setError(search, loginState); + SearchResult.setError(search, loginState); Log.e(Settings.tag, "cgeoBase.searchByNextPage: Can not log in geocaching"); return search; } @@ -1770,28 +1769,29 @@ public class cgBase { return search; } - final cgCacheWrap caches = parseSearch(thread, url, page, showCaptcha); - if (caches == null || CollectionUtils.isEmpty(caches.cacheList)) { + final ParseResult parseResult = parseSearch(thread, url, page, showCaptcha); + if (parseResult == null || CollectionUtils.isEmpty(parseResult.cacheList)) { Log.e(Settings.tag, "cgeoBase.searchByNextPage: No cache parsed"); return search; } // save to application - cgeoapplication.setError(search, caches.error); - cgeoapplication.setViewstates(search, caches.viewstates); + SearchResult.setError(search, parseResult.error); + SearchResult.setViewstates(search, parseResult.viewstates); + if (search != null) { + search.cacheList = parseResult.cacheList; - for (final cgCache cache : caches.cacheList) { - cgeoapplication.addGeocode(search, cache.getGeocode()); + for (final cgCache cache : parseResult.cacheList) { + search.addGeocode(cache.getGeocode()); + } } - cgeoapplication.getInstance().addSearch(caches.cacheList, listId); + cgeoapplication.getInstance().addSearch(parseResult.cacheList, listId); return search; } - public static cgSearch searchByGeocode(final String geocode, final String guid, final int listId, final boolean forceReload, final CancellableHandler handler) { - final cgSearch search = new cgSearch(); - + public static ParseResult searchByGeocode(final String geocode, final String guid, final int listId, final boolean forceReload, final CancellableHandler handler) { if (StringUtils.isBlank(geocode) && StringUtils.isBlank(guid)) { Log.e(Settings.tag, "cgeoBase.searchByGeocode: No geocode nor guid given"); return null; @@ -1799,6 +1799,7 @@ public class cgBase { cgeoapplication app = cgeoapplication.getInstance(); if (!forceReload && listId == 0 && (app.isOffline(geocode, guid) || app.isThere(geocode, guid, true, true))) { + final ParseResult search = new ParseResult(); final String realGeocode = StringUtils.isNotBlank(geocode) ? geocode : app.getGeocode(guid); search.addGeocode(realGeocode); return search; @@ -1806,22 +1807,22 @@ public class cgBase { // if we have no geocode, we can't dynamically select the handler, but must explicitly use GC if (geocode == null && guid != null) { - return GCConnector.getInstance().searchByGeocode(null, guid, app, search, listId, handler); + return GCConnector.getInstance().searchByGeocode(null, guid, app, listId, handler); } - return ConnectorFactory.getConnector(geocode).searchByGeocode(geocode, guid, app, search, listId, handler); + return ConnectorFactory.getConnector(geocode).searchByGeocode(geocode, guid, app, listId, handler); } - public static cgSearch searchByOffline(final Geopoint coords, final CacheType cacheType, final int list) { + public static ParseResult searchByOffline(final Geopoint coords, final CacheType cacheType, final int list) { cgeoapplication app = cgeoapplication.getInstance(); - final cgSearch search = app.getBatchOfStoredCaches(true, coords, cacheType, list); + final ParseResult search = app.getBatchOfStoredCaches(true, coords, cacheType, list); search.totalCnt = app.getAllStoredCachesCount(true, cacheType, list); return search; } - public static cgSearch searchByHistory(final CacheType cacheType) { + public static ParseResult searchByHistory(final CacheType cacheType) { final cgeoapplication app = cgeoapplication.getInstance(); - final cgSearch search = app.getHistoryOfCaches(true, cacheType); + final ParseResult search = app.getHistoryOfCaches(true, cacheType); search.totalCnt = app.getAllHistoricCachesCount(); return search; @@ -1837,8 +1838,7 @@ public class cgBase { * the parameters to add to the request URI * @return */ - private static cgSearch searchByAny(final cgSearchThread thread, final CacheType cacheType, final boolean my, final int listId, final boolean showCaptcha, final Parameters params) { - final cgSearch search = new cgSearch(); + private static ParseResult searchByAny(final cgSearchThread thread, final CacheType cacheType, final boolean my, final int listId, final boolean showCaptcha, final Parameters params) { insertCacheType(params, cacheType); final String uri = "http://www.geocaching.com/seek/nearest.aspx"; @@ -1850,23 +1850,24 @@ public class cgBase { return null; } - final cgCacheWrap caches = parseSearch(thread, fullUri, page, showCaptcha); - if (caches == null || CollectionUtils.isEmpty(caches.cacheList)) { + final ParseResult parseResult = parseSearch(thread, fullUri, page, showCaptcha); + if (parseResult == null || CollectionUtils.isEmpty(parseResult.cacheList)) { Log.e(Settings.tag, "cgeoBase.searchByAny: No cache parsed"); + return parseResult; } - List<cgCache> cacheList = filterSearchResults(search, caches, Settings.isExcludeDisabledCaches(), false, cacheType); - cgeoapplication.getInstance().addSearch(cacheList, listId); + final ParseResult search = ParseResult.filterParseResults(parseResult, Settings.isExcludeDisabledCaches(), false, cacheType); + cgeoapplication.getInstance().addSearch(search.cacheList, listId); return search; } - public static cgSearch searchByCoords(final cgSearchThread thread, final Geopoint coords, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static ParseResult searchByCoords(final cgSearchThread thread, final Geopoint coords, final CacheType cacheType, final int listId, final boolean showCaptcha) { final Parameters params = new Parameters("lat", Double.toString(coords.getLatitude()), "lng", Double.toString(coords.getLongitude())); return searchByAny(thread, cacheType, false, listId, showCaptcha, params); } - public static cgSearch searchByKeyword(final cgSearchThread thread, final String keyword, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static ParseResult searchByKeyword(final cgSearchThread thread, final String keyword, final CacheType cacheType, final int listId, final boolean showCaptcha) { if (StringUtils.isBlank(keyword)) { Log.e(Settings.tag, "cgeoBase.searchByKeyword: No keyword given"); return null; @@ -1876,7 +1877,7 @@ public class cgBase { return searchByAny(thread, cacheType, false, listId, showCaptcha, params); } - public static cgSearch searchByUsername(final cgSearchThread thread, final String userName, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static ParseResult searchByUsername(final cgSearchThread thread, final String userName, final CacheType cacheType, final int listId, final boolean showCaptcha) { if (StringUtils.isBlank(userName)) { Log.e(Settings.tag, "cgeoBase.searchByUsername: No user name given"); return null; @@ -1893,7 +1894,7 @@ public class cgBase { return searchByAny(thread, cacheType, my, listId, showCaptcha, params); } - public static cgSearch searchByOwner(final cgSearchThread thread, final String userName, final CacheType cacheType, final int listId, final boolean showCaptcha) { + public static ParseResult searchByOwner(final cgSearchThread thread, final String userName, final CacheType cacheType, final int listId, final boolean showCaptcha) { if (StringUtils.isBlank(userName)) { Log.e(Settings.tag, "cgeoBase.searchByOwner: No user name given"); return null; @@ -1903,8 +1904,7 @@ public class cgBase { return searchByAny(thread, cacheType, false, listId, showCaptcha, params); } - public static cgSearch searchByViewport(final String userToken, final Viewport viewport) { - final cgSearch search = new cgSearch(); + public static ParseResult searchByViewport(final String userToken, final Viewport viewport) { String page = null; @@ -1921,14 +1921,14 @@ public class cgBase { return null; } - final cgCacheWrap caches = parseMapJSON(Uri.parse(uri).buildUpon().encodedQuery(params).build().toString(), page); - if (caches == null || CollectionUtils.isEmpty(caches.cacheList)) { + final ParseResult parseResult = parseMapJSON(Uri.parse(uri).buildUpon().encodedQuery(params).build().toString(), page); + if (parseResult == null || CollectionUtils.isEmpty(parseResult.cacheList)) { Log.e(Settings.tag, "cgeoBase.searchByViewport: No cache parsed"); + return parseResult; } - List<cgCache> cacheList = filterSearchResults(search, caches, Settings.isExcludeDisabledCaches(), Settings.isExcludeMyCaches(), Settings.getCacheType()); - - cgeoapplication.getInstance().addSearch(cacheList, 0); + final ParseResult search = ParseResult.filterParseResults(parseResult, Settings.isExcludeDisabledCaches(), Settings.isExcludeMyCaches(), Settings.getCacheType()); + cgeoapplication.getInstance().addSearch(search.cacheList, 0); return search; } @@ -1950,34 +1950,6 @@ public class cgBase { return page; } - public static List<cgCache> filterSearchResults(final cgSearch search, final cgCacheWrap caches, final boolean excludeDisabled, final boolean excludeMine, final CacheType cacheType) { - List<cgCache> cacheList = new ArrayList<cgCache>(); - if (caches != null) { - if (caches.error != null) { - search.error = caches.error; - } - if (StringUtils.isNotBlank(caches.url)) { - search.url = caches.url; - } - search.viewstates = caches.viewstates; - search.totalCnt = caches.totalCnt; - - if (CollectionUtils.isNotEmpty(caches.cacheList)) { - for (final cgCache cache : caches.cacheList) { - // Is there any reason to exclude the cache from the list? - final boolean excludeCache = (excludeDisabled && cache.isDisabled()) || - (excludeMine && (cache.isOwn() || cache.isFound())) || - (cacheType != CacheType.ALL && cacheType != cache.getType()); - if (!excludeCache) { - search.addGeocode(cache.getGeocode()); - cacheList.add(cache); - } - } - } - } - return cacheList; - } - public static cgTrackable searchTrackable(final String geocode, final String guid, final String id) { if (StringUtils.isBlank(geocode) && StringUtils.isBlank(guid) && StringUtils.isBlank(id)) { Log.w(Settings.tag, "cgeoBase.searchTrackable: No geocode nor guid nor id given"); @@ -2643,13 +2615,13 @@ public class cgBase { if (origCache != null) { // only reload the cache, if it was already stored or has not all details (by checking the description) if (origCache.getListId() > 0 || StringUtils.isBlank(origCache.getDescription())) { - final cgSearch search = searchByGeocode(origCache.getGeocode(), null, listId, false, null); + final SearchResult search = searchByGeocode(origCache.getGeocode(), null, listId, false, null); cache = app.getCache(search); } else { cache = origCache; } } else if (StringUtils.isNotBlank(geocode)) { - final cgSearch search = searchByGeocode(geocode, null, listId, false, null); + final SearchResult search = searchByGeocode(geocode, null, listId, false, null); cache = app.getCache(search); } else { cache = null; diff --git a/main/src/cgeo/geocaching/cgCacheWrap.java b/main/src/cgeo/geocaching/cgCacheWrap.java deleted file mode 100644 index b1ccb12..0000000 --- a/main/src/cgeo/geocaching/cgCacheWrap.java +++ /dev/null @@ -1,17 +0,0 @@ -package cgeo.geocaching; - -import cgeo.geocaching.enumerations.StatusCode; - -import java.util.ArrayList; -import java.util.List; - -/** - * List of caches - */ -public class cgCacheWrap { - public StatusCode error = null; - public String url = ""; - public String[] viewstates = null; - public int totalCnt = 0; - public List<cgCache> cacheList = new ArrayList<cgCache>(); -}
\ No newline at end of file diff --git a/main/src/cgeo/geocaching/cgSearch.java b/main/src/cgeo/geocaching/cgSearch.java deleted file mode 100644 index b96b1cd..0000000 --- a/main/src/cgeo/geocaching/cgSearch.java +++ /dev/null @@ -1,87 +0,0 @@ -package cgeo.geocaching; - -import cgeo.geocaching.enumerations.StatusCode; - -import android.os.Parcel; -import android.os.Parcelable; - -import java.util.ArrayList; -import java.util.Collections; -import java.util.List; - -public class cgSearch implements Parcelable { - - final private List<String> geocodes; - public StatusCode error = null; - public String url = ""; - public String[] viewstates = null; - public int totalCnt = 0; - - final public static Parcelable.Creator<cgSearch> CREATOR = new Parcelable.Creator<cgSearch>() { - public cgSearch createFromParcel(Parcel in) { - return new cgSearch(in); - } - - public cgSearch[] newArray(int size) { - return new cgSearch[size]; - } - }; - - public cgSearch() { - this((List<String>) null); - } - - public cgSearch(final List<String> geocodes) { - if (geocodes == null) { - this.geocodes = new ArrayList<String>(); - } else { - this.geocodes = new ArrayList<String>(geocodes.size()); - this.geocodes.addAll(geocodes); - } - } - - public cgSearch(final Parcel in) { - geocodes = new ArrayList<String>(); - in.readStringList(geocodes); - error = (StatusCode) in.readSerializable(); - url = in.readString(); - final int length = in.readInt(); - if (length >= 0) { - viewstates = new String[length]; - in.readStringArray(viewstates); - } - totalCnt = in.readInt(); - } - - @Override - public void writeToParcel(final Parcel out, final int flags) { - out.writeStringList(geocodes); - out.writeSerializable(error); - out.writeString(url); - if (viewstates == null) { - out.writeInt(-1); - } else { - out.writeInt(viewstates.length); - out.writeStringArray(viewstates); - } - out.writeInt(totalCnt); - } - - @Override - public int describeContents() { - return 0; - } - - public List<String> getGeocodes() { - return Collections.unmodifiableList(geocodes); - } - - public int getCount() { - return geocodes.size(); - } - - public void addGeocode(final String geocode) { - geocodes.add(geocode); - } - -} diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index b964555..ddc5aaa 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -5,7 +5,6 @@ import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.LoadFlags; import cgeo.geocaching.enumerations.LoadFlags.LoadFlag; import cgeo.geocaching.enumerations.LogType; -import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.geopoint.Geopoint; import org.apache.commons.collections.CollectionUtils; @@ -237,77 +236,7 @@ public class cgeoapplication extends Application { return storage.getCacheidForGeocode(geocode); } - public static StatusCode getError(final cgSearch search) { - if (search == null) { - return null; - } - - return search.error; - } - - public static boolean setError(final cgSearch search, final StatusCode error) { - if (search == null) { - return false; - } - - search.error = error; - - return true; - } - - public static String getUrl(final cgSearch search) { - if (search == null) { - return null; - } - - return search.url; - } - - public static boolean setUrl(final cgSearch search, String url) { - if (search == null) { - return false; - } - - search.url = url; - - return true; - } - - public static String[] getViewstates(final cgSearch search) { - if (search == null) { - return null; - } - - return search.viewstates; - } - - public static boolean setViewstates(final cgSearch search, String[] viewstates) { - if (cgBase.isEmpty(viewstates) || search == null) { - return false; - } - - search.viewstates = viewstates; - - return true; - } - - public static int getTotal(final cgSearch search) { - if (search == null) { - return 0; - } - - return search.totalCnt; - } - - public static int getCount(final cgSearch search) { - if (search == null) { - return 0; - } - - return search.getCount(); - } - - public boolean hasUnsavedCaches(final cgSearch search) { + public boolean hasUnsavedCaches(final SearchResult search) { if (search == null) { return false; } @@ -380,7 +309,7 @@ public class cgeoapplication extends Application { return getBounds(geocodeList); } - public List<Number> getBounds(final cgSearch search) { + public List<Number> getBounds(final SearchResult search) { if (search == null) { return null; } @@ -396,7 +325,7 @@ public class cgeoapplication extends Application { return storage.getBounds(geocodes.toArray()); } - public cgCache getCache(final cgSearch search) { + public cgCache getCache(final SearchResult search) { if (search == null) { return null; } @@ -412,15 +341,15 @@ public class cgeoapplication extends Application { * only load waypoints for map usage. All other callers should set this to <code>false</code> * @return */ - public List<cgCache> getCaches(final cgSearch search, final boolean loadWaypoints) { + public List<cgCache> getCaches(final SearchResult search, final boolean loadWaypoints) { return getCaches(search, null, null, null, null, loadWaypoints ? EnumSet.of(LoadFlag.LOADWAYPOINTS, LoadFlag.LOADOFFLINELOG) : EnumSet.of(LoadFlag.LOADOFFLINELOG)); } - public List<cgCache> getCaches(final cgSearch search, Long centerLat, Long centerLon, Long spanLat, Long spanLon) { + public List<cgCache> getCaches(final SearchResult search, Long centerLat, Long centerLon, Long spanLat, Long spanLon) { return getCaches(search, centerLat, centerLon, spanLat, spanLon, EnumSet.of(LoadFlag.LOADWAYPOINTS, LoadFlag.LOADOFFLINELOG)); } - public List<cgCache> getCaches(final cgSearch search, final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final EnumSet<LoadFlag> loadFlags) { + public List<cgCache> getCaches(final SearchResult search, final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final EnumSet<LoadFlag> loadFlags) { if (search == null) { List<cgCache> cachesOut = new ArrayList<cgCache>(); @@ -445,28 +374,28 @@ public class cgeoapplication extends Application { return cachesOut; } - public cgSearch getBatchOfStoredCaches(final boolean detailedOnly, final Geopoint coords, final CacheType cacheType, final int list) { + public ParseResult getBatchOfStoredCaches(final boolean detailedOnly, final Geopoint coords, final CacheType cacheType, final int list) { final List<String> geocodes = storage.loadBatchOfStoredGeocodes(detailedOnly, coords, cacheType, list); - return new cgSearch(geocodes); + return new ParseResult(geocodes); } public List<cgDestination> getHistoryOfSearchedLocations() { return storage.loadHistoryOfSearchedLocations(); } - public cgSearch getHistoryOfCaches(final boolean detailedOnly, final CacheType cacheType) { + public ParseResult getHistoryOfCaches(final boolean detailedOnly, final CacheType cacheType) { final List<String> geocodes = storage.loadBatchOfHistoricGeocodes(detailedOnly, cacheType); - return new cgSearch(geocodes); + return new ParseResult(geocodes); } - public cgSearch getCachedInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cacheType) { + public SearchResult getCachedInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cacheType) { final List<String> geocodes = storage.getCachedInViewport(centerLat, centerLon, spanLat, spanLon, cacheType); - return new cgSearch(geocodes); + return new SearchResult(geocodes); } - public cgSearch getStoredInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cacheType) { + public SearchResult getStoredInViewport(final Long centerLat, final Long centerLon, final Long spanLat, final Long spanLon, final CacheType cacheType) { final List<String> geocodes = storage.getStoredInViewport(centerLat, centerLon, spanLat, spanLon, cacheType); - return new cgSearch(geocodes); + return new SearchResult(geocodes); } public int getAllStoredCachesCount(final boolean detailedOnly, final CacheType cacheType, final Integer list) { @@ -516,14 +445,6 @@ public class cgeoapplication extends Application { return storage.saveInventory("---", list); } - public static void addGeocode(final cgSearch search, final String geocode) { - if (search == null || StringUtils.isBlank(geocode)) { - return; - } - - search.addGeocode(geocode); - } - public void addSearch(final List<cgCache> cacheList, final int listId) { if (CollectionUtils.isEmpty(cacheList)) { return; @@ -535,7 +456,7 @@ public class cgeoapplication extends Application { } } - public boolean addCacheToSearch(cgSearch search, cgCache cache) { + public boolean addCacheToSearch(SearchResult search, cgCache cache) { if (search == null || cache == null) { return false; } diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index 1e14427..9ef26e4 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -133,7 +133,7 @@ public class cgeocaches extends AbstractListActivity { private String keyword = null; private String address = null; private String username = null; - private cgSearch search = null; + private ParseResult search = null; private List<cgCache> cacheList = new ArrayList<cgCache>(); private CacheListAdapter adapter = null; private LayoutInflater inflater = null; @@ -163,7 +163,7 @@ public class cgeocaches extends AbstractListActivity { public void handleMessage(Message msg) { try { if (search != null) { - setTitle(title + " [" + cgeoapplication.getCount(search) + "]"); + setTitle(title + " [" + SearchResult.getCount(search) + "]"); cacheList.clear(); final List<cgCache> cacheListTmp = app.getCaches(search, false); @@ -185,11 +185,11 @@ public class cgeocaches extends AbstractListActivity { showToast(res.getString(R.string.err_list_load_fail)); setMoreCaches(false); } else { - final int count = cgeoapplication.getTotal(search); + final int count = SearchResult.getTotal(search); setMoreCaches(count > 0 && cacheList != null && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS); } - if (cacheList != null && cgeoapplication.getError(search) == StatusCode.UNAPPROVED_LICENSE) { + if (cacheList != null && SearchResult.getError(search) == StatusCode.UNAPPROVED_LICENSE) { AlertDialog.Builder dialog = new AlertDialog.Builder(cgeocaches.this); dialog.setTitle(res.getString(R.string.license)); dialog.setMessage(res.getString(R.string.err_license)); @@ -211,8 +211,8 @@ public class cgeocaches extends AbstractListActivity { AlertDialog alert = dialog.create(); alert.show(); - } else if (app != null && cgeoapplication.getError(search) != null) { - showToast(res.getString(R.string.err_download_fail) + cgeoapplication.getError(search).getErrorString(res) + "."); + } else if (app != null && SearchResult.getError(search) != null) { + showToast(res.getString(R.string.err_download_fail) + SearchResult.getError(search).getErrorString(res) + "."); hideLoading(); showProgress(false); @@ -254,7 +254,7 @@ public class cgeocaches extends AbstractListActivity { public void handleMessage(Message msg) { try { if (search != null) { - setTitle(title + " [" + cgeoapplication.getCount(search) + "]"); + setTitle(title + " [" + SearchResult.getCount(search) + "]"); cacheList.clear(); final List<cgCache> cacheListTmp = app.getCaches(search, false); @@ -276,12 +276,12 @@ public class cgeocaches extends AbstractListActivity { showToast(res.getString(R.string.err_list_load_fail)); setMoreCaches(false); } else { - final int count = cgeoapplication.getTotal(search); + final int count = SearchResult.getTotal(search); setMoreCaches(count > 0 && cacheList != null && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS); } - if (cgeoapplication.getError(search) != null) { - showToast(res.getString(R.string.err_download_fail) + cgeoapplication.getError(search).getErrorString(res) + "."); + if (SearchResult.getError(search) != null) { + showToast(res.getString(R.string.err_download_fail) + SearchResult.getError(search).getErrorString(res) + "."); listFooter.setOnClickListener(new MoreCachesListener()); hideLoading(); @@ -655,7 +655,8 @@ public class cgeocaches extends AbstractListActivity { title = res.getString(R.string.map_map); setTitle(title); showProgress(true); - search = extras != null ? (cgSearch) extras.get("search") : null; + SearchResult result = extras != null ? (SearchResult) extras.get("search") : null; + search = new ParseResult(result); loadCachesHandler.sendMessage(Message.obtain()); break; default: @@ -721,7 +722,7 @@ public class cgeocaches extends AbstractListActivity { // refresh standard list if it has changed (new caches downloaded) if (type == CacheListType.OFFLINE && listId == StoredList.STANDARD_LIST_ID && search != null) { - cgSearch newSearch = cgBase.searchByOffline(coords, cacheType, listId); + SearchResult newSearch = cgBase.searchByOffline(coords, cacheType, listId); if (newSearch != null && newSearch.totalCnt != search.totalCnt) { refreshCurrentList(); } @@ -1262,7 +1263,7 @@ public class cgeocaches extends AbstractListActivity { if (adapterInfo != null) { // create a search for a single cache (as if in details view) final cgCache cache = getCacheFromAdapter(adapterInfo); - final cgSearch singleSearch = cgBase.searchByGeocode(cache.getGeocode(), null, 0, false, null); + final SearchResult singleSearch = cgBase.searchByGeocode(cache.getGeocode(), null, 0, false, null); if (NavigationAppFactory.onMenuItemSelected(item, geo, this, res, cache, singleSearch, null, null)) { @@ -1391,7 +1392,7 @@ public class cgeocaches extends AbstractListActivity { } if (CollectionUtils.isNotEmpty(cacheList)) { - final int count = cgeoapplication.getTotal(search); + final int count = SearchResult.getTotal(search); setMoreCaches(count > 0 && cacheList.size() < count && cacheList.size() < MAX_LIST_ITEMS); } @@ -2524,7 +2525,7 @@ public class cgeocaches extends AbstractListActivity { return; } - cgSearch searchToUse = search; + SearchResult searchToUse = search; // apply filter settings (if there's a filter) if (adapter != null) { @@ -2532,10 +2533,10 @@ public class cgeocaches extends AbstractListActivity { for (cgCache cache : adapter.getFilteredList()) { geocodes.add(cache.getGeocode()); } - searchToUse = new cgSearch(geocodes); + searchToUse = new SearchResult(geocodes); } - int count = cgeoapplication.getCount(searchToUse); + int count = SearchResult.getCount(searchToUse); String mapTitle = title; if (count > 0) { mapTitle = title + " [" + count + "]"; @@ -2676,7 +2677,7 @@ public class cgeocaches extends AbstractListActivity { context.startActivity(cachesIntent); } - public static void startActivityMap(final Context context, final cgSearch search) { + public static void startActivityMap(final Context context, final SearchResult search) { final Intent cachesIntent = new Intent(context, cgeocaches.class); cachesIntent.putExtra(EXTRAS_LIST_TYPE, CacheListType.MAP); cachesIntent.putExtra("search", search); diff --git a/main/src/cgeo/geocaching/connector/AbstractConnector.java b/main/src/cgeo/geocaching/connector/AbstractConnector.java index b78c145..9abcd45 100644 --- a/main/src/cgeo/geocaching/connector/AbstractConnector.java +++ b/main/src/cgeo/geocaching/connector/AbstractConnector.java @@ -1,7 +1,7 @@ package cgeo.geocaching.connector; +import cgeo.geocaching.ParseResult; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgSearch; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.utils.CancellableHandler; @@ -44,12 +44,12 @@ public abstract class AbstractConnector implements IConnector { } @Override - public cgSearch searchByCoordinate(Geopoint center) { + public ParseResult searchByCoordinate(Geopoint center) { return null; } @Override - public cgSearch searchByGeocode(String geocode, String guid, cgeoapplication app, cgSearch search, int listId, CancellableHandler handler) { + public ParseResult searchByGeocode(String geocode, String guid, cgeoapplication app, int listId, CancellableHandler handler) { return null; } diff --git a/main/src/cgeo/geocaching/connector/GCConnector.java b/main/src/cgeo/geocaching/connector/GCConnector.java index 33705ab..f1bb117 100644 --- a/main/src/cgeo/geocaching/connector/GCConnector.java +++ b/main/src/cgeo/geocaching/connector/GCConnector.java @@ -1,13 +1,13 @@ package cgeo.geocaching.connector; import cgeo.geocaching.Parameters; +import cgeo.geocaching.ParseResult; import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgCacheWrap; -import cgeo.geocaching.cgSearch; import cgeo.geocaching.cgeoapplication; +import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.utils.CancellableHandler; import org.apache.commons.collections.CollectionUtils; @@ -15,7 +15,6 @@ import org.apache.commons.lang3.StringUtils; import android.util.Log; -import java.util.List; import java.util.regex.Pattern; public class GCConnector extends AbstractConnector { @@ -81,7 +80,13 @@ public class GCConnector extends AbstractConnector { } @Override - public cgSearch searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int listId, final CancellableHandler handler) { + public ParseResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final int listId, final CancellableHandler handler) { + + if (app == null) { + Log.e(Settings.tag, "cgeoBase.searchByGeocode: No application found"); + return null; + } + final Parameters params = new Parameters("decrypt", "y"); if (StringUtils.isNotBlank(geocode)) { params.put("wp", geocode); @@ -89,16 +94,12 @@ public class GCConnector extends AbstractConnector { params.put("guid", guid); } - if (app == null) { - Log.e(Settings.tag, "cgeoBase.searchByGeocode: No application found"); - return null; - } - cgBase.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_loadpage); final String page = cgBase.requestLogged("http://www.geocaching.com/seek/cache_details.aspx", params, false, false, false); if (StringUtils.isEmpty(page)) { + ParseResult search = new ParseResult(); if (app.isThere(geocode, guid, true, false)) { if (StringUtils.isBlank(geocode) && StringUtils.isNotBlank(guid)) { Log.i(Settings.tag, "Loading old cache from cache."); @@ -107,32 +108,25 @@ public class GCConnector extends AbstractConnector { } else { search.addGeocode(geocode); } - search.error = null; + search.error = StatusCode.NO_ERROR; return search; } Log.e(Settings.tag, "cgeoBase.searchByGeocode: No data from server"); - return null; + search.error = StatusCode.COMMUNICATION_ERROR; + return search; } - final cgCacheWrap caches = cgBase.parseCache(page, listId, handler); + final ParseResult parseResult = cgBase.parseCache(page, listId, handler); - if (caches == null || CollectionUtils.isEmpty(caches.cacheList)) { - if (caches != null && caches.error != null) { - search.error = caches.error; - } - if (caches != null && StringUtils.isNotBlank(caches.url)) { - search.url = caches.url; - } - - app.addSearch(null, listId); + if (parseResult == null || CollectionUtils.isEmpty(parseResult.cacheList)) { Log.e(Settings.tag, "cgeoBase.searchByGeocode: No cache parsed"); - return search; + return parseResult; } - final List<cgCache> cacheList = cgBase.filterSearchResults(search, caches, false, false, Settings.getCacheType()); - app.addSearch(cacheList, listId); + ParseResult search = ParseResult.filterParseResults(parseResult, false, false, Settings.getCacheType()); + app.addSearch(search.cacheList, listId); return search; } diff --git a/main/src/cgeo/geocaching/connector/IConnector.java b/main/src/cgeo/geocaching/connector/IConnector.java index 66c5c89..7fa0e3f 100644 --- a/main/src/cgeo/geocaching/connector/IConnector.java +++ b/main/src/cgeo/geocaching/connector/IConnector.java @@ -1,7 +1,7 @@ package cgeo.geocaching.connector; +import cgeo.geocaching.ParseResult; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgSearch; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.utils.CancellableHandler; @@ -75,7 +75,7 @@ public interface IConnector { */ public boolean supportsCachesAround(); - public cgSearch searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int listId, final CancellableHandler handler); + public ParseResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final int listId, final CancellableHandler handler); /** * search caches by coordinate. must be implemented if {@link supportsCachesAround} returns <code>true</true> @@ -83,11 +83,11 @@ public interface IConnector { * @param center * @return */ - public cgSearch searchByCoordinate(final Geopoint center); + public ParseResult searchByCoordinate(final Geopoint center); /** * return true if this is a ZIP file containing a GPX file - * + * * @param fileName * @return */ diff --git a/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java b/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java index 657006a..dfd474d 100644 --- a/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java +++ b/main/src/cgeo/geocaching/connector/opencaching/ApiOpenCachingConnector.java @@ -1,17 +1,13 @@ package cgeo.geocaching.connector.opencaching; import cgeo.geocaching.Parameters; +import cgeo.geocaching.ParseResult; import cgeo.geocaching.Settings; -import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgCacheWrap; -import cgeo.geocaching.cgSearch; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.utils.CancellableHandler; import cgeo.geocaching.utils.CryptUtils; -import java.util.List; - public class ApiOpenCachingConnector extends OpenCachingConnector { private final String cK; @@ -37,16 +33,16 @@ public class ApiOpenCachingConnector extends OpenCachingConnector { } @Override - public cgSearch searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final cgSearch search, final int listId, final CancellableHandler handler) { + public ParseResult searchByGeocode(final String geocode, final String guid, final cgeoapplication app, final int listId, final CancellableHandler handler) { final cgCache cache = OkapiClient.getCache(geocode); if (cache == null) { return null; } - final cgCacheWrap caches = new cgCacheWrap(); - caches.cacheList.add(cache); + final ParseResult parseResult = new ParseResult(); + parseResult.cacheList.add(cache); - final List<cgCache> cacheList = cgBase.filterSearchResults(search, caches, false, false, Settings.getCacheType()); - app.addSearch(cacheList, listId); + final ParseResult search = ParseResult.filterParseResults(parseResult, false, false, Settings.getCacheType()); + app.addSearch(search.cacheList, listId); return search; } diff --git a/main/src/cgeo/geocaching/files/GPXImporter.java b/main/src/cgeo/geocaching/files/GPXImporter.java index a021af0..d855d69 100644 --- a/main/src/cgeo/geocaching/files/GPXImporter.java +++ b/main/src/cgeo/geocaching/files/GPXImporter.java @@ -3,7 +3,7 @@ package cgeo.geocaching.files; import cgeo.geocaching.R; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.activity.IAbstractActivity; import cgeo.geocaching.activity.Progress; @@ -123,10 +123,10 @@ public class GPXImporter { caches = doImport(); importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_STORE_CACHES, R.string.gpx_import_storing, caches.size())); - cgSearch search = storeParsedCaches(caches); + SearchResult search = storeParsedCaches(caches); Log.i(Settings.tag, "Imported successfully " + caches.size() + " caches."); - importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_FINISHED, cgeoapplication.getCount(search), 0, search)); + importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_FINISHED, SearchResult.getCount(search), 0, search)); } catch (IOException e) { Log.i(Settings.tag, "Importing caches failed - error reading data: " + e.getMessage()); importStepHandler.sendMessage(importStepHandler.obtainMessage(IMPORT_STEP_FINISHED_WITH_ERROR, R.string.gpx_import_error_io, 0, e.getLocalizedMessage())); @@ -144,8 +144,8 @@ public class GPXImporter { protected abstract Collection<cgCache> doImport() throws IOException, ParserException; - private cgSearch storeParsedCaches(Collection<cgCache> caches) { - final cgSearch search = new cgSearch(); + private SearchResult storeParsedCaches(Collection<cgCache> caches) { + final SearchResult search = new SearchResult(); final cgeoapplication app = cgeoapplication.getInstance(); int storedCaches = 0; for (cgCache cache : caches) { diff --git a/main/src/cgeo/geocaching/files/LocParser.java b/main/src/cgeo/geocaching/files/LocParser.java index 7fd48d4..6f043f0 100644 --- a/main/src/cgeo/geocaching/files/LocParser.java +++ b/main/src/cgeo/geocaching/files/LocParser.java @@ -1,8 +1,8 @@ package cgeo.geocaching.files; +import cgeo.geocaching.ParseResult; import cgeo.geocaching.Settings; import cgeo.geocaching.cgCache; -import cgeo.geocaching.cgCacheWrap; import cgeo.geocaching.cgCoord; import cgeo.geocaching.enumerations.CacheSize; import cgeo.geocaching.enumerations.CacheType; @@ -42,12 +42,11 @@ public final class LocParser extends FileParser { private int listId; - public static void parseLoc(final cgCacheWrap caches, - final String fileContent) { + public static void parseLoc(final ParseResult parseResult, final String fileContent) { final Map<String, cgCoord> cidCoords = parseCoordinates(fileContent); // save found cache coordinates - for (cgCache cache : caches.cacheList) { + for (cgCache cache : parseResult.cacheList) { if (cidCoords.containsKey(cache.getGeocode())) { cgCoord coord = cidCoords.get(cache.getGeocode()); diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index 3a813e5..99a528b 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -9,7 +9,7 @@ import cgeo.geocaching.cgCache; import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgDirection; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.cgSearch; +import cgeo.geocaching.SearchResult; import cgeo.geocaching.cgWaypoint; import cgeo.geocaching.cgeoapplication; import cgeo.geocaching.cgeocaches; @@ -103,13 +103,13 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory private UpdateDirectionCallback dirUpdate = new UpdateDir(); // from intent private boolean fromDetailIntent = false; - private cgSearch searchIntent = null; + private SearchResult searchIntent = null; private String geocodeIntent = null; private Geopoint coordsIntent = null; private WaypointType waypointTypeIntent = null; private int[] mapStateIntent = null; // status data - private cgSearch search = null; + private SearchResult search = null; private String token = null; private boolean noMapTokenShowed = false; // map status data @@ -357,7 +357,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory Bundle extras = activity.getIntent().getExtras(); if (extras != null) { fromDetailIntent = extras.getBoolean(EXTRAS_DETAIL); - searchIntent = (cgSearch) extras.getParcelable(EXTRAS_SEARCH); + searchIntent = (SearchResult) extras.getParcelable(EXTRAS_SEARCH); geocodeIntent = extras.getString(EXTRAS_GEOCODE); final double latitudeIntent = extras.getDouble(EXTRAS_LATITUDE); final double longitudeIntent = extras.getDouble(EXTRAS_LONGITUDE); @@ -678,7 +678,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory mapView.repaintRequired(overlayCaches); return true; case MENU_AS_LIST: { - final cgSearch search = new cgSearch(); + final SearchResult search = new SearchResult(); search.totalCnt = caches.size(); for (cgCache cache : caches) { search.addGeocode(cache.getGeocode()); @@ -1721,7 +1721,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory } // move map to view results of searchIntent - private void centerMap(String geocodeCenter, final cgSearch searchCenter, final Geopoint coordsCenter, int[] mapState) { + private void centerMap(String geocodeCenter, final SearchResult searchCenter, final Geopoint coordsCenter, int[] mapState) { if (!centered && mapState != null) { try { @@ -1847,7 +1847,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory return new Intent(context, Settings.getMapProvider().getMapClass()); } - public static void startActivitySearch(final Activity fromActivity, final cgSearch search, final String title, boolean detail) { + public static void startActivitySearch(final Activity fromActivity, final SearchResult search, final String title, boolean detail) { final Intent mapIntent = newIntent(fromActivity); mapIntent.putExtra(EXTRAS_DETAIL, detail); mapIntent.putExtra(EXTRAS_SEARCH, search); |