aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/network
diff options
context:
space:
mode:
authorSamuel Tardieu <sam@rfc1149.net>2012-04-17 14:00:24 +0200
committerSamuel Tardieu <sam@rfc1149.net>2012-04-17 14:00:24 +0200
commit7e64bf85d832430172f88b3a1bbd691d6935f097 (patch)
tree0a5a5677fec386514fc88f2629817329c609d5fa /main/src/cgeo/geocaching/network
parent3882c655f50b2d6d22050eea9e54176704d15b4c (diff)
downloadcgeo-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/cgeo/geocaching/network')
-rw-r--r--main/src/cgeo/geocaching/network/HtmlImage.java2
-rw-r--r--main/src/cgeo/geocaching/network/Login.java12
-rw-r--r--main/src/cgeo/geocaching/network/Network.java27
3 files changed, 19 insertions, 22 deletions
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.");
}