fixes:
- start MapWorkers at end of init - check for screensize > 0 in updateMap
This commit is contained in:
parent
e54e6e1c46
commit
6ee2a85e12
@ -18,7 +18,7 @@ package org.oscim.utils;
|
||||
* An abstract base class for threads which support pausing and resuming.
|
||||
*/
|
||||
public abstract class PausableThread extends Thread {
|
||||
private boolean mPausing;
|
||||
private boolean mPausing = true;
|
||||
private boolean mShouldPause;
|
||||
|
||||
/**
|
||||
|
||||
@ -116,7 +116,8 @@ public abstract class MapActivity extends Activity {
|
||||
GeoPoint geoPoint = new GeoPoint(latitudeE6, longitudeE6);
|
||||
MapPosition mapPosition = new MapPosition(geoPoint, (byte) zoomLevel, 1);
|
||||
|
||||
mapView.setMapCenter(mapPosition);
|
||||
mMapView.getMapViewPosition().setMapCenter(mapPosition);
|
||||
// mapView.setMapCenter(mapPosition);
|
||||
}
|
||||
|
||||
String theme = sharedPreferences.getString(KEY_THEME,
|
||||
|
||||
@ -38,8 +38,8 @@ import org.oscim.theme.Theme;
|
||||
import org.oscim.view.generator.JobQueue;
|
||||
import org.oscim.view.generator.JobTile;
|
||||
import org.oscim.view.generator.MapWorker;
|
||||
import org.oscim.view.renderer.TileGenerator;
|
||||
import org.oscim.view.renderer.MapRenderer;
|
||||
import org.oscim.view.renderer.TileGenerator;
|
||||
import org.xml.sax.SAXException;
|
||||
|
||||
import android.content.Context;
|
||||
@ -163,7 +163,6 @@ public class MapView extends FrameLayout {
|
||||
mMapDatabase = mapDatabase;
|
||||
|
||||
mMapWorkers[i] = new MapWorker(i, mJobQueue, tileGenerator, mMapRenderer);
|
||||
mMapWorkers[i].start();
|
||||
}
|
||||
|
||||
mapActivity.registerMapView(this);
|
||||
@ -190,6 +189,10 @@ public class MapView extends FrameLayout {
|
||||
mMapZoomControls.setShowMapZoomControls(true);
|
||||
|
||||
enableRotation = true;
|
||||
|
||||
for (MapWorker worker : mMapWorkers)
|
||||
worker.start();
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
@ -221,10 +224,16 @@ public class MapView extends FrameLayout {
|
||||
* Calculates all necessary tiles and adds jobs accordingly.
|
||||
*/
|
||||
public void redrawMap() {
|
||||
if (mPausing || this.getWidth() == 0 || this.getHeight() == 0)
|
||||
return;
|
||||
|
||||
mMapRenderer.updateMap(false);
|
||||
}
|
||||
|
||||
public void clearAndRedrawMap() {
|
||||
if (mPausing || this.getWidth() == 0 || this.getHeight() == 0)
|
||||
return;
|
||||
|
||||
mMapRenderer.updateMap(true);
|
||||
}
|
||||
|
||||
@ -462,18 +471,28 @@ public class MapView extends FrameLayout {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean mPausing = false;
|
||||
|
||||
void onPause() {
|
||||
mapWorkersPause(false);
|
||||
mPausing = true;
|
||||
|
||||
Log.d(TAG, "onPause");
|
||||
mJobQueue.clear();
|
||||
mapWorkersPause(true);
|
||||
|
||||
if (this.enableCompass)
|
||||
mCompass.disable();
|
||||
|
||||
}
|
||||
|
||||
void onResume() {
|
||||
Log.d(TAG, "onResume");
|
||||
mapWorkersProceed();
|
||||
|
||||
if (this.enableCompass)
|
||||
mCompass.enable();
|
||||
|
||||
mPausing = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@ -33,32 +33,7 @@ import android.util.Log;
|
||||
|
||||
public class MapRenderer extends GLSurfaceView {
|
||||
private final static String TAG = "MapRenderer";
|
||||
|
||||
public MapRenderer(Context context, MapView mapView) {
|
||||
super(context);
|
||||
|
||||
mMapView = mapView;
|
||||
|
||||
Log.d(TAG, "init GLSurfaceLayer");
|
||||
setEGLConfigChooser(new GlConfigChooser());
|
||||
setEGLContextClientVersion(2);
|
||||
|
||||
// setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);
|
||||
mRenderer = new GLRenderer(mMapView);
|
||||
setRenderer(mRenderer);
|
||||
//
|
||||
// if (!debugFrameTime)
|
||||
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
|
||||
|
||||
mJobList = new ArrayList<JobTile>();
|
||||
mTiles = new ArrayList<MapTile>();
|
||||
mTilesLoaded = new ArrayList<MapTile>(30);
|
||||
|
||||
ShortPool.init();
|
||||
QuadTree.init();
|
||||
|
||||
mInitial = true;
|
||||
}
|
||||
private GLRenderer mRenderer;
|
||||
|
||||
private static final int MAX_TILES_IN_QUEUE = 40;
|
||||
|
||||
@ -85,6 +60,32 @@ public class MapRenderer extends GLSurfaceView {
|
||||
|
||||
private static TilesData newTiles;
|
||||
|
||||
public MapRenderer(Context context, MapView mapView) {
|
||||
super(context);
|
||||
|
||||
mMapView = mapView;
|
||||
|
||||
Log.d(TAG, "init GLSurfaceLayer");
|
||||
setEGLConfigChooser(new GlConfigChooser());
|
||||
setEGLContextClientVersion(2);
|
||||
|
||||
// setDebugFlags(DEBUG_CHECK_GL_ERROR | DEBUG_LOG_GL_CALLS);
|
||||
mRenderer = new GLRenderer(mMapView);
|
||||
setRenderer(mRenderer);
|
||||
|
||||
// if (!debugFrameTime)
|
||||
setRenderMode(GLSurfaceView.RENDERMODE_WHEN_DIRTY);
|
||||
|
||||
mJobList = new ArrayList<JobTile>();
|
||||
mTiles = new ArrayList<MapTile>();
|
||||
mTilesLoaded = new ArrayList<MapTile>(30);
|
||||
|
||||
ShortPool.init();
|
||||
QuadTree.init();
|
||||
|
||||
mInitial = true;
|
||||
}
|
||||
|
||||
/**
|
||||
* called by MapView when position or map settings changes
|
||||
*/
|
||||
@ -511,13 +512,6 @@ public class MapRenderer extends GLSurfaceView {
|
||||
|
||||
}
|
||||
|
||||
private GLRenderer mRenderer;
|
||||
|
||||
@Override
|
||||
public void onPause() {
|
||||
super.onPause();
|
||||
}
|
||||
|
||||
@Override
|
||||
protected void onSizeChanged(int w, int h, int oldw, int oldh) {
|
||||
|
||||
|
||||
@ -98,7 +98,7 @@ public class TileGenerator implements IRenderCallback, IMapDatabaseCallback {
|
||||
* the MapView
|
||||
*/
|
||||
public TileGenerator(MapView mapView) {
|
||||
Log.d(TAG, "init DatabaseRenderer");
|
||||
Log.d(TAG, "init TileGenerator");
|
||||
mMapView = mapView;
|
||||
}
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user