From 08ab7a6613dc741a808d6b80810f20213acbfe3b Mon Sep 17 00:00:00 2001 From: simon Date: Mon, 7 Sep 2020 17:32:21 +0300 Subject: [PATCH] cleanup --- OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java | 8 ++++---- .../net/osmand/plus/server/endpoints/TileEndpoint.java | 6 ++---- 2 files changed, 6 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java b/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java index 31d0bc12b6..44f8cbab71 100644 --- a/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java +++ b/OsmAnd/src/net/osmand/plus/server/OsmAndHttpServer.java @@ -40,6 +40,10 @@ public class OsmAndHttpServer extends NanoHTTPD { return getStatic(uri); } + public String getUrl() { + return "http://" + getHostname() + ":" + getListeningPort(); + } + private NanoHTTPD.Response routeApi(NanoHTTPD.IHTTPSession session) { String uri = session.getUri(); for (String path : endpoints.keySet()) { @@ -102,10 +106,6 @@ public class OsmAndHttpServer extends NanoHTTPD { return type; } - public String getUrl() { - return "http://" + getHostname() + ":" + getListeningPort(); - } - public interface ApiEndpoint { NanoHTTPD.Response process(NanoHTTPD.IHTTPSession session); } diff --git a/OsmAnd/src/net/osmand/plus/server/endpoints/TileEndpoint.java b/OsmAnd/src/net/osmand/plus/server/endpoints/TileEndpoint.java index c3251247e4..da99126197 100644 --- a/OsmAnd/src/net/osmand/plus/server/endpoints/TileEndpoint.java +++ b/OsmAnd/src/net/osmand/plus/server/endpoints/TileEndpoint.java @@ -20,9 +20,9 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile private static final int TILE_SIZE_PX = 512; private static final int TIMEOUT_STEP = 500; private static final Log LOG = PlatformUtil.getLog(TileEndpoint.class); + private final MapActivity mapActivity; private RotatedTileBox resultBmpViewport; private Bitmap resultBitmap; - private MapActivity mapActivity; public TileEndpoint(MapActivity mapActivity) { this.mapActivity = mapActivity; @@ -48,7 +48,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile if (bitmap == null) { return OsmAndHttpServer.ErrorResponses.response500; } - //stream also needs to be synchronized ByteArrayOutputStream stream = new ByteArrayOutputStream(); bitmap.compress(Bitmap.CompressFormat.PNG, 100, stream); byte[] byteArray = stream.toByteArray(); @@ -68,7 +67,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile .setZoom(zoom) .setPixelDimensions(TILE_SIZE_PX, TILE_SIZE_PX, 0.5f, 0.5f).build(); mapActivity.getMapView().setCurrentViewport(rotatedTileBox); - Bitmap bmp = null; int timeout = 0; try { while (!rotatedTileBox.equals(resultBmpViewport) && timeout < SOCKET_READ_TIMEOUT) { @@ -80,6 +78,6 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint, OsmandMapTile } catch (InterruptedException e) { LOG.error(e); } - return bmp; + return null; } }