Fix viewport change
This commit is contained in:
parent
9a35b70773
commit
b5a24dc23b
1 changed files with 12 additions and 2 deletions
|
@ -7,6 +7,7 @@ import net.osmand.PlatformUtil;
|
||||||
import net.osmand.data.RotatedTileBox;
|
import net.osmand.data.RotatedTileBox;
|
||||||
import net.osmand.plus.activities.MapActivity;
|
import net.osmand.plus.activities.MapActivity;
|
||||||
import net.osmand.plus.resources.AsyncLoadingThread;
|
import net.osmand.plus.resources.AsyncLoadingThread;
|
||||||
|
import net.osmand.plus.resources.ResourceManager;
|
||||||
import net.osmand.plus.server.OsmAndHttpServer;
|
import net.osmand.plus.server.OsmAndHttpServer;
|
||||||
import net.osmand.plus.views.OsmandMapTileView;
|
import net.osmand.plus.views.OsmandMapTileView;
|
||||||
import net.osmand.util.MapUtils;
|
import net.osmand.util.MapUtils;
|
||||||
|
@ -80,6 +81,7 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint {
|
||||||
private synchronized MetaTileFileSystemCache.MetaTileCache requestMetatile(int x, int y, int zoom) {
|
private synchronized MetaTileFileSystemCache.MetaTileCache requestMetatile(int x, int y, int zoom) {
|
||||||
long tm = System.currentTimeMillis();
|
long tm = System.currentTimeMillis();
|
||||||
MapActivity mapActivity = server.getMapActivity();
|
MapActivity mapActivity = server.getMapActivity();
|
||||||
|
ResourceManager resourceManager = mapActivity.getMyApplication().getResourceManager();
|
||||||
if (mapActivity == null) {
|
if (mapActivity == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
@ -91,9 +93,10 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint {
|
||||||
mapActivity.getMapView().setCurrentViewport(res.bbox);
|
mapActivity.getMapView().setCurrentViewport(res.bbox);
|
||||||
int timeout = 0;
|
int timeout = 0;
|
||||||
try {
|
try {
|
||||||
AsyncLoadingThread athread = mapActivity.getMyApplication().getResourceManager().getAsyncLoadingThread();
|
AsyncLoadingThread athread = resourceManager.getAsyncLoadingThread();
|
||||||
mapActivity.getMyApplication().getResourceManager().updateRendererMap(res.bbox, null);
|
resourceManager.updateRendererMap(res.bbox, null);
|
||||||
Thread.sleep(TIMEOUT_STEP); // to do line should be removed in future
|
Thread.sleep(TIMEOUT_STEP); // to do line should be removed in future
|
||||||
|
// wait till all resources rendered and loaded
|
||||||
while (athread.areResourcesLoading() && timeout < TIMEOUT) {
|
while (athread.areResourcesLoading() && timeout < TIMEOUT) {
|
||||||
if(lastRequestedZoom != zoom) {
|
if(lastRequestedZoom != zoom) {
|
||||||
return null;
|
return null;
|
||||||
|
@ -101,6 +104,13 @@ public class TileEndpoint implements OsmAndHttpServer.ApiEndpoint {
|
||||||
Thread.sleep(TIMEOUT_STEP);
|
Thread.sleep(TIMEOUT_STEP);
|
||||||
timeout += TIMEOUT_STEP;
|
timeout += TIMEOUT_STEP;
|
||||||
}
|
}
|
||||||
|
mapActivity.getMapView().refreshMap();
|
||||||
|
// wait for image to be refreshed
|
||||||
|
while(!resourceManager.getRenderingBufferImageThread().getLooper().getQueue().isIdle() &&
|
||||||
|
timeout < TIMEOUT) {
|
||||||
|
Thread.sleep(TIMEOUT_STEP);
|
||||||
|
timeout += TIMEOUT_STEP;
|
||||||
|
}
|
||||||
Bitmap rbmp = mapActivity.getMapView().getBufferBitmap();
|
Bitmap rbmp = mapActivity.getMapView().getBufferBitmap();
|
||||||
if (timeout >= TIMEOUT) {
|
if (timeout >= TIMEOUT) {
|
||||||
return null;
|
return null;
|
||||||
|
|
Loading…
Reference in a new issue