Small refactoring and do not clear bitmap cache often

This commit is contained in:
Victor Shcherb 2011-11-26 02:04:38 +01:00
parent d79ffb1580
commit 129bdce53c
3 changed files with 62 additions and 55 deletions

View file

@ -533,6 +533,12 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
}
return super.onKeyDown(keyCode, event);
}
public void setMapLocation(double lat, double lon){
mapView.setLatLon(lat, lon);
locationChanged(lat, lon, this);
}
@Override
public boolean onTrackballEvent(MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE && settings.USE_TRACKBALL_FOR_MOVEMENTS.get()){
@ -965,11 +971,6 @@ public class MapActivity extends Activity implements IMapLocationListener, Senso
}
}
public void setMapLocation(double lat, double lon){
mapView.setLatLon(lat, lon);
locationChanged(lat, lon, this);
}
public OsmandMapTileView getMapView() {
return mapView;
}

View file

@ -298,9 +298,18 @@ public class OsmandApplication extends Application {
startDialog = new ProgressDialogImplementation(this, null, false);
startDialog.setRunnable("Initializing app", new Runnable() { //$NON-NLS-1$
@Override
public void run() {
startApplicationBackground();
}
});
startDialog.run();
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
}
private void startApplicationBackground() {
List<String> warnings = null;
try {
if (osmandSettings.NATIVE_RENDERING.get()) {
@ -319,8 +328,6 @@ public class OsmandApplication extends Application {
warnings.addAll(helper.saveDataToGpx());
}
helper.close();
// NativeOsmandLibrary.loadLibrary();
} finally {
synchronized (OsmandApplication.this) {
final ProgressDialog toDismiss;
@ -347,12 +354,6 @@ public class OsmandApplication extends Application {
}
}
}
});
startDialog.run();
Thread.setDefaultUncaughtExceptionHandler(new DefaultExceptionHandler());
}
protected void showWarnings(List<String> warnings, final Context uiContext) {
if (warnings != null && !warnings.isEmpty()) {

View file

@ -172,6 +172,8 @@ public class MapRenderRepositories {
public void clearAllResources() {
clearCache();
bmp = null;
bmpLocation = null;
for (String f : new ArrayList<String>(files.keySet())) {
closeConnection(files.get(f), f);
}
@ -607,8 +609,11 @@ public class MapRenderRepositories {
public synchronized void clearCache() {
cObjects = new ArrayList<BinaryMapDataObject>();
cObjectsBox = new RectF();
prevBmp = bmp = null;
requestedBox = prevBmpLocation = bmpLocation = null;
prevBmp = null;
requestedBox = prevBmpLocation = null;
// Do not clear main bitmap to not cause a screen refresh
// bmp = null;
// bmpLocation = null;
}
// / Manipulating with multipolygons