add onDetach-method to MapScaleBarLayer to free resources automatically

removed mapScaleBar.destroy() methods from onDestroy-Activity methods
changed global mapScaleBar-variables to local
This commit is contained in:
Meibes
2020-01-26 16:39:44 +01:00
parent f449a0a6fb
commit ebe98c8990
4 changed files with 9 additions and 24 deletions

View File

@@ -42,7 +42,6 @@ public class GettingStarted extends Activity {
private static final String MAP_FILE = "berlin.map";
private MapView mapView;
private MapScaleBar mapScaleBar;
@Override
public void onCreate(Bundle savedInstanceState) {
@@ -69,7 +68,7 @@ public class GettingStarted extends Activity {
mapView.map().setTheme(VtmThemes.DEFAULT);
// Scale bar
mapScaleBar = new DefaultMapScaleBar(mapView.map());
MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
MapScaleBarLayer mapScaleBarLayer = new MapScaleBarLayer(mapView.map(), mapScaleBar);
mapScaleBarLayer.getRenderer().setPosition(GLViewport.Position.BOTTOM_LEFT);
mapScaleBarLayer.getRenderer().setOffset(5 * CanvasAdapter.getScale(), 0);
@@ -94,8 +93,6 @@ public class GettingStarted extends Activity {
@Override
protected void onDestroy() {
if (mapScaleBar != null)
mapScaleBar.destroy();
mapView.onDestroy();
super.onDestroy();
}