Samples MapFragment: use theme dispose function (#800)
This commit is contained in:
@@ -30,6 +30,7 @@ import org.oscim.renderer.GLViewport;
|
|||||||
import org.oscim.scalebar.DefaultMapScaleBar;
|
import org.oscim.scalebar.DefaultMapScaleBar;
|
||||||
import org.oscim.scalebar.MapScaleBar;
|
import org.oscim.scalebar.MapScaleBar;
|
||||||
import org.oscim.scalebar.MapScaleBarLayer;
|
import org.oscim.scalebar.MapScaleBarLayer;
|
||||||
|
import org.oscim.theme.IRenderTheme;
|
||||||
import org.oscim.theme.VtmThemes;
|
import org.oscim.theme.VtmThemes;
|
||||||
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
import org.oscim.tiling.source.mapfile.MapFileTileSource;
|
||||||
|
|
||||||
@@ -42,6 +43,7 @@ import java.io.File;
|
|||||||
public class MapFragment extends Fragment {
|
public class MapFragment extends Fragment {
|
||||||
|
|
||||||
private MapView mapView;
|
private MapView mapView;
|
||||||
|
private IRenderTheme theme;
|
||||||
|
|
||||||
public static MapFragment newInstance() {
|
public static MapFragment newInstance() {
|
||||||
MapFragment instance = new MapFragment();
|
MapFragment instance = new MapFragment();
|
||||||
@@ -79,7 +81,7 @@ public class MapFragment extends Fragment {
|
|||||||
mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer));
|
mapView.map().layers().add(new LabelLayer(mapView.map(), tileLayer));
|
||||||
|
|
||||||
// Render theme
|
// Render theme
|
||||||
mapView.map().setTheme(VtmThemes.DEFAULT);
|
theme = mapView.map().setTheme(VtmThemes.DEFAULT);
|
||||||
|
|
||||||
// Scale bar
|
// Scale bar
|
||||||
MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
|
MapScaleBar mapScaleBar = new DefaultMapScaleBar(mapView.map());
|
||||||
@@ -110,6 +112,10 @@ public class MapFragment extends Fragment {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onDestroyView() {
|
public void onDestroyView() {
|
||||||
|
if (theme != null) {
|
||||||
|
theme.dispose();
|
||||||
|
theme = null;
|
||||||
|
}
|
||||||
if (mapView != null) {
|
if (mapView != null) {
|
||||||
mapView.onDestroy();
|
mapView.onDestroy();
|
||||||
mapView = null;
|
mapView = null;
|
||||||
|
|||||||
Reference in New Issue
Block a user