diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-11-08 14:57:30 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-11-08 15:37:41 +0100 |
| commit | 2255aa28d81ce4e625abd01f3d12780507e5bde6 (patch) | |
| tree | aeb502c3b82d01671d7e5387f48c1dfdd1fe63cc /main/src/cgeo/geocaching | |
| parent | 614f060bfe39c90ef38752512ecd738d4d3ae8d5 (diff) | |
| download | cgeo-2255aa28d81ce4e625abd01f3d12780507e5bde6.zip cgeo-2255aa28d81ce4e625abd01f3d12780507e5bde6.tar.gz cgeo-2255aa28d81ce4e625abd01f3d12780507e5bde6.tar.bz2 | |
Remove deprecated structures and methods
Diffstat (limited to 'main/src/cgeo/geocaching')
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 29 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgCache.java | 13 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgData.java | 16 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeoapplication.java | 7 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeocaches.java | 72 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/enumerations/CacheType.java | 1 |
6 files changed, 59 insertions, 79 deletions
diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index 1cdc30e..d569cb1 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -90,12 +90,9 @@ public class cgBase { private static final String passMatch = "(?<=[\\?&])[Pp]ass(w(or)?d)?=[^&#$]+"; - @Deprecated - public final static Map<String, String> cacheTypes = new HashMap<String, String>(); public final static Map<String, String> cacheIDs = new HashMap<String, String>(); static { for (CacheType ct : CacheType.values()) { - cacheTypes.put(ct.pattern, ct.id); cacheIDs.put(ct.id, ct.guid); } } @@ -248,10 +245,8 @@ public class cgBase { // setup cache type mappings - final String CACHETYPE_ALL_GUID = "9a79e6ce-3344-409c-bbe9-496530baf758"; - cacheIDs.put("all", CACHETYPE_ALL_GUID); - cacheIDsChoices.put(res.getString(R.string.all), CACHETYPE_ALL_GUID); + cacheIDsChoices.put(res.getString(R.string.all), CacheType.ALL_GUID); for (CacheType ct : CacheType.values()) { String l10n = res.getString(ct.stringId); @@ -1996,14 +1991,10 @@ public class cgBase { * @param params * the parameters to insert the restriction into * @param cacheType - * the type of cache, or "all" if null or not recognized + * the type of cache, or null to include everything */ - static private void insertCacheType(final Parameters params, final String cacheType) { - if (StringUtils.isNotBlank(cacheType) && cacheIDs.containsKey(cacheType)) { - params.put("tx", cacheIDs.get(cacheType)); - } else { - params.put("tx", cacheIDs.get("all")); - } + static private void insertCacheType(final Parameters params, final CacheType cacheType) { + params.put("tx", cacheType != null ? cacheType.guid : CacheType.ALL_GUID); } public cgSearch searchByNextPage(cgSearchThread thread, final cgSearch search, int reason, boolean showCaptcha) { @@ -2084,7 +2075,7 @@ public class cgBase { return ConnectorFactory.getConnector(geocode).searchByGeocode(this, geocode, guid, app, search, reason, handler); } - public cgSearch searchByOffline(final Geopoint coords, final String cacheType, final int list) { + public cgSearch searchByOffline(final Geopoint coords, final CacheType cacheType, final int list) { if (app == null) { Log.e(Settings.tag, "cgeoBase.searchByOffline: No application found"); return null; @@ -2116,7 +2107,7 @@ public class cgBase { * the parameters to add to the request URI * @return */ - private cgSearch searchByAny(final cgSearchThread thread, final String cacheType, final boolean my, final int reason, final boolean showCaptcha, final Parameters params) { + private cgSearch searchByAny(final cgSearchThread thread, final CacheType cacheType, final boolean my, final int reason, final boolean showCaptcha, final Parameters params) { final cgSearch search = new cgSearch(); insertCacheType(params, cacheType); @@ -2145,12 +2136,12 @@ public class cgBase { return search; } - public cgSearch searchByCoords(final cgSearchThread thread, final Geopoint coords, final String cacheType, final int reason, final boolean showCaptcha) { + public cgSearch searchByCoords(final cgSearchThread thread, final Geopoint coords, final CacheType cacheType, final int reason, final boolean showCaptcha) { final Parameters params = new Parameters("lat", Double.toString(coords.getLatitude()), "lng", Double.toString(coords.getLongitude())); return searchByAny(thread, cacheType, false, reason, showCaptcha, params); } - public cgSearch searchByKeyword(final cgSearchThread thread, final String keyword, final String cacheType, final int reason, final boolean showCaptcha) { + public cgSearch searchByKeyword(final cgSearchThread thread, final String keyword, final CacheType cacheType, final int reason, final boolean showCaptcha) { if (StringUtils.isBlank(keyword)) { Log.e(Settings.tag, "cgeoBase.searchByKeyword: No keyword given"); return null; @@ -2160,7 +2151,7 @@ public class cgBase { return searchByAny(thread, cacheType, false, reason, showCaptcha, params); } - public cgSearch searchByUsername(final cgSearchThread thread, final String userName, final String cacheType, final int reason, final boolean showCaptcha) { + public cgSearch searchByUsername(final cgSearchThread thread, final String userName, final CacheType cacheType, final int reason, final boolean showCaptcha) { if (StringUtils.isBlank(userName)) { Log.e(Settings.tag, "cgeoBase.searchByUsername: No user name given"); return null; @@ -2177,7 +2168,7 @@ public class cgBase { return searchByAny(thread, cacheType, my, reason, showCaptcha, params); } - public cgSearch searchByOwner(final cgSearchThread thread, final String userName, final String cacheType, final int reason, final boolean showCaptcha) { + public cgSearch searchByOwner(final cgSearchThread thread, final String userName, final CacheType cacheType, final int reason, final boolean showCaptcha) { if (StringUtils.isBlank(userName)) { Log.e(Settings.tag, "cgeoBase.searchByOwner: No user name given"); return null; diff --git a/main/src/cgeo/geocaching/cgCache.java b/main/src/cgeo/geocaching/cgCache.java index 71c9f6e..74dad21 100644 --- a/main/src/cgeo/geocaching/cgCache.java +++ b/main/src/cgeo/geocaching/cgCache.java @@ -417,19 +417,6 @@ public class cgCache implements ICache { return terrain; } - /** - * @deprecated Use getCacheType() instead - * @return cache type as an id - */ - @Deprecated - public String getType() { - if (null != cacheType) { - return cacheType.id; - } else { - return ""; - } - } - @Override public boolean isArchived() { return archived; diff --git a/main/src/cgeo/geocaching/cgData.java b/main/src/cgeo/geocaching/cgData.java index 761fb0c..ba95ad4 100644 --- a/main/src/cgeo/geocaching/cgData.java +++ b/main/src/cgeo/geocaching/cgData.java @@ -2538,7 +2538,7 @@ public class cgData { return trackable; } - public int getAllStoredCachesCount(boolean detailedOnly, String cachetype, Integer list) { + public int getAllStoredCachesCount(final boolean detailedOnly, final CacheType cacheType, final Integer list) { String listSql = null; String listSqlW = null; if (list == null) { @@ -2555,16 +2555,16 @@ public class cgData { try { String sql = "select count(_id) from " + dbTableCaches; // this default is not used, but we like to have variables initialized if (!detailedOnly) { - if (cachetype == null) { + if (cacheType == null) { sql = "select count(_id) from " + dbTableCaches + listSql; } else { - sql = "select count(_id) from " + dbTableCaches + " where type = \"" + cachetype + "\"" + listSqlW; + sql = "select count(_id) from " + dbTableCaches + " where type = \"" + cacheType.id + "\"" + listSqlW; } } else { - if (cachetype == null) { + if (cacheType == null) { sql = "select count(_id) from " + dbTableCaches + " where detailed = 1" + listSqlW; } else { - sql = "select count(_id) from " + dbTableCaches + " where detailed = 1 and type = \"" + cachetype + "\"" + listSqlW; + sql = "select count(_id) from " + dbTableCaches + " where detailed = 1 and type = \"" + cacheType.id + "\"" + listSqlW; } } SQLiteStatement compiledStmnt = databaseRO.compileStatement(sql); @@ -2593,7 +2593,7 @@ public class cgData { return count; } - public List<String> loadBatchOfStoredGeocodes(final boolean detailedOnly, final Geopoint coords, final String cachetype, final int list) { + public List<String> loadBatchOfStoredGeocodes(final boolean detailedOnly, final Geopoint coords, final CacheType cacheType, final int list) { init(); List<String> geocodes = new ArrayList<String>(); @@ -2607,9 +2607,9 @@ public class cgData { specifySql.append(" and detailed = 1 "); } - if (cachetype != null) { + if (cacheType != null) { specifySql.append(" and type = \""); - specifySql.append(cachetype); + specifySql.append(cacheType.id); specifySql.append('"'); } diff --git a/main/src/cgeo/geocaching/cgeoapplication.java b/main/src/cgeo/geocaching/cgeoapplication.java index b039060..9ca30a3 100644 --- a/main/src/cgeo/geocaching/cgeoapplication.java +++ b/main/src/cgeo/geocaching/cgeoapplication.java @@ -1,5 +1,6 @@ package cgeo.geocaching; +import cgeo.geocaching.enumerations.CacheType; import cgeo.geocaching.enumerations.StatusCode; import cgeo.geocaching.geopoint.Geopoint; @@ -443,7 +444,7 @@ public class cgeoapplication extends Application { return cachesOut; } - public cgSearch getBatchOfStoredCaches(boolean detailedOnly, final Geopoint coords, String cachetype, int list) { + public cgSearch getBatchOfStoredCaches(final boolean detailedOnly, final Geopoint coords, final CacheType cachetype, final int list) { final List<String> geocodes = getStorage().loadBatchOfStoredGeocodes(detailedOnly, coords, cachetype, list); return new cgSearch(geocodes); } @@ -472,8 +473,8 @@ public class cgeoapplication extends Application { return new cgSearch(geocodes); } - public int getAllStoredCachesCount(boolean detailedOnly, String cachetype, Integer list) { - return getStorage().getAllStoredCachesCount(detailedOnly, cachetype, list); + public int getAllStoredCachesCount(final boolean detailedOnly, final CacheType cacheType, final Integer list) { + return getStorage().getAllStoredCachesCount(detailedOnly, cacheType, list); } private cgData getStorage() { diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index b8eaed4..07087cd 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -149,7 +149,7 @@ public class cgeocaches extends AbstractListActivity { private String action = null; private CacheListType type = null; private Geopoint coords = null; - private String cachetype = null; + private CacheType cachetype = null; private String keyword = null; private String address = null; private String username = null; @@ -556,7 +556,7 @@ public class cgeocaches extends AbstractListActivity { Object typeObject = extras.get(EXTRAS_LIST_TYPE); type = (typeObject instanceof CacheListType) ? (CacheListType) typeObject : CacheListType.OFFLINE; coords = new Geopoint(extras.getDouble("latitude"), extras.getDouble("longitude")); - cachetype = Settings.getCacheType(); + cachetype = CacheType.getById(Settings.getCacheType()); keyword = extras.getString("keyword"); address = extras.getString("address"); username = extras.getString("username"); @@ -1775,7 +1775,7 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { if (coords != null) { - search = base.searchByOffline(coords, Settings.getCacheType(), listId); + search = base.searchByOffline(coords, CacheType.getById(Settings.getCacheType()), listId); } else { search = base.searchByOffline(null, null, cgList.STANDARD_LIST_ID); } @@ -1816,16 +1816,16 @@ public class cgeocaches extends AbstractListActivity { private class geocachesLoadByCoords extends cgSearchThread { - private Handler handler = null; - private Geopoint coords = null; - private String cachetype = null; + final private Handler handler; + final private Geopoint coords; + final private CacheType cacheType; - public geocachesLoadByCoords(Handler handlerIn, final Geopoint coordsIn, String cachetypeIn) { + public geocachesLoadByCoords(final Handler handler, final Geopoint coords, final CacheType cacheType) { setPriority(Thread.MIN_PRIORITY); - handler = handlerIn; - coords = coordsIn; - cachetype = cachetypeIn; + this.handler = handler; + this.coords = coords; + this.cacheType = cacheType; if (coords == null) { showToast(res.getString(R.string.warn_no_coordinates)); @@ -1837,7 +1837,7 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { - search = base.searchByCoords(this, coords, cachetype, 0, Settings.isShowCaptcha()); + search = base.searchByCoords(this, coords, cacheType, 0, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } @@ -1845,16 +1845,16 @@ public class cgeocaches extends AbstractListActivity { private class geocachesLoadByKeyword extends cgSearchThread { - private Handler handler = null; - private String keyword = null; - private String cachetype = null; + final private Handler handler; + final private String keyword; + final private CacheType cacheType; - public geocachesLoadByKeyword(Handler handlerIn, String keywordIn, String cachetypeIn) { + public geocachesLoadByKeyword(final Handler handler, final String keyword, final CacheType cacheType) { setPriority(Thread.MIN_PRIORITY); - handler = handlerIn; - keyword = keywordIn; - cachetype = cachetypeIn; + this.handler = handler; + this.keyword = keyword; + this.cacheType = cacheType; if (keyword == null) { showToast(res.getString(R.string.warn_no_keyword)); @@ -1866,23 +1866,23 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { - search = base.searchByKeyword(this, keyword, cachetype, 0, Settings.isShowCaptcha()); + search = base.searchByKeyword(this, keyword, cacheType, 0, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } } private class geocachesLoadByUserName extends cgSearchThread { - private Handler handler = null; - private String username = null; - private String cachetype = null; + final private Handler handler; + final private String username; + final private CacheType cacheType; - public geocachesLoadByUserName(Handler handlerIn, String usernameIn, String cachetypeIn) { + public geocachesLoadByUserName(final Handler handler, final String username, final CacheType cacheType) { setPriority(Thread.MIN_PRIORITY); - handler = handlerIn; - username = usernameIn; - cachetype = cachetypeIn; + this.handler = handler; + this.username = username; + this.cacheType = cacheType; if (StringUtils.isBlank(username)) { showToast(res.getString(R.string.warn_no_username)); @@ -1894,23 +1894,23 @@ public class cgeocaches extends AbstractListActivity { @Override public void run() { - search = base.searchByUsername(this, username, cachetype, 0, Settings.isShowCaptcha()); + search = base.searchByUsername(this, username, cacheType, 0, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } } private class geocachesLoadByOwner extends cgSearchThread { - private Handler handler = null; - private String username = null; - private String cachetype = null; + final private Handler handler; + final private String username; + final private CacheType cacheType; - public geocachesLoadByOwner(Handler handlerIn, String usernameIn, String cachetypeIn) { + public geocachesLoadByOwner(final Handler handler, final String username, final CacheType cacheType) { setPriority(Thread.MIN_PRIORITY); - handler = handlerIn; - username = usernameIn; - cachetype = cachetypeIn; + this.handler = handler; + this.username = username; + this.cacheType = cacheType; if (StringUtils.isBlank(username)) { showToast(res.getString(R.string.warn_no_username)); @@ -1924,9 +1924,9 @@ public class cgeocaches extends AbstractListActivity { public void run() { Map<String, String> params = new HashMap<String, String>(); params.put("username", username); - params.put("cachetype", cachetype); + params.put("cachetype", cachetype.id); - search = base.searchByOwner(this, username, cachetype, 0, Settings.isShowCaptcha()); + search = base.searchByOwner(this, username, cacheType, 0, Settings.isShowCaptcha()); handler.sendMessage(new Message()); } diff --git a/main/src/cgeo/geocaching/enumerations/CacheType.java b/main/src/cgeo/geocaching/enumerations/CacheType.java index 61b38b9..e2d3d98 100644 --- a/main/src/cgeo/geocaching/enumerations/CacheType.java +++ b/main/src/cgeo/geocaching/enumerations/CacheType.java @@ -73,4 +73,5 @@ public enum CacheType { return result; } + final public static String ALL_GUID = "9a79e6ce-3344-409c-bbe9-496530baf758"; } |
