diff options
| author | Samuel Tardieu <sam@rfc1149.net> | 2013-12-28 12:15:52 +0100 |
|---|---|---|
| committer | Samuel Tardieu <sam@rfc1149.net> | 2013-12-28 12:15:52 +0100 |
| commit | 5e9d1008080b67808bc19ddec3880670a8992ee7 (patch) | |
| tree | 8b49f1f5b51ebcfbba1b30a9c11b13c79b09ea25 /main/src | |
| parent | 40e9c8a2c70c40b382ab127736a23e2b51dfdf4d (diff) | |
| download | cgeo-5e9d1008080b67808bc19ddec3880670a8992ee7.zip cgeo-5e9d1008080b67808bc19ddec3880670a8992ee7.tar.gz cgeo-5e9d1008080b67808bc19ddec3880670a8992ee7.tar.bz2 | |
fix #3485: requests to gc.com although deactivated
Also, refactor code so that the login request (if needed) done when
retrieving the map tokens is done directly from the connector.
Diffstat (limited to 'main/src')
| -rw-r--r-- | main/src/cgeo/geocaching/connector/gc/GCLogin.java | 5 | ||||
| -rw-r--r-- | main/src/cgeo/geocaching/maps/CGeoMap.java | 20 |
2 files changed, 7 insertions, 18 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCLogin.java b/main/src/cgeo/geocaching/connector/gc/GCLogin.java index e072c8f..7f23bf6 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCLogin.java +++ b/main/src/cgeo/geocaching/connector/gc/GCLogin.java @@ -473,10 +473,9 @@ public class GCLogin extends AbstractLogin { * * @return first is user session, second is session token */ - public static @NonNull + public @NonNull MapTokens getMapTokens() { - final HttpResponse response = Network.getRequest(GCConstants.URL_LIVE_MAP); - final String data = Network.getResponseData(response); + final String data = getRequestLogged(GCConstants.URL_LIVE_MAP, null); final String userSession = TextUtils.getMatch(data, GCConstants.PATTERN_USERSESSION, ""); final String sessionToken = TextUtils.getMatch(data, GCConstants.PATTERN_SESSIONTOKEN, ""); return new MapTokens(userSession, sessionToken); diff --git a/main/src/cgeo/geocaching/maps/CGeoMap.java b/main/src/cgeo/geocaching/maps/CGeoMap.java index d8cad51..48be2d7 100644 --- a/main/src/cgeo/geocaching/maps/CGeoMap.java +++ b/main/src/cgeo/geocaching/maps/CGeoMap.java @@ -1161,29 +1161,19 @@ public class CGeoMap extends AbstractMap implements OnMapDragListener, ViewFacto public void run() { try { showProgressHandler.sendEmptyMessage(SHOW_PROGRESS); // show progress - - int count = 0; - SearchResult searchResult; - do { - + SearchResult searchResult = new SearchResult(); + if (Settings.isGCConnectorActive()) { if (tokens == null) { - tokens = GCLogin.getMapTokens(); + tokens = GCLogin.getInstance().getMapTokens(); if (noMapTokenHandler != null && (StringUtils.isEmpty(tokens.getUserSession()) || StringUtils.isEmpty(tokens.getSessionToken()))) { + tokens = null; noMapTokenHandler.sendEmptyMessage(0); } } searchResult = ConnectorFactory.searchByViewport(viewport.resize(0.8), tokens); downloaded = true; - if (searchResult.getError() == StatusCode.NOT_LOGGED_IN && Settings.isGCConnectorActive()) { - GCLogin.getInstance().login(); - tokens = null; - } else { - break; - } - count++; - - } while (count < 2); + } Set<Geocache> result = searchResult.getCachesFromSearchResult(LoadFlags.LOAD_CACHE_OR_DB); CGeoMap.filter(result); |
