use of com.mapbox.android.core.permissions.PermissionsManager in project mapbox-plugins-android by mapbox.
the class FeatureOverviewActivity method onCreate.
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_feature_overview);
recyclerView = findViewById(R.id.recyclerView);
recyclerView.setLayoutManager(new LinearLayoutManager(this));
recyclerView.addOnItemTouchListener(new RecyclerView.SimpleOnItemTouchListener());
recyclerView.setHasFixedSize(true);
ItemClickSupport.addTo(recyclerView).setOnItemClickListener((recyclerView, position, view) -> {
if (!sectionAdapter.isSectionHeaderPosition(position)) {
int itemPosition = sectionAdapter.getConvertedPosition(position);
Feature feature = features.get(itemPosition);
startFeature(feature);
}
});
if (savedInstanceState == null) {
loadFeatures();
} else {
features = savedInstanceState.getParcelableArrayList(KEY_STATE_FEATURES);
onFeaturesLoaded(features);
}
// Check for location permission
permissionsManager = new PermissionsManager(this);
if (!PermissionsManager.areLocationPermissionsGranted(this)) {
recyclerView.setEnabled(false);
permissionsManager.requestLocationPermissions(this);
}
}
use of com.mapbox.android.core.permissions.PermissionsManager in project mapbox-events-android by mapbox.
the class MainActivity method checkPermissions.
private void checkPermissions() {
boolean permissionsGranted = PermissionsManager.areLocationPermissionsGranted(this);
if (permissionsGranted) {
mapboxTelemetry.enable();
} else {
permissionsManager = new PermissionsManager(this);
permissionsManager.requestLocationPermissions(this);
}
}
use of com.mapbox.android.core.permissions.PermissionsManager in project mapbox-plugins-android by mapbox.
the class PlacePickerActivity method enableLocationComponent.
@SuppressWarnings({ "MissingPermission" })
private void enableLocationComponent(@NonNull Style loadedMapStyle) {
// Check if permissions are enabled and if not request
if (PermissionsManager.areLocationPermissionsGranted(this)) {
// Get an instance of the component
LocationComponent locationComponent = mapboxMap.getLocationComponent();
// Activate with options
locationComponent.activateLocationComponent(LocationComponentActivationOptions.builder(this, loadedMapStyle).build());
// Enable to make component visible
locationComponent.setLocationComponentEnabled(true);
// Set the component's camera mode
locationComponent.setCameraMode(CameraMode.NONE);
// Set the component's render mode
locationComponent.setRenderMode(RenderMode.NORMAL);
addUserLocationButton();
} else {
permissionsManager = new PermissionsManager(this);
permissionsManager.requestLocationPermissions(this);
}
}
Aggregations