diff options
author | Bananeweizen <Bananeweizen@gmx.de> | 2012-08-25 23:04:57 -0700 |
---|---|---|
committer | Bananeweizen <Bananeweizen@gmx.de> | 2012-08-25 23:04:57 -0700 |
commit | 0167c767937d56deb611a72d92d2fb563fd347f2 (patch) | |
tree | ff2fa899d784909ec7952940aed3d47be74ec087 /main/src/cgeo/geocaching | |
parent | 0de76826f86914e93e84724f0131c7ca79898f57 (diff) | |
parent | 42f6652ba1996d605e1fe33750b7ee1b998f1395 (diff) | |
download | cgeo-0167c767937d56deb611a72d92d2fb563fd347f2.zip cgeo-0167c767937d56deb611a72d92d2fb563fd347f2.tar.gz cgeo-0167c767937d56deb611a72d92d2fb563fd347f2.tar.bz2 |
Merge pull request #1974 from campbeb/add_oc_instant_search
Allow searching OC geocodes on main screen
Diffstat (limited to 'main/src/cgeo/geocaching')
-rw-r--r-- | main/src/cgeo/geocaching/SearchActivity.java | 11 |
1 files changed, 9 insertions, 2 deletions
diff --git a/main/src/cgeo/geocaching/SearchActivity.java b/main/src/cgeo/geocaching/SearchActivity.java index ae350c0..e5cf679 100644 --- a/main/src/cgeo/geocaching/SearchActivity.java +++ b/main/src/cgeo/geocaching/SearchActivity.java @@ -1,6 +1,9 @@ package cgeo.geocaching; import cgeo.geocaching.activity.AbstractActivity; +import cgeo.geocaching.connector.ConnectorFactory; +import cgeo.geocaching.connector.IConnector; +import cgeo.geocaching.connector.capability.ISearchByGeocode; import cgeo.geocaching.connector.gc.GCConstants; import cgeo.geocaching.geopoint.Geopoint; import cgeo.geocaching.geopoint.GeopointFormatter; @@ -98,14 +101,18 @@ public class SearchActivity extends AbstractActivity { * @return true if a search was performed, else false */ private boolean instantSearch(final String query, final boolean keywordSearch) { - final String geocode = BaseUtils.getMatch(query, GCConstants.PATTERN_GC_CODE, true, 0, "", false); - if (StringUtils.isNotBlank(geocode)) { + + // Check if any connector can handle the query as a geocode + final String geocode = StringUtils.deleteWhitespace(query); + final IConnector connector = ConnectorFactory.getConnector(geocode); + if (connector instanceof ISearchByGeocode) { final Intent cachesIntent = new Intent(this, CacheDetailActivity.class); cachesIntent.putExtra("geocode", geocode.toUpperCase()); startActivity(cachesIntent); return true; } + // Check if the query is a TB code final String trackable = BaseUtils.getMatch(query, GCConstants.PATTERN_TB_CODE, true, 0, "", false); if (StringUtils.isNotBlank(trackable)) { final Intent trackablesIntent = new Intent(this, cgeotrackable.class); |