Samples MapFragment: use theme dispose function (#800)

This commit is contained in:
Meibes
2020-12-28 12:33:09 +01:00
committed by Emux
parent 6bea801bf6
commit 7d6c623a80

View File

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