Search in sources :

Example 1 with PermissionsManager

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);
    }
}
Also used : RecyclerView(androidx.recyclerview.widget.RecyclerView) PermissionsManager(com.mapbox.android.core.permissions.PermissionsManager) LinearLayoutManager(androidx.recyclerview.widget.LinearLayoutManager)

Example 2 with PermissionsManager

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);
    }
}
Also used : PermissionsManager(com.mapbox.android.core.permissions.PermissionsManager)

Example 3 with PermissionsManager

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);
    }
}
Also used : PermissionsManager(com.mapbox.android.core.permissions.PermissionsManager) LocationComponent(com.mapbox.mapboxsdk.location.LocationComponent)

Aggregations

PermissionsManager (com.mapbox.android.core.permissions.PermissionsManager)3 LinearLayoutManager (androidx.recyclerview.widget.LinearLayoutManager)1 RecyclerView (androidx.recyclerview.widget.RecyclerView)1 LocationComponent (com.mapbox.mapboxsdk.location.LocationComponent)1