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); return super.onKeyDown(keyCode, event);
} }
public void setMapLocation(double lat, double lon){
mapView.setLatLon(lat, lon);
locationChanged(lat, lon, this);
}
@Override @Override
public boolean onTrackballEvent(MotionEvent event) { public boolean onTrackballEvent(MotionEvent event) {
if(event.getAction() == MotionEvent.ACTION_MOVE && settings.USE_TRACKBALL_FOR_MOVEMENTS.get()){ 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() { public OsmandMapTileView getMapView() {
return mapView; return mapView;
} }

View file

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

View file

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