Samples: use theme dispose function
This commit is contained in:
@@ -29,7 +29,6 @@ import org.oscim.scalebar.DefaultMapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBar;
|
||||
import org.oscim.scalebar.MapScaleBarLayer;
|
||||
import org.oscim.theme.IRenderTheme;
|
||||
import org.oscim.theme.ThemeLoader;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||
|
||||
@@ -90,8 +89,7 @@ public class GettingStarted extends Activity {
|
||||
mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer));
|
||||
|
||||
// Render theme
|
||||
theme = ThemeLoader.load(VtmThemes.DEFAULT);
|
||||
mapView.map().setTheme(theme);
|
||||
theme = mapView.map().setTheme(VtmThemes.DEFAULT);
|
||||
|
||||
// Scale bar
|
||||
MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
|
||||
|
||||
@@ -42,6 +42,7 @@ import org.oscim.renderer.BitmapRenderer;
|
||||
import org.oscim.renderer.GLViewport;
|
||||
import org.oscim.renderer.bucket.RenderBuckets;
|
||||
import org.oscim.scalebar.*;
|
||||
import org.oscim.theme.IRenderTheme;
|
||||
import org.oscim.theme.ThemeFile;
|
||||
import org.oscim.theme.VtmThemes;
|
||||
import org.oscim.theme.styles.AreaStyle;
|
||||
@@ -68,6 +69,7 @@ public class MapsforgeActivity extends MapActivity {
|
||||
private TileGridLayer mGridLayer;
|
||||
private Menu mMenu;
|
||||
private final boolean mS3db;
|
||||
IRenderTheme mTheme;
|
||||
VectorTileLayer mTileLayer;
|
||||
|
||||
public MapsforgeActivity() {
|
||||
@@ -106,27 +108,37 @@ public class MapsforgeActivity extends MapActivity {
|
||||
|
||||
switch (item.getItemId()) {
|
||||
case R.id.theme_default:
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_osmarender:
|
||||
mMap.setTheme(VtmThemes.OSMARENDER);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.OSMARENDER);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_osmagray:
|
||||
mMap.setTheme(VtmThemes.OSMAGRAY);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.OSMAGRAY);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_tubes:
|
||||
mMap.setTheme(VtmThemes.TRONRENDER);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.TRONRENDER);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
case R.id.theme_newtron:
|
||||
mMap.setTheme(VtmThemes.NEWTRON);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.NEWTRON);
|
||||
item.setChecked(true);
|
||||
return true;
|
||||
|
||||
@@ -230,12 +242,16 @@ public class MapsforgeActivity extends MapActivity {
|
||||
});
|
||||
}
|
||||
|
||||
mMap.setTheme(theme);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(theme);
|
||||
mMenu.findItem(R.id.theme_external).setChecked(true);
|
||||
}
|
||||
}
|
||||
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(VtmThemes.DEFAULT);
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(VtmThemes.DEFAULT);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
/*
|
||||
* Copyright 2016-2017 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify it under the
|
||||
* terms of the GNU Lesser General Public License as published by the Free Software
|
||||
@@ -17,7 +17,6 @@ package org.oscim.android.test;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import android.widget.Toast;
|
||||
|
||||
import org.oscim.android.theme.AssetsRenderTheme;
|
||||
import org.oscim.theme.XmlRenderThemeMenuCallback;
|
||||
import org.oscim.theme.XmlRenderThemeStyleLayer;
|
||||
@@ -58,7 +57,9 @@ public class MapsforgeStyleActivity extends MapsforgeActivity {
|
||||
|
||||
@Override
|
||||
protected void loadTheme(final String styleId) {
|
||||
mMap.setTheme(new AssetsRenderTheme(getAssets(), "", "vtm/stylemenu.xml", new XmlRenderThemeMenuCallback() {
|
||||
if (mTheme != null)
|
||||
mTheme.dispose();
|
||||
mTheme = mMap.setTheme(new AssetsRenderTheme(getAssets(), "", "vtm/stylemenu.xml", new XmlRenderThemeMenuCallback() {
|
||||
@Override
|
||||
public Set<String> getCategories(XmlRenderThemeStyleMenu renderThemeStyleMenu) {
|
||||
// Use the selected style or the default
|
||||
|
||||
@@ -2,7 +2,7 @@
|
||||
* Copyright 2013 Hannes Janetzek
|
||||
* Copyright 2016 Andrey Novikov
|
||||
* Copyright 2016 Stephan Leuschner
|
||||
* Copyright 2016-2019 devemux86
|
||||
* Copyright 2016-2020 devemux86
|
||||
* Copyright 2016 Longri
|
||||
* Copyright 2018 Gustl22
|
||||
*
|
||||
@@ -24,11 +24,7 @@ package org.oscim.map;
|
||||
import org.oscim.core.BoundingBox;
|
||||
import org.oscim.core.Box;
|
||||
import org.oscim.core.MapPosition;
|
||||
import org.oscim.event.Event;
|
||||
import org.oscim.event.EventDispatcher;
|
||||
import org.oscim.event.EventListener;
|
||||
import org.oscim.event.Gesture;
|
||||
import org.oscim.event.MotionEvent;
|
||||
import org.oscim.event.*;
|
||||
import org.oscim.layers.AbstractMapEventLayer;
|
||||
import org.oscim.layers.Layer;
|
||||
import org.oscim.layers.MapEventLayer;
|
||||
@@ -189,16 +185,18 @@ public abstract class Map implements TaskQueue {
|
||||
* Utility function to set theme of base vector-layer and
|
||||
* use map background color from theme.
|
||||
*/
|
||||
public void setTheme(ThemeFile theme) {
|
||||
setTheme(theme, false);
|
||||
public IRenderTheme setTheme(ThemeFile theme) {
|
||||
return setTheme(theme, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* Utility function to set theme of base vector-layer, optionally
|
||||
* to all vector layers and use map background color from theme.
|
||||
*/
|
||||
public void setTheme(ThemeFile theme, boolean allLayers) {
|
||||
setTheme(ThemeLoader.load(theme), allLayers);
|
||||
public IRenderTheme setTheme(ThemeFile theme, boolean allLayers) {
|
||||
IRenderTheme renderTheme = ThemeLoader.load(theme);
|
||||
setTheme(renderTheme, allLayers);
|
||||
return renderTheme;
|
||||
}
|
||||
|
||||
public void setTheme(IRenderTheme theme) {
|
||||
|
||||
Reference in New Issue
Block a user