diff options
Diffstat (limited to 'main/src/cgeo/geocaching/connector/gc')
7 files changed, 26 insertions, 47 deletions
diff --git a/main/src/cgeo/geocaching/connector/gc/GCConnector.java b/main/src/cgeo/geocaching/connector/gc/GCConnector.java index e43b9b5..3ad8117 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCConnector.java +++ b/main/src/cgeo/geocaching/connector/gc/GCConnector.java @@ -305,7 +305,8 @@ public class GCConnector extends AbstractConnector implements ISearchByGeocode, } @Override - public String getGeocodeFromUrl(final String url) { + @Nullable + public String getGeocodeFromUrl(@NonNull final String url) { // coord.info URLs String code = StringUtils.substringAfterLast(url, "coord.info/"); if (code != null && canHandle(code)) { @@ -375,7 +376,7 @@ public class GCConnector extends AbstractConnector implements ISearchByGeocode, } @Override - public String getWaypointGpxId(final String prefix, final String geocode) { + public String getWaypointGpxId(final String prefix, @NonNull final String geocode) { String gpxId = prefix; if (StringUtils.isNotBlank(geocode) && geocode.length() > 2) { gpxId += geocode.substring(2); diff --git a/main/src/cgeo/geocaching/connector/gc/GCLogin.java b/main/src/cgeo/geocaching/connector/gc/GCLogin.java index 035176b..71c31c1 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCLogin.java +++ b/main/src/cgeo/geocaching/connector/gc/GCLogin.java @@ -166,7 +166,6 @@ public class GCLogin extends AbstractLogin { /** * Check if the user has been logged in when he retrieved the data. * - * @param page * @return <code>true</code> if user is logged in, <code>false</code> otherwise */ boolean getLoginStatus(@Nullable final String page) { @@ -412,8 +411,6 @@ public class GCLogin extends AbstractLogin { /** * POST HTTP request. Do the request a second time if the user is not logged in * - * @param uri - * @return */ String postRequestLogged(final String uri, final Parameters params) { final String data = Network.getResponseData(Network.postRequest(uri, params)); @@ -433,9 +430,6 @@ public class GCLogin extends AbstractLogin { /** * GET HTTP request. Do the request a second time if the user is not logged in * - * @param uri - * @param params - * @return */ @Nullable String getRequestLogged(@NonNull final String uri, @Nullable final Parameters params) { @@ -459,8 +453,6 @@ public class GCLogin extends AbstractLogin { * Unfortunately the cache details page contains user generated whitespace in the personal note, therefore we cannot * remove the white space from cache details pages. * - * @param uri - * @return */ private static boolean canRemoveWhitespace(final String uri) { return !StringUtils.contains(uri, "cache_details"); diff --git a/main/src/cgeo/geocaching/connector/gc/GCMap.java b/main/src/cgeo/geocaching/connector/gc/GCMap.java index 1571faa..5d59613 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCMap.java +++ b/main/src/cgeo/geocaching/connector/gc/GCMap.java @@ -226,7 +226,6 @@ public class GCMap { * Area to search * @param tokens * Live map tokens - * @return */ @NonNull public static SearchResult searchByViewport(final Viewport viewport, final MapTokens tokens) { @@ -257,7 +256,6 @@ public class GCMap { * Live map tokens * @param strategy * Strategy for data retrieval and parsing, @see Strategy - * @return */ @NonNull private static SearchResult searchByViewport(final Viewport viewport, final MapTokens tokens, final Strategy strategy) { @@ -360,7 +358,6 @@ public class GCMap { * * @param typeToDisplay * - cache type to omit from exclusion list so it gets displayed - * @return * * cache types for live map filter: * 2 = traditional, 9 = ape, 5 = letterbox diff --git a/main/src/cgeo/geocaching/connector/gc/GCParser.java b/main/src/cgeo/geocaching/connector/gc/GCParser.java index f20df8d..4a8451b 100644 --- a/main/src/cgeo/geocaching/connector/gc/GCParser.java +++ b/main/src/cgeo/geocaching/connector/gc/GCParser.java @@ -57,7 +57,6 @@ import rx.functions.Action1; import rx.functions.Func0; import rx.functions.Func2; import rx.schedulers.Schedulers; -import rx.util.async.Async; import android.net.Uri; import android.text.Html; @@ -65,6 +64,7 @@ import android.text.Html; import java.io.File; import java.io.IOException; import java.io.InputStream; +import java.text.Collator; import java.text.ParseException; import java.util.ArrayList; import java.util.Calendar; @@ -304,12 +304,13 @@ public abstract class GCParser { if (!cids.isEmpty() && (Settings.isGCPremiumMember() || showCaptcha) && ((recaptchaReceiver == null || StringUtils.isBlank(recaptchaReceiver.getChallenge())) || StringUtils.isNotBlank(recaptchaText))) { Log.i("Trying to get .loc for " + cids.size() + " caches"); - final Observable<Set<Geocache>> storedCaches = Async.start(new Func0<Set<Geocache>>() { + final Observable<Set<Geocache>> storedCaches = Observable.defer(new Func0<Observable<Set<Geocache>>>() { @Override - public Set<Geocache> call() { - return DataStore.loadCaches(Geocache.getGeocodes(caches), LoadFlags.LOAD_CACHE_OR_DB); + public Observable<Set<Geocache>> call() { + return Observable.just(DataStore.loadCaches(Geocache.getGeocodes(caches), LoadFlags.LOAD_CACHE_OR_DB)); } - }, Schedulers.io()); + }).subscribeOn(Schedulers.io()).cache(); + storedCaches.subscribe(); // Force asynchronous start of database loading try { // get coordinates for parsed caches @@ -979,22 +980,22 @@ public abstract class GCParser { * Observable that fetches a list of pocket queries. Returns a single element (which may be an empty list). * Executes on the network scheduler. */ - public static final Observable<List<PocketQueryList>> searchPocketQueryListObservable = Async.fromCallable(new Func0<List<PocketQueryList>>() { + public static final Observable<List<PocketQueryList>> searchPocketQueryListObservable = Observable.defer(new Func0<Observable<List<PocketQueryList>>>() { @Override - public List<PocketQueryList> call() { + public Observable<List<PocketQueryList>> call() { final Parameters params = new Parameters(); final String page = GCLogin.getInstance().getRequestLogged("http://www.geocaching.com/pocket/default.aspx", params); if (StringUtils.isBlank(page)) { Log.e("GCParser.searchPocketQueryList: No data from server"); - return Collections.emptyList(); + return Observable.just(Collections.<PocketQueryList>emptyList()); } final String subPage = StringUtils.substringAfter(page, "class=\"PocketQueryListTable"); if (StringUtils.isEmpty(subPage)) { Log.e("GCParser.searchPocketQueryList: class \"PocketQueryListTable\" not found on page"); - return Collections.emptyList(); + return Observable.just(Collections.<PocketQueryList>emptyList()); } final List<PocketQueryList> list = new ArrayList<>(); @@ -1016,17 +1017,18 @@ public abstract class GCParser { } // just in case, lets sort the resulting list + final Collator collator = TextUtils.getCollator(); Collections.sort(list, new Comparator<PocketQueryList>() { @Override public int compare(final PocketQueryList left, final PocketQueryList right) { - return String.CASE_INSENSITIVE_ORDER.compare(left.getName(), right.getName()); + return collator.compare(left.getName(), right.getName()); } }); - return list; + return Observable.just(list); } - }, RxUtils.networkScheduler); + }).subscribeOn(RxUtils.networkScheduler); public static ImmutablePair<StatusCode, String> postLog(final String geocode, final String cacheid, final String[] viewstates, final LogType logType, final int year, final int month, final int day, diff --git a/main/src/cgeo/geocaching/connector/gc/Tile.java b/main/src/cgeo/geocaching/connector/gc/Tile.java index 93b61f9..dd6371b 100644 --- a/main/src/cgeo/geocaching/connector/gc/Tile.java +++ b/main/src/cgeo/geocaching/connector/gc/Tile.java @@ -15,7 +15,6 @@ import org.eclipse.jdt.annotation.NonNull; import rx.Observable; import rx.functions.Func0; -import rx.util.async.Async; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -144,7 +143,6 @@ public class Tile { * First point * @param right * Second point - * @return */ static int calcZoomLon(final Geopoint left, final Geopoint right, final int numberOfTiles) { @@ -177,7 +175,6 @@ public class Tile { * First point * @param top * Second point - * @return */ static int calcZoomLat(final Geopoint bottom, final Geopoint top, final int numberOfTiles) { @@ -208,8 +205,6 @@ public class Tile { * Calculates the inverted hyperbolic sine * (after Bronstein, Semendjajew: Taschenbuch der Mathematik) * - * @param x - * @return */ private static double asinh(final double x) { return Math.log(x + Math.sqrt(x * x + 1.0)); @@ -241,12 +236,12 @@ public class Tile { static Observable<String> requestMapInfo(final String url, final Parameters params, final String referer) { final HttpResponse response = Network.getRequest(url, params, new Parameters("Referer", referer)); - return Async.start(new Func0<String>() { + return Observable.defer(new Func0<Observable<String>>() { @Override - public String call() { - return Network.getResponseData(response); + public Observable<String> call() { + return Observable.just(Network.getResponseData(response)); } - }, RxUtils.networkScheduler); + }).subscribeOn(RxUtils.networkScheduler); } /** Request .png image for a tile. Return as soon as the request has been made, before the answer has been @@ -256,17 +251,17 @@ public class Tile { */ static Observable<Bitmap> requestMapTile(final Parameters params) { final HttpResponse response = Network.getRequest(GCConstants.URL_MAP_TILE, params, new Parameters("Referer", GCConstants.URL_LIVE_MAP)); - return Async.start(new Func0<Bitmap>() { + return Observable.defer(new Func0<Observable<Bitmap>>() { @Override - public Bitmap call() { + public Observable<Bitmap> call() { try { - return response != null ? BitmapFactory.decodeStream(response.getEntity().getContent()) : null; + return Observable.just(response != null ? BitmapFactory.decodeStream(response.getEntity().getContent()) : null); } catch (final IOException e) { Log.e("Tile.requestMapTile() ", e); - return null; + return Observable.just(null); } } - }, RxUtils.computationScheduler); + }).subscribeOn(RxUtils.computationScheduler); } public boolean containsPoint(final @NonNull ICoordinates point) { @@ -281,8 +276,6 @@ public class Tile { * Calculate needed tiles for the given viewport to cover it with * max 2x2 tiles * - * @param viewport - * @return */ protected static Set<Tile> getTilesForViewport(final Viewport viewport) { return getTilesForViewport(viewport, 2, Tile.ZOOMLEVEL_MIN); @@ -293,10 +286,6 @@ public class Tile { * You can define the minimum number of tiles on the longer axis * and/or the minimum zoom level. * - * @param viewport - * @param tilesOnAxis - * @param minZoom - * @return */ protected static Set<Tile> getTilesForViewport(final Viewport viewport, final int tilesOnAxis, final int minZoom) { final Set<Tile> tiles = new HashSet<>(); diff --git a/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java b/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java index 9de7e1e..f5cd208 100644 --- a/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java +++ b/main/src/cgeo/geocaching/connector/gc/UTFGridPosition.java @@ -36,7 +36,6 @@ final class UTFGridPosition { /** * @param key * Key in the format (xx, xx) - * @return */ static UTFGridPosition fromString(final String key) { final MatcherWrapper matcher = new MatcherWrapper(UTFGridPosition.PATTERN_JSON_KEY, key); diff --git a/main/src/cgeo/geocaching/connector/gc/UncertainProperty.java b/main/src/cgeo/geocaching/connector/gc/UncertainProperty.java index 71adcbd..c9e01a2 100644 --- a/main/src/cgeo/geocaching/connector/gc/UncertainProperty.java +++ b/main/src/cgeo/geocaching/connector/gc/UncertainProperty.java @@ -4,7 +4,6 @@ package cgeo.geocaching.connector.gc; /** * Property with certainty. When merging properties, the one with higher certainty wins. * - * @param <T> */ public class UncertainProperty<T> { |
