diff options
Diffstat (limited to 'main/src/cgeo/geocaching/StaticMapsProvider.java')
-rw-r--r-- | main/src/cgeo/geocaching/StaticMapsProvider.java | 21 |
1 files changed, 7 insertions, 14 deletions
diff --git a/main/src/cgeo/geocaching/StaticMapsProvider.java b/main/src/cgeo/geocaching/StaticMapsProvider.java index 5184f71..8c399af 100644 --- a/main/src/cgeo/geocaching/StaticMapsProvider.java +++ b/main/src/cgeo/geocaching/StaticMapsProvider.java @@ -16,9 +16,7 @@ import org.apache.commons.lang3.StringUtils; import org.eclipse.jdt.annotation.NonNull; import rx.Observable; -import rx.functions.Action0; import rx.functions.Func0; -import rx.util.async.Async; import android.graphics.Bitmap; import android.graphics.BitmapFactory; @@ -86,9 +84,9 @@ public final class StaticMapsProvider { final int requestWidth = Math.min(width / scale, GOOGLE_MAPS_MAX_SIZE); final int requestHeight = (aspectRatio > 1) ? Math.round(requestWidth / aspectRatio) : requestWidth; final int requestZoom = Math.min((scale == 2) ? zoom + 1 : zoom, GOOGLE_MAX_ZOOM); - return checkDownloadPermission(Async.fromAction(new Action0() { + return checkDownloadPermission(Observable.defer(new Func0<Observable<String>>() { @Override - public void call() { + public Observable<String> call() { final Parameters params = new Parameters( "center", latlonMap, "zoom", String.valueOf(requestZoom), @@ -104,7 +102,7 @@ public final class StaticMapsProvider { if (httpResponse == null) { Log.e("StaticMapsProvider.downloadMap: httpResponse is null"); - return; + return Observable.just(prefix); } final int statusCode = httpResponse.getStatusLine().getStatusCode(); if (statusCode != 200) { @@ -112,7 +110,7 @@ public final class StaticMapsProvider { if (statusCode == 403) { last403 = System.currentTimeMillis(); } - return; + return Observable.just(prefix); } final File file = getMapFile(geocode, prefix, true); if (LocalStorage.saveEntityToFile(httpResponse, file)) { @@ -122,8 +120,9 @@ public final class StaticMapsProvider { FileUtils.deleteIgnoringFailure(file); } } + return Observable.just(prefix); } - }, prefix, RxUtils.networkScheduler)); + }).subscribeOn(RxUtils.networkScheduler)); } public static Observable<String> downloadMaps(final Geocache cache) { @@ -216,9 +215,8 @@ public final class StaticMapsProvider { public static Observable<String> storeCachePreviewMap(final Geocache cache) { final String latlonMap = cache.getCoords().format(Format.LAT_LON_DECDEGREE_COMMA); final Point displaySize = Compatibility.getDisplaySize(); - final int minSize = Math.min(displaySize.x, displaySize.y); final String markerUrl = MARKERS_URL + "my_location_mdpi.png"; - return downloadMap(cache.getGeocode(), 15, ROADMAP, markerUrl, PREFIX_PREVIEW, "shadow:false|", latlonMap, minSize, minSize, null); + return downloadMap(cache.getGeocode(), 15, ROADMAP, markerUrl, PREFIX_PREVIEW, "shadow:false|", latlonMap, displaySize.x, displaySize.y, null); } private static Observable<String> downloadMaps(final String geocode, final String markerUrl, final String prefix, @@ -261,7 +259,6 @@ public final class StaticMapsProvider { /** * Check if at least one map file exists for the given cache. * - * @param cache * @return <code>true</code> if at least one map file exists; <code>false</code> otherwise */ public static boolean hasStaticMap(@NonNull final Geocache cache) { @@ -281,8 +278,6 @@ public final class StaticMapsProvider { /** * Checks if at least one map file exists for the given geocode and waypoint ID. * - * @param geocode - * @param waypoint * @return <code>true</code> if at least one map file exists; <code>false</code> otherwise */ public static boolean hasStaticMapForWaypoint(final String geocode, final Waypoint waypoint) { @@ -300,8 +295,6 @@ public final class StaticMapsProvider { /** * Checks if all map files exist for the given geocode and waypoint ID. * - * @param geocode - * @param waypoint * @return <code>true</code> if all map files exist; <code>false</code> otherwise */ public static boolean hasAllStaticMapsForWaypoint(final String geocode, final Waypoint waypoint) { |