use of org.odk.collect.settings.keys.MetaKeys.KEY_MAPBOX_INITIALIZED in project collect by opendatakit.
the class MapBoxInitializationFragment method initMapBox.
private void initMapBox(View rootView) {
Settings metaSharedPreferences = settingsProvider.getMetaSettings();
if (!metaSharedPreferences.getBoolean(KEY_MAPBOX_INITIALIZED) && connectivityProvider.isDeviceOnline()) {
// most likely to be available. This is annoyingly needed for offline tiles to work.
try {
mapView = new MapView(getContext());
FrameLayout mapBoxContainer = rootView.findViewById(R.id.map_box_container);
mapBoxContainer.addView(mapView);
mapView.getMapAsync(mapBoxMap -> mapBoxMap.setStyle(Style.MAPBOX_STREETS, style -> {
metaSharedPreferences.save(KEY_MAPBOX_INITIALIZED, true);
}));
} catch (Exception | Error ignored) {
// This will crash on devices where the arch for MapBox is not included
}
}
}
Aggregations