From 91e8071ea366853d06e6010d49a513fdd0d486b7 Mon Sep 17 00:00:00 2001 From: Pavol Zibrita Date: Sun, 16 Oct 2011 19:44:47 +0200 Subject: [PATCH] Revert "Fixed issue 494. Do not draw new map when it is already drawing and there is only rotation change." This reverts commit b3c6fede747bf9ceeddd1c53088dfe0f3d85fca1. --- .../net/osmand/plus/AsyncLoadingThread.java | 13 ++-- .../src/net/osmand/plus/RotatedTileBox.java | 63 +------------------ .../plus/render/MapRenderRepositories.java | 20 ++---- .../osmand/plus/render/MapVectorLayer.java | 3 +- 4 files changed, 15 insertions(+), 84 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java b/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java index d5be9ce42c..91779e8e7c 100644 --- a/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java +++ b/OsmAnd/src/net/osmand/plus/AsyncLoadingThread.java @@ -4,21 +4,22 @@ import java.io.File; import java.util.List; import java.util.Stack; +import org.apache.commons.logging.Log; + +import android.os.Handler; +import android.os.HandlerThread; +import android.os.Looper; + import net.osmand.Algoritms; import net.osmand.LogUtil; import net.osmand.ResultMatcher; import net.osmand.data.Amenity; import net.osmand.data.MapTileDownloader; +import net.osmand.data.TransportStop; import net.osmand.data.MapTileDownloader.DownloadRequest; import net.osmand.data.MapTileDownloader.IMapDownloaderCallback; -import net.osmand.data.TransportStop; import net.osmand.map.ITileSource; -import org.apache.commons.logging.Log; - -import android.os.Handler; -import android.os.HandlerThread; - /** * Thread to load map objects (POI, transport stops )async */ diff --git a/OsmAnd/src/net/osmand/plus/RotatedTileBox.java b/OsmAnd/src/net/osmand/plus/RotatedTileBox.java index 5bf6ea82e9..bb22dfa330 100644 --- a/OsmAnd/src/net/osmand/plus/RotatedTileBox.java +++ b/OsmAnd/src/net/osmand/plus/RotatedTileBox.java @@ -13,9 +13,6 @@ public class RotatedTileBox { private int zoom; private float rotateCos; private float rotateSin; - private RectF latLon; - private boolean rendering; - private RotatedTileBox parent; public RotatedTileBox(float leftTileX, float topTileY, float tileWidth, float tileHeight, float rotate, int zoom) { set(leftTileX, topTileY, tileWidth, tileHeight, rotate, zoom); @@ -23,9 +20,6 @@ public class RotatedTileBox { public RotatedTileBox(RotatedTileBox r){ set(r.leftTileX, r.topTileY, r.tileWidth, r.tileHeight, r.rotate, r.zoom); - this.latLon = r.latLon; - this.rendering = r.rendering; - this.parent = r; } private void init() { @@ -172,61 +166,6 @@ public class RotatedTileBox { return calcPointTileY(tileWidth, tileHeight); } - /** - * the lat lon bounds - * @param latLonBounds - */ - public void setLatLon(RectF latLonBounds) { - //on new latLonBounds reset rendering info and latLonBounds.... - if (!latLonBounds.equals(this.latLon)) { - this.rendering = false; - this.latLon = latLonBounds; - } - } - - /** - * @return true if rendering is in progress - */ - public boolean isRendering() { - return rendering; - } - - /** - * Say we are rendering this box - */ - public void rendering() { - rendering = true; - if (parent != null) { - parent.rendering(latLon); - } - } - - /** - * Say we are rendering this box for this coordinates - * - * @param aLatLon - */ - private void rendering(RectF aLatLon) { - if (aLatLon.equals(latLon)) { - rendering = true; - } - } - - /** - * all if rendering was interrupted - */ - public void renderingInterrupted() { - rendered(); - } - - /** - * Call if rendering is finished - */ - public void rendered() { - rendering = false; - if (parent != null) { - parent.rendered(); - } - } + } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java index 5ccf009419..7edba9a3cd 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java +++ b/OsmAnd/src/net/osmand/plus/render/MapRenderRepositories.java @@ -196,9 +196,6 @@ public class MapRenderRepositories { } public void interruptLoadingMap(){ - if (requestedBox != null) { - requestedBox.renderingInterrupted(); - } interrupted = true; if(currentRenderingContext != null){ currentRenderingContext.interrupted = true; @@ -210,9 +207,6 @@ public class MapRenderRepositories { private boolean checkWhetherInterrupted(){ if(interrupted || (currentRenderingContext != null && currentRenderingContext.interrupted)){ - if (requestedBox != null) { - requestedBox.renderingInterrupted(); - } requestedBox = bmpLocation; return true; } @@ -362,10 +356,6 @@ public class MapRenderRepositories { currentRenderingContext = null; } try { - // prevent editing - requestedBox = new RotatedTileBox(tileRect); - requestedBox.rendering(); - // find selected rendering type OsmandApplication app = ((OsmandApplication)context.getApplicationContext()); Boolean renderDay = app.getDaynightHelper().getDayNightRenderer(); @@ -373,6 +363,9 @@ public class MapRenderRepositories { // boolean moreDetail = prefs.SHOW_MORE_MAP_DETAIL.get(); BaseOsmandRender renderingType = app.getRendererRegistry().getCurrentSelectedRenderer(); + // prevent editing + requestedBox = new RotatedTileBox(tileRect); + // calculate data box RectF dataBox = requestedBox.calculateLatLonBox(new RectF()); long now = System.currentTimeMillis(); @@ -426,6 +419,7 @@ public class MapRenderRepositories { } + renderer.generateNewBitmap(currentRenderingContext, cObjects, bmp, prefs.USE_ENGLISH_NAMES.get(), renderingType, stepByStep ? notifyList : null); String renderingDebugInfo = currentRenderingContext.renderingDebugInfo; @@ -474,11 +468,9 @@ public class MapRenderRepositories { Toast.makeText(context, R.string.rendering_out_of_memory, Toast.LENGTH_SHORT).show(); } }); - } finally { - if (requestedBox != null) { - requestedBox.rendered(); - } + } + } public Bitmap getBitmap() { diff --git a/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java b/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java index 14f1e2974e..7d5bf1596a 100644 --- a/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java +++ b/OsmAnd/src/net/osmand/plus/render/MapVectorLayer.java @@ -93,11 +93,10 @@ public class MapVectorLayer extends BaseMapLayer { tileLayer.drawTileMap(canvas, tilesRect); resourceManager.getRenderer().interruptLoadingMap(); } else { - rotatedTileBox.setLatLon(latLonBounds); if (!view.isZooming()) { pixRect.set(0, 0, view.getWidth(), view.getHeight()); updateRotatedTileBox(); - if (!rotatedTileBox.isRendering() && resourceManager.updateRenderedMapNeeded(rotatedTileBox)) { + if (resourceManager.updateRenderedMapNeeded(rotatedTileBox)) { // pixRect.set(-view.getWidth(), -view.getHeight() / 2, 2 * view.getWidth(), 3 * view.getHeight() / 2); pixRect.set(-view.getWidth() / 3, -view.getHeight() / 4, 4 * view.getWidth() / 3, 5 * view.getHeight() / 4); updateRotatedTileBox();