diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2011-10-05 11:24:18 +0200 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2011-10-05 11:24:20 +0200 |
| commit | dbd3729003c68e4133bbd30bb2cae66c1340e96b (patch) | |
| tree | 34dc2708ec2c4fce5594df70698554238f61c15e /main | |
| parent | 4833848c0445d5592a95fdba3f3f61e09ead6317 (diff) | |
| download | cgeo-dbd3729003c68e4133bbd30bb2cae66c1340e96b.zip cgeo-dbd3729003c68e4133bbd30bb2cae66c1340e96b.tar.gz cgeo-dbd3729003c68e4133bbd30bb2cae66c1340e96b.tar.bz2 | |
Make several things static following the Settings static move
Diffstat (limited to 'main')
| -rw-r--r-- | main/src/cgeo/geocaching/LogTemplateProvider.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 43 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgDistanceView.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgGeo.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeo.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeodetail.java | 10 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeoinit.java | 4 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeonavigate.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeopopup.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeotouch.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeotrackable.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/cgeovisit.java | 2 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/connector/GCConnector.java | 6 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 8 |
14 files changed, 42 insertions, 51 deletions
diff --git a/main/src/cgeo/geocaching/LogTemplateProvider.java b/main/src/cgeo/geocaching/LogTemplateProvider.java index 1a775fc..a83a812 100644 --- a/main/src/cgeo/geocaching/LogTemplateProvider.java +++ b/main/src/cgeo/geocaching/LogTemplateProvider.java @@ -74,7 +74,7 @@ public class LogTemplateProvider { @Override String getValue(final cgBase base, final boolean offline) { - return base.getUserName(); + return Settings.getUsername(); } }, new LogTemplate("NUMBER", R.string.init_signature_template_number) { diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index d9a336e..03fa5fd 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -479,7 +479,7 @@ public class cgBase { } } - public int login() { + public static int login() { HttpResponse loginResponse = null; String loginData = null; @@ -589,7 +589,7 @@ public class cgBase { return false; } - public String switchToEnglish(final String[] viewstates) { + public static String switchToEnglish(final String[] viewstates) { final Parameters params = new Parameters( "__EVENTTARGET", "ctl00$uxLocaleList$uxLocaleList$ctl00$uxLocaleItem", // switch to english "__EVENTARGUMENT", ""); @@ -598,7 +598,7 @@ public class cgBase { return cgBase.getResponseData(postRequest("http://www.geocaching.com/default.aspx", params)); } - public cgCacheWrap parseSearch(cgSearchThread thread, String url, String page, boolean showCaptcha) { + public static cgCacheWrap parseSearch(final cgSearchThread thread, final String url, String page, final boolean showCaptcha) { if (StringUtils.isBlank(page)) { Log.e(Settings.tag, "cgeoBase.parseSearch: No page given"); return null; @@ -1050,7 +1050,7 @@ public class cgBase { return caches; } - public cgCacheWrap parseCache(String page, int reason) { + public static cgCacheWrap parseCache(final String page, final int reason) { if (StringUtils.isBlank(page)) { Log.e(Settings.tag, "cgeoBase.parseCache: No page given"); return null; @@ -1523,7 +1523,7 @@ public class cgBase { * @param cache * the cache object to put the logs in */ - private void loadLogsFromDetails(final String page, final cgCache cache) { + private static void loadLogsFromDetails(final String page, final cgCache cache) { final Matcher userTokenMatcher = patternUserToken.matcher(page); if (!userTokenMatcher.find()) { Log.e(Settings.tag, "cgBase.loadLogsFromDetails: unable to extract userToken"); @@ -1644,7 +1644,7 @@ public class cgBase { } } - public Date parseGcCustomDate(final String input) + public static Date parseGcCustomDate(final String input) throws ParseException { if (StringUtils.isBlank(input)) @@ -1675,7 +1675,7 @@ public class cgBase { throw new ParseException("No matching pattern", 0); } - public void detectGcCustomDate() + public static void detectGcCustomDate() { final String result = getResponseData(request("http://www.geocaching.com/account/ManagePreferences.aspx", null, false, false, false)); @@ -2051,7 +2051,7 @@ public class cgBase { return trackables; } - public String getHumanDistance(final Float distance) { + public static String getHumanDistance(final Float distance) { if (distance == null) { return "?"; } @@ -2380,7 +2380,7 @@ public class cgBase { return page; } - public List<cgUser> getGeocachersInViewport(String username, Double latMin, Double latMax, Double lonMin, Double lonMax) { + public static List<cgUser> getGeocachersInViewport(final String username, final Double latMin, final Double latMax, final Double lonMin, final Double lonMax) { final List<cgUser> users = new ArrayList<cgUser>(); if (username == null) { @@ -2499,7 +2499,7 @@ public class cgBase { return trackable; } - public int postLog(final cgeoapplication app, final String geocode, final String cacheid, final String[] viewstates, + public static int postLog(final cgeoapplication app, final String geocode, final String cacheid, final String[] viewstates, final int logType, final int year, final int month, final int day, final String log, final List<cgTrackableLog> trackables) { if (isEmpty(viewstates)) { @@ -2658,7 +2658,7 @@ public class cgBase { return 1000; } - public int postLogTrackable(final String tbid, final String trackingCode, final String[] viewstates, + public static int postLogTrackable(final String tbid, final String trackingCode, final String[] viewstates, final int logType, final int year, final int month, final int day, final String log) { if (isEmpty(viewstates)) { Log.e(Settings.tag, "cgeoBase.postLogTrackable: No viewstate given"); @@ -2739,7 +2739,7 @@ public class cgBase { * the cache to add * @return -1: error occured */ - public int addToWatchlist(cgCache cache) { + public static int addToWatchlist(final cgCache cache) { final String uri = "http://www.geocaching.com/my/watchlist.aspx?w=" + cache.cacheId; String page = postRequestLogged(uri); @@ -2765,7 +2765,7 @@ public class cgBase { * the cache to remove * @return -1: error occured */ - public int removeFromWatchlist(cgCache cache) { + public static int removeFromWatchlist(final cgCache cache) { final String uri = "http://www.geocaching.com/my/watchlist.aspx?ds=1&action=rem&id=" + cache.cacheId; String page = postRequestLogged(uri); @@ -2899,7 +2899,7 @@ public class cgBase { } } - public String postRequestLogged(final String uri) { + public static String postRequestLogged(final String uri) { final String data = getResponseData(postRequest(uri, null)); if (!checkLogin(data)) { if (login() == 1) { @@ -2911,7 +2911,7 @@ public class cgBase { return data; } - public String requestLogged(final String uri, final Parameters params, boolean xContentType, boolean my, boolean addF) { + public static String requestLogged(final String uri, final Parameters params, boolean xContentType, boolean my, boolean addF) { HttpResponse response = request(uri, params, xContentType, my, addF); String data = getResponseData(response); @@ -2961,7 +2961,7 @@ public class cgBase { cookieStore.clear(); } - public HttpResponse postRequest(final String uri, final List<? extends NameValuePair> params) { + public static HttpResponse postRequest(final String uri, final List<? extends NameValuePair> params) { try { HttpPost request = new HttpPost(uri); if (params != null) { @@ -3503,7 +3503,7 @@ public class cgBase { return false; } - public String getMapUserToken(Handler noTokenHandler) { + public static String getMapUserToken(final Handler noTokenHandler) { final HttpResponse response = request("http://www.geocaching.com/map/default.aspx", null, false); final String data = getResponseData(response); String usertoken = null; @@ -3623,15 +3623,6 @@ public class cgBase { } /** - * TODO This method is only needed until the settings are a singleton - * - * @return - */ - public String getUserName() { - return Settings.getUsername(); - } - - /** * insert text into the EditText at the current cursor position * * @param editText diff --git a/main/src/cgeo/geocaching/cgDistanceView.java b/main/src/cgeo/geocaching/cgDistanceView.java index ebdfe78..33db51e 100644 --- a/main/src/cgeo/geocaching/cgDistanceView.java +++ b/main/src/cgeo/geocaching/cgDistanceView.java @@ -31,11 +31,11 @@ public class cgDistanceView extends TextView { if (cacheCoords == null || coords == null || base == null) { return; } - setText(base.getHumanDistance(coords.distanceTo(cacheCoords))); + setText(cgBase.getHumanDistance(coords.distanceTo(cacheCoords))); } public void setDistance(Float distance) { - setText("~" + base.getHumanDistance(distance)); + setText("~" + cgBase.getHumanDistance(distance)); } public void clear() { diff --git a/main/src/cgeo/geocaching/cgGeo.java b/main/src/cgeo/geocaching/cgGeo.java index e105c03..f54ece2 100644 --- a/main/src/cgeo/geocaching/cgGeo.java +++ b/main/src/cgeo/geocaching/cgGeo.java @@ -397,7 +397,7 @@ public class cgGeo { if (base.version != null) { params.put("v", base.version); } - final String res = cgBase.getResponseData(base.postRequest("http://api.go4cache.com/", params)); + final String res = cgBase.getResponseData(cgBase.postRequest("http://api.go4cache.com/", params)); if (StringUtils.isNotBlank(res)) { lastGo4cacheCoords = coordsNow; diff --git a/main/src/cgeo/geocaching/cgeo.java b/main/src/cgeo/geocaching/cgeo.java index 68292e0..d68d07a 100644 --- a/main/src/cgeo/geocaching/cgeo.java +++ b/main/src/cgeo/geocaching/cgeo.java @@ -730,11 +730,11 @@ public class cgeo extends AbstractActivity { return; } - int status = base.login(); + final int status = cgBase.login(); if (status == 1) { app.firstRun = false; - base.detectGcCustomDate(); + cgBase.detectGcCustomDate(); } if (app.showLoginToast) { diff --git a/main/src/cgeo/geocaching/cgeodetail.java b/main/src/cgeo/geocaching/cgeodetail.java index 1d47e7d..cace929 100644 --- a/main/src/cgeo/geocaching/cgeodetail.java +++ b/main/src/cgeo/geocaching/cgeodetail.java @@ -746,7 +746,7 @@ public class cgeodetail extends AbstractActivity { itemName.setText(res.getString(R.string.cache_distance)); if (cache.distance != null) { - itemValue.setText("~" + base.getHumanDistance(cache.distance)); + itemValue.setText("~" + cgBase.getHumanDistance(cache.distance)); } else { itemValue.setText("--"); } @@ -1070,7 +1070,7 @@ public class cgeodetail extends AbstractActivity { } if (geo != null && geo.coordsNow != null && cache != null && cache.coords != null) { - cacheDistance.setText(base.getHumanDistance(geo.coordsNow.distanceTo(cache.coords))); + cacheDistance.setText(cgBase.getHumanDistance(geo.coordsNow.distanceTo(cache.coords))); cacheDistance.bringToFront(); } } catch (Exception e) { @@ -1623,7 +1623,7 @@ public class cgeodetail extends AbstractActivity { StringBuilder dist = new StringBuilder(); if (geo.coordsNow != null && cache != null && cache.coords != null) { - dist.append(base.getHumanDistance(geo.coordsNow.distanceTo(cache.coords))); + dist.append(cgBase.getHumanDistance(geo.coordsNow.distanceTo(cache.coords))); } if (cache != null && cache.elevation != null) { @@ -1834,7 +1834,7 @@ public class cgeodetail extends AbstractActivity { @Override public void run() { - handler.sendEmptyMessage(base.addToWatchlist(cache)); + handler.sendEmptyMessage(cgBase.addToWatchlist(cache)); } } @@ -1848,7 +1848,7 @@ public class cgeodetail extends AbstractActivity { @Override public void run() { - handler.sendEmptyMessage(base.removeFromWatchlist(cache)); + handler.sendEmptyMessage(cgBase.removeFromWatchlist(cache)); } } diff --git a/main/src/cgeo/geocaching/cgeoinit.java b/main/src/cgeo/geocaching/cgeoinit.java index f098065..e92ba6b 100644 --- a/main/src/cgeo/geocaching/cgeoinit.java +++ b/main/src/cgeo/geocaching/cgeoinit.java @@ -688,10 +688,10 @@ public class cgeoinit extends AbstractActivity { @Override public void run() { - final int loginResult = base.login(); + final int loginResult = cgBase.login(); if (1 == loginResult) { - base.detectGcCustomDate(); + cgBase.detectGcCustomDate(); } logInHandler.sendEmptyMessage(loginResult); } diff --git a/main/src/cgeo/geocaching/cgeonavigate.java b/main/src/cgeo/geocaching/cgeonavigate.java index 420b697..838bcc3 100644 --- a/main/src/cgeo/geocaching/cgeonavigate.java +++ b/main/src/cgeo/geocaching/cgeonavigate.java @@ -330,7 +330,7 @@ public class cgeonavigate extends AbstractActivity { } cacheHeading = geo.coordsNow.bearingTo(dstCoords); - distanceView.setText(base.getHumanDistance(geo.coordsNow.distanceTo(dstCoords))); + distanceView.setText(cgBase.getHumanDistance(geo.coordsNow.distanceTo(dstCoords))); headingView.setText(String.format(Locale.getDefault(), "%.0f", cacheHeading) + "°"); } diff --git a/main/src/cgeo/geocaching/cgeopopup.java b/main/src/cgeo/geocaching/cgeopopup.java index 502280b..ed963bd 100644 --- a/main/src/cgeo/geocaching/cgeopopup.java +++ b/main/src/cgeo/geocaching/cgeopopup.java @@ -514,7 +514,7 @@ public class cgeopopup extends AbstractActivity { try { if (geo.coordsNow != null && cache != null && cache.coords != null) { - cacheDistance.setText(base.getHumanDistance(geo.coordsNow.distanceTo(cache.coords))); + cacheDistance.setText(cgBase.getHumanDistance(geo.coordsNow.distanceTo(cache.coords))); cacheDistance.bringToFront(); } } catch (Exception e) { diff --git a/main/src/cgeo/geocaching/cgeotouch.java b/main/src/cgeo/geocaching/cgeotouch.java index d46108e..9a2ddb3 100644 --- a/main/src/cgeo/geocaching/cgeotouch.java +++ b/main/src/cgeo/geocaching/cgeotouch.java @@ -448,7 +448,7 @@ public class cgeotouch extends cgLogForm { tweetCheck = (CheckBox) findViewById(R.id.tweet); } - status = base.postLogTrackable(guid, tracking, viewstates, typeSelected, date.get(Calendar.YEAR), (date.get(Calendar.MONTH) + 1), date.get(Calendar.DATE), log); + status = cgBase.postLogTrackable(guid, tracking, viewstates, typeSelected, date.get(Calendar.YEAR), (date.get(Calendar.MONTH) + 1), date.get(Calendar.DATE), log); if (status == 1 && Settings.isUseTwitter() && Settings.isTwitterLoginValid() && diff --git a/main/src/cgeo/geocaching/cgeotrackable.java b/main/src/cgeo/geocaching/cgeotrackable.java index 0f8da92..a10a8ce 100644 --- a/main/src/cgeo/geocaching/cgeotrackable.java +++ b/main/src/cgeo/geocaching/cgeotrackable.java @@ -218,7 +218,7 @@ public class cgeotrackable extends AbstractActivity { itemValue = (TextView) itemLayout.findViewById(R.id.value); itemName.setText(res.getString(R.string.trackable_distance)); - itemValue.setText(base.getHumanDistance(trackable.distance)); + itemValue.setText(cgBase.getHumanDistance(trackable.distance)); detailsList.addView(itemLayout); } diff --git a/main/src/cgeo/geocaching/cgeovisit.java b/main/src/cgeo/geocaching/cgeovisit.java index 6a5ca09..f22203c 100644 --- a/main/src/cgeo/geocaching/cgeovisit.java +++ b/main/src/cgeo/geocaching/cgeovisit.java @@ -736,7 +736,7 @@ public class cgeovisit extends cgLogForm { tweetCheck = (CheckBox) findViewById(R.id.tweet); } - status = base.postLog(app, geocode, cacheid, viewstates, typeSelected, + status = cgBase.postLog(app, geocode, cacheid, viewstates, typeSelected, date.get(Calendar.YEAR), (date.get(Calendar.MONTH) + 1), date.get(Calendar.DATE), log, trackables); diff --git a/main/src/cgeo/geocaching/connector/GCConnector.java b/main/src/cgeo/geocaching/connector/GCConnector.java index ea4ca45..bd5e196 100644 --- a/main/src/cgeo/geocaching/connector/GCConnector.java +++ b/main/src/cgeo/geocaching/connector/GCConnector.java @@ -1,11 +1,11 @@ package cgeo.geocaching.connector; import cgeo.geocaching.Parameters; +import cgeo.geocaching.Settings; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgCacheWrap; import cgeo.geocaching.cgSearch; -import cgeo.geocaching.Settings; import cgeo.geocaching.cgeoapplication; import org.apache.commons.lang3.StringUtils; @@ -73,7 +73,7 @@ public class GCConnector extends AbstractConnector implements IConnector { params.put("guid", guid); } - String page = base.requestLogged("http://www.geocaching.com/seek/cache_details.aspx", params, false, false, false); + String page = cgBase.requestLogged("http://www.geocaching.com/seek/cache_details.aspx", params, false, false, false); if (StringUtils.isEmpty(page)) { if (app.isThere(geocode, guid, true, false)) { @@ -99,7 +99,7 @@ public class GCConnector extends AbstractConnector implements IConnector { return null; } - final cgCacheWrap caches = base.parseCache(page, reason); + final cgCacheWrap caches = cgBase.parseCache(page, reason); if (caches == null || caches.cacheList == null || caches.cacheList.isEmpty()) { if (caches != null && StringUtils.isNotBlank(caches.error)) { search.error = caches.error; diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index e14bdec..481ae62 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -1,13 +1,13 @@ package cgeo.geocaching.maps; import cgeo.geocaching.R; +import cgeo.geocaching.Settings; +import cgeo.geocaching.Settings.mapSourceEnum; import cgeo.geocaching.cgBase; import cgeo.geocaching.cgCache; import cgeo.geocaching.cgCoord; import cgeo.geocaching.cgDirection; import cgeo.geocaching.cgGeo; -import cgeo.geocaching.Settings; -import cgeo.geocaching.Settings.mapSourceEnum; import cgeo.geocaching.cgUpdateDir; import cgeo.geocaching.cgUpdateLoc; import cgeo.geocaching.cgUser; @@ -1208,7 +1208,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory //this should just fetch and insert into the db _and_ be cancel-able if the viewport changes if (token == null) { - token = base.getMapUserToken(noMapTokenHandler); + token = cgBase.getMapUserToken(noMapTokenHandler); } if (stop) { @@ -1414,7 +1414,7 @@ public class CGeoMap extends AbstractMap implements OnDragListener, ViewFactory lonMin = llCache; } - users = base.getGeocachersInViewport(Settings.getUsername(), latMin, latMax, lonMin, lonMax); + users = cgBase.getGeocachersInViewport(Settings.getUsername(), latMin, latMax, lonMin, lonMax); if (stop) { return; |
