aboutsummaryrefslogtreecommitdiffstats
path: root/main/src/cgeo/geocaching/connector/gc/Tile.java
diff options
context:
space:
mode:
Diffstat (limited to 'main/src/cgeo/geocaching/connector/gc/Tile.java')
-rw-r--r--main/src/cgeo/geocaching/connector/gc/Tile.java29
1 files changed, 9 insertions, 20 deletions
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<>();