Search in sources :

Example 1 with NotificationOptions

use of com.mapbox.mapboxsdk.plugins.offline.model.NotificationOptions in project mapbox-plugins-android by mapbox.

the class OfflineDownloadActivity method onDownloadRegion.

@OnClick(R.id.fab)
public void onDownloadRegion() {
    // get data from UI
    String regionName = regionNameView.getText().toString();
    double latitudeNorth = Double.parseDouble(latNorthView.getText().toString());
    double longitudeEast = Double.parseDouble(lonEastView.getText().toString());
    double latitudeSouth = Double.parseDouble(latSouthView.getText().toString());
    double longitudeWest = Double.parseDouble(lonWestView.getText().toString());
    String styleUrl = (String) styleUrlView.getSelectedItem();
    float maxZoom = maxZoomView.getProgress();
    float minZoom = minZoomView.getProgress();
    if (!validCoordinates(latitudeNorth, longitudeEast, latitudeSouth, longitudeWest)) {
        Toast.makeText(this, "coordinates need to be in valid range", Toast.LENGTH_LONG).show();
        return;
    }
    // create offline definition from data
    OfflineTilePyramidRegionDefinition definition = new OfflineTilePyramidRegionDefinition(styleUrl, new LatLngBounds.Builder().include(new LatLng(latitudeNorth, longitudeEast)).include(new LatLng(latitudeSouth, longitudeWest)).build(), minZoom, maxZoom, getResources().getDisplayMetrics().density);
    // customize notification appearance
    NotificationOptions notificationOptions = NotificationOptions.builder(this).smallIconRes(R.drawable.mapbox_logo_icon).returnActivity(OfflineRegionDetailActivity.class.getName()).build();
    // start offline download
    OfflinePlugin.getInstance().startDownload(this, OfflineDownloadOptions.builder().definition(definition).metadata(OfflineUtils.convertRegionName(regionName)).notificationOptions(notificationOptions).build());
}
Also used : NotificationOptions(com.mapbox.mapboxsdk.plugins.offline.model.NotificationOptions) OfflineTilePyramidRegionDefinition(com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition) LatLng(com.mapbox.mapboxsdk.geometry.LatLng) OnClick(butterknife.OnClick)

Aggregations

OnClick (butterknife.OnClick)1 LatLng (com.mapbox.mapboxsdk.geometry.LatLng)1 OfflineTilePyramidRegionDefinition (com.mapbox.mapboxsdk.offline.OfflineTilePyramidRegionDefinition)1 NotificationOptions (com.mapbox.mapboxsdk.plugins.offline.model.NotificationOptions)1