diff options
author | Samuel Tardieu <sam@rfc1149.net> | 2012-04-17 14:00:24 +0200 |
---|---|---|
committer | Samuel Tardieu <sam@rfc1149.net> | 2012-04-17 14:00:24 +0200 |
commit | 7e64bf85d832430172f88b3a1bbd691d6935f097 (patch) | |
tree | 0a5a5677fec386514fc88f2629817329c609d5fa /main/src | |
parent | 3882c655f50b2d6d22050eea9e54176704d15b4c (diff) | |
download | cgeo-7e64bf85d832430172f88b3a1bbd691d6935f097.zip cgeo-7e64bf85d832430172f88b3a1bbd691d6935f097.tar.gz cgeo-7e64bf85d832430172f88b3a1bbd691d6935f097.tar.bz2 |
Refactoring: rename request into getRequest
Those methods only do GET requests.
Diffstat (limited to 'main/src')
-rw-r--r-- | main/src/cgeo/geocaching/StaticMapsProvider.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/VisitCacheActivity.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgBase.java | 8 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeocaches.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeoinit.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/cgeotouch.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCBase.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCConnector.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/connector/gc/Tile.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/gcvote/GCVote.java | 4 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/network/HtmlImage.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/network/Login.java | 12 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/network/Network.java | 27 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/ui/DirectionImage.java | 2 | ||||
-rw-r--r-- | main/src/cgeo/geocaching/utils/LogTemplateProvider.java | 2 |
16 files changed, 37 insertions, 40 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java index 4942b1a..fc55949 100644 --- a/main/src/cgeo/geocaching/StaticMapsProvider.java +++ b/main/src/cgeo/geocaching/StaticMapsProvider.java @@ -50,7 +50,7 @@ public class StaticMapsProvider { if (waypoints != null) { params.addAll(waypoints); } - final HttpResponse httpResponse = Network.request(mapUrl, params); + final HttpResponse httpResponse = Network.getRequest(mapUrl, params); if (httpResponse != null) { final File file = getMapFile(cache.getGeocode(), prefix, level, true); diff --git a/main/src/cgeo/geocaching/VisitCacheActivity.java b/main/src/cgeo/geocaching/VisitCacheActivity.java index 4a8e8fb..fdfe4bd 100644 --- a/main/src/cgeo/geocaching/VisitCacheActivity.java +++ b/main/src/cgeo/geocaching/VisitCacheActivity.java @@ -656,7 +656,7 @@ public class VisitCacheActivity extends AbstractActivity implements DateDialog.D return; } - final String page = Network.getResponseData(Network.request("http://www.geocaching.com/seek/log.aspx", params)); + final String page = Network.getResponseData(Network.getRequest("http://www.geocaching.com/seek/log.aspx", params)); viewstates = Login.getViewstates(page); trackables = cgBase.parseTrackableLog(page); diff --git a/main/src/cgeo/geocaching/cgBase.java b/main/src/cgeo/geocaching/cgBase.java index fd6f326..3df00d7 100644 --- a/main/src/cgeo/geocaching/cgBase.java +++ b/main/src/cgeo/geocaching/cgBase.java @@ -143,7 +143,7 @@ public class cgBase { if (recaptchaJsParam != null) { final Parameters params = new Parameters("k", recaptchaJsParam.trim()); - final String recaptchaJs = Network.getResponseData(Network.request("http://www.google.com/recaptcha/api/challenge", params)); + final String recaptchaJs = Network.getResponseData(Network.getRequest("http://www.google.com/recaptcha/api/challenge", params)); if (StringUtils.isNotBlank(recaptchaJs)) { recaptchaChallenge = BaseUtils.getMatch(recaptchaJs, GCConstants.PATTERN_SEARCH_RECAPTCHACHALLENGE, true, 1, null, true); @@ -853,7 +853,7 @@ public class cgBase { // "sp", Boolean.toString(personal), // personal logs "sf", Boolean.toString(friends)); - final HttpResponse response = Network.request("http://www.geocaching.com/seek/geocache.logbook", params); + final HttpResponse response = Network.getRequest("http://www.geocaching.com/seek/geocache.logbook", params); if (response == null) { Log.e("cgBase.loadLogsFromDetails: cannot log logs, response is null"); return null; @@ -1359,7 +1359,7 @@ public class cgBase { final String uri = "http://www.geocaching.com/seek/nearest.aspx"; final String fullUri = uri + "?" + addFToParams(params, false, true); - final String page = Network.requestLogged(uri, addFToParams(params, my, true)); + final String page = Network.getRequestLogged(uri, addFToParams(params, my, true)); if (StringUtils.isBlank(page)) { Log.e("cgeoBase.searchByAny: No data from server"); @@ -1439,7 +1439,7 @@ public class cgBase { params.put("id", id); } - final String page = Network.requestLogged("http://www.geocaching.com/track/details.aspx", params); + final String page = Network.getRequestLogged("http://www.geocaching.com/track/details.aspx", params); if (StringUtils.isBlank(page)) { Log.e("cgeoBase.searchTrackable: No data from server"); diff --git a/main/src/cgeo/geocaching/cgeocaches.java b/main/src/cgeo/geocaching/cgeocaches.java index 23eeec4..e7005f1 100644 --- a/main/src/cgeo/geocaching/cgeocaches.java +++ b/main/src/cgeo/geocaching/cgeocaches.java @@ -1767,7 +1767,7 @@ public class cgeocaches extends AbstractListActivity { deviceCode = ""; } final Parameters params = new Parameters("code", deviceCode); - HttpResponse responseFromWeb = Network.request("http://send2.cgeo.org/read.html", params); + HttpResponse responseFromWeb = Network.getRequest("http://send2.cgeo.org/read.html", params); if (responseFromWeb != null && responseFromWeb.getStatusLine().getStatusCode() == 200) { final String response = Network.getResponseData(responseFromWeb); diff --git a/main/src/cgeo/geocaching/cgeoinit.java b/main/src/cgeo/geocaching/cgeoinit.java index c7f959f..3a37a50 100644 --- a/main/src/cgeo/geocaching/cgeoinit.java +++ b/main/src/cgeo/geocaching/cgeoinit.java @@ -864,7 +864,7 @@ public class cgeoinit extends AbstractActivity { final String cod = StringUtils.defaultString(deviceCode); final Parameters params = new Parameters("name", nam, "code", cod); - HttpResponse response = Network.request("http://send2.cgeo.org/auth.html", params); + HttpResponse response = Network.getRequest("http://send2.cgeo.org/auth.html", params); if (response != null && response.getStatusLine().getStatusCode() == 200) { diff --git a/main/src/cgeo/geocaching/cgeotouch.java b/main/src/cgeo/geocaching/cgeotouch.java index 78d5746..8245aea 100644 --- a/main/src/cgeo/geocaching/cgeotouch.java +++ b/main/src/cgeo/geocaching/cgeotouch.java @@ -392,7 +392,7 @@ public class cgeotouch extends AbstractActivity implements DateDialog.DateDialog return; } - final String page = Network.getResponseData(Network.request("http://www.geocaching.com/track/log.aspx", params)); + final String page = Network.getResponseData(Network.getRequest("http://www.geocaching.com/track/log.aspx", params)); viewstates = Login.getViewstates(page); diff --git a/main/src/cgeo/geocaching/connector/gc/GCBase.java b/main/src/cgeo/geocaching/connector/gc/GCBase.java index 53b5640..c5ee29d 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCBase.java +++ b/main/src/cgeo/geocaching/connector/gc/GCBase.java @@ -361,7 +361,7 @@ public class GCBase { /** Get user session & session token from the Live Map. Needed for following requests */ public static String[] getTokens() { - final HttpResponse response = Network.request(GCConstants.URL_LIVE_MAP); + final HttpResponse response = Network.getRequest(GCConstants.URL_LIVE_MAP); final String data = Network.getResponseData(response); String userSession = BaseUtils.getMatch(data, GCConstants.PATTERN_USERSESSION, ""); String sessionToken = BaseUtils.getMatch(data, GCConstants.PATTERN_SESSIONTOKEN, ""); diff --git a/main/src/cgeo/geocaching/connector/gc/GCConnector.java b/main/src/cgeo/geocaching/connector/gc/GCConnector.java index 06bf728..e68f9a2 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCConnector.java +++ b/main/src/cgeo/geocaching/connector/gc/GCConnector.java @@ -104,7 +104,7 @@ public class GCConnector extends AbstractConnector { cgBase.sendLoadProgressDetail(handler, R.string.cache_dialog_loading_details_status_loadpage); - final String page = Network.requestLogged("http://www.geocaching.com/seek/cache_details.aspx", params); + final String page = Network.getRequestLogged("http://www.geocaching.com/seek/cache_details.aspx", params); if (StringUtils.isEmpty(page)) { final SearchResult search = new SearchResult(); diff --git a/main/src/cgeo/geocaching/connector/gc/Tile.java b/main/src/cgeo/geocaching/connector/gc/Tile.java index 272bf28..289c9db 100644 --- a/main/src/cgeo/geocaching/connector/gc/Tile.java +++ b/main/src/cgeo/geocaching/connector/gc/Tile.java @@ -208,12 +208,12 @@ public class Tile { /** Request JSON informations for a tile */ public static String requestMapInfo(final String url, final Parameters params, final String referer) { - return Network.getResponseData(Network.request(url, params, new Parameters("Referer", referer))); + return Network.getResponseData(Network.getRequest(url, params, new Parameters("Referer", referer))); } /** Request .png image for a tile. */ public static Bitmap requestMapTile(final String url, final Parameters params, final String referer) { - final HttpResponse response = Network.request(url, params, new Parameters("Referer", referer)); + final HttpResponse response = Network.getRequest(url, params, new Parameters("Referer", referer)); try { return response != null ? BitmapFactory.decodeStream(response.getEntity().getContent()) : null; } catch (IOException e) { diff --git a/main/src/cgeo/geocaching/gcvote/GCVote.java b/main/src/cgeo/geocaching/gcvote/GCVote.java index 39e6a39..070be09 100644 --- a/main/src/cgeo/geocaching/gcvote/GCVote.java +++ b/main/src/cgeo/geocaching/gcvote/GCVote.java @@ -95,7 +95,7 @@ public final class GCVote { params.put("waypoints", StringUtils.join(geocodes.toArray(), ',')); } params.put("version", "cgeo"); - final String page = Network.getResponseData(Network.request("http://gcvote.com/getVotes.php", params)); + final String page = Network.getResponseData(Network.getRequest("http://gcvote.com/getVotes.php", params)); if (page == null) { return null; } @@ -219,7 +219,7 @@ public final class GCVote { "voteUser", String.format("%.1f", vote).replace(',', '.'), "version", "cgeo"); - final String result = Network.getResponseData(Network.request("http://gcvote.com/setVote.php", params)); + final String result = Network.getResponseData(Network.getRequest("http://gcvote.com/setVote.php", params)); return result.trim().equalsIgnoreCase("ok"); } diff --git a/main/src/cgeo/geocaching/network/HtmlImage.java b/main/src/cgeo/geocaching/network/HtmlImage.java index 37c7486..b6be931 100644 --- a/main/src/cgeo/geocaching/network/HtmlImage.java +++ b/main/src/cgeo/geocaching/network/HtmlImage.java @@ -80,7 +80,7 @@ public class HtmlImage implements Html.ImageGetter { if (absoluteURL != null) { try { final File file = LocalStorage.getStorageFile(geocode, url, true, true); - final HttpResponse httpResponse = Network.request(absoluteURL, null, file); + final HttpResponse httpResponse = Network.getRequest(absoluteURL, null, file); if (httpResponse != null) { final int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode == 200) { diff --git a/main/src/cgeo/geocaching/network/Login.java b/main/src/cgeo/geocaching/network/Login.java index 3eca55d..827bf96 100644 --- a/main/src/cgeo/geocaching/network/Login.java +++ b/main/src/cgeo/geocaching/network/Login.java @@ -69,7 +69,7 @@ public abstract class Login { if (cgBase.res != null) { Login.setActualStatus(cgBase.res.getString(R.string.init_login_popup_working)); } - HttpResponse loginResponse = Network.request("https://www.geocaching.com/login/default.aspx"); + HttpResponse loginResponse = Network.getRequest("https://www.geocaching.com/login/default.aspx"); String loginData = Network.getResponseData(loginResponse); if (loginResponse != null && loginResponse.getStatusLine().getStatusCode() == 503 && BaseUtils.matches(loginData, GCConstants.PATTERN_MAINTENANCE)) { return StatusCode.MAINTENANCE; @@ -131,7 +131,7 @@ public abstract class Login { } public static StatusCode logout() { - HttpResponse logoutResponse = Network.request("https://www.geocaching.com/login/default.aspx?RESET=Y&redir=http%3a%2f%2fwww.geocaching.com%2fdefault.aspx%3f"); + HttpResponse logoutResponse = Network.getRequest("https://www.geocaching.com/login/default.aspx?RESET=Y&redir=http%3a%2f%2fwww.geocaching.com%2fdefault.aspx%3f"); String logoutData = Network.getResponseData(logoutResponse); if (logoutResponse != null && logoutResponse.getStatusLine().getStatusCode() == 503 && BaseUtils.matches(logoutData, GCConstants.PATTERN_MAINTENANCE)) { return StatusCode.MAINTENANCE; @@ -218,9 +218,9 @@ public abstract class Login { if (previousPage != null && previousPage.indexOf(ENGLISH) >= 0) { Log.i("Geocaching.com language already set to English"); // get find count - getLoginStatus(Network.getResponseData(Network.request("http://www.geocaching.com/email/"))); + getLoginStatus(Network.getResponseData(Network.getRequest("http://www.geocaching.com/email/"))); } else { - final String page = Network.getResponseData(Network.request("http://www.geocaching.com/default.aspx")); + final String page = Network.getResponseData(Network.getRequest("http://www.geocaching.com/default.aspx")); getLoginStatus(page); if (page == null) { Log.e("Failed to read viewstates to set geocaching.com language"); @@ -238,7 +238,7 @@ public abstract class Login { public static BitmapDrawable downloadAvatarAndGetMemberStatus(final Context context) { try { - final String profile = BaseUtils.replaceWhitespace(Network.getResponseData(Network.request("http://www.geocaching.com/my/"))); + final String profile = BaseUtils.replaceWhitespace(Network.getResponseData(Network.getRequest("http://www.geocaching.com/my/"))); Settings.setMemberStatus(BaseUtils.getMatch(profile, GCConstants.PATTERN_MEMBER_STATUS, true, null)); @@ -262,7 +262,7 @@ public abstract class Login { */ public static void detectGcCustomDate() { - final String result = Network.getResponseData(Network.request("http://www.geocaching.com/account/ManagePreferences.aspx")); + final String result = Network.getResponseData(Network.getRequest("http://www.geocaching.com/account/ManagePreferences.aspx")); if (null == result) { Log.w("cgeoBase.detectGcCustomDate: result is null"); diff --git a/main/src/cgeo/geocaching/network/Network.java b/main/src/cgeo/geocaching/network/Network.java index 31ddb2a..7427fd4 100644 --- a/main/src/cgeo/geocaching/network/Network.java +++ b/main/src/cgeo/geocaching/network/Network.java @@ -197,7 +197,7 @@ public abstract class Network { * the headers to add to the GET request * @return the HTTP response */ - public static HttpResponse request(final String uri, final Parameters params, final Parameters headers) { + public static HttpResponse getRequest(final String uri, final Parameters params, final Parameters headers) { final String fullUri = params == null ? uri : Uri.parse(uri).buildUpon().encodedQuery(params.toString()).build().toString(); final HttpRequestBase request = new HttpGet(fullUri); @@ -222,20 +222,20 @@ public abstract class Network { * the name of the file storing the cached resource, or null not to use one * @return the HTTP response */ - public static HttpResponse request(final String uri, final Parameters params, final File cacheFile) { + public static HttpResponse getRequest(final String uri, final Parameters params, final File cacheFile) { if (cacheFile != null && cacheFile.exists()) { final String etag = LocalStorage.getSavedHeader(cacheFile, "etag"); if (etag != null) { - return request(uri, params, new Parameters("If-None-Match", etag)); + return getRequest(uri, params, new Parameters("If-None-Match", etag)); } else { final String lastModified = LocalStorage.getSavedHeader(cacheFile, "last-modified"); if (lastModified != null) { - return request(uri, params, new Parameters("If-Modified-Since", lastModified)); + return getRequest(uri, params, new Parameters("If-Modified-Since", lastModified)); } } } - return request(uri, params, (Parameters) null); + return getRequest(uri, params, (Parameters) null); } /** @@ -247,8 +247,8 @@ public abstract class Network { * the parameters to add the the GET request * @return the HTTP response */ - public static HttpResponse request(final String uri, final Parameters params) { - return request(uri, params, (Parameters) null); + public static HttpResponse getRequest(final String uri, final Parameters params) { + return getRequest(uri, params, (Parameters) null); } /** @@ -258,8 +258,8 @@ public abstract class Network { * the URI to request * @return the HTTP response */ - public static HttpResponse request(final String uri) { - return request(uri, null, (Parameters) null); + public static HttpResponse getRequest(final String uri) { + return getRequest(uri, null, (Parameters) null); } public static HttpResponse request(final HttpRequestBase request) { @@ -377,17 +377,14 @@ public abstract class Network { * * @param uri * @param params - * @param xContentType * @return */ - public static String requestLogged(final String uri, final Parameters params) { - HttpResponse response = request(uri, params); - String data = getResponseData(response); + public static String getRequestLogged(final String uri, final Parameters params) { + final String data = getResponseData(getRequest(uri, params)); if (!Login.getLoginStatus(data)) { if (Login.login() == StatusCode.NO_ERROR) { - response = request(uri, params); - data = getResponseData(response); + return getResponseData(getRequest(uri, params)); } else { Log.i("Working as guest."); } diff --git a/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java b/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java index 1419f5d..86db2d2 100644 --- a/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java +++ b/main/src/cgeo/geocaching/twitter/TwitterAuthorizationActivity.java @@ -141,7 +141,7 @@ public class TwitterAuthorizationActivity extends AbstractActivity { try { final Parameters params = new Parameters(); OAuth.signOAuth(host, pathRequest, method, true, params, null, null); - final String line = Network.getResponseData(Network.request("https://" + host + pathRequest, params)); + final String line = Network.getResponseData(Network.getRequest("https://" + host + pathRequest, params)); if (StringUtils.isNotBlank(line)) { diff --git a/main/src/cgeo/geocaching/ui/DirectionImage.java b/main/src/cgeo/geocaching/ui/DirectionImage.java index 92ed64d..b246718 100644 --- a/main/src/cgeo/geocaching/ui/DirectionImage.java +++ b/main/src/cgeo/geocaching/ui/DirectionImage.java @@ -17,7 +17,7 @@ public class DirectionImage { } final HttpResponse httpResponse = - Network.request("http://www.geocaching.com/ImgGen/seek/CacheDir.ashx", new Parameters("k", code)); + Network.getRequest("http://www.geocaching.com/ImgGen/seek/CacheDir.ashx", new Parameters("k", code)); if (httpResponse != null) { LocalStorage.saveEntityToFile(httpResponse, getDirectionFile(geocode, true)); } diff --git a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java index fa4fa4e..8010c83 100644 --- a/main/src/cgeo/geocaching/utils/LogTemplateProvider.java +++ b/main/src/cgeo/geocaching/utils/LogTemplateProvider.java @@ -89,7 +89,7 @@ public class LogTemplateProvider { if (offline) { return ""; } - final String page = Network.getResponseData(Network.request("http://www.geocaching.com/email/")); + final String page = Network.getResponseData(Network.getRequest("http://www.geocaching.com/email/")); current = parseFindCount(page); } |