Revert "Fixed issue 494. Do not draw new map when it is already drawing and there is only rotation change."

This reverts commit b3c6fede74.
This commit is contained in:
Pavol Zibrita 2011-10-16 19:44:47 +02:00
parent 515ac61264
commit 91e8071ea3
4 changed files with 15 additions and 84 deletions

View file

@ -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
*/

View file

@ -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();
}
}
}

View file

@ -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() {

View file

@ -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();