diff options
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java')
-rw-r--r-- | platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java | 25 |
1 files changed, 20 insertions, 5 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java index 0895096f6e..641c283798 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/snapshotter/MapSnapshotter.java @@ -16,7 +16,6 @@ import android.util.DisplayMetrics; import android.view.View; import android.view.ViewGroup; import android.widget.TextView; - import com.mapbox.mapboxsdk.R; import com.mapbox.mapboxsdk.attribution.AttributionLayout; import com.mapbox.mapboxsdk.attribution.AttributionMeasure; @@ -25,7 +24,7 @@ import com.mapbox.mapboxsdk.camera.CameraPosition; import com.mapbox.mapboxsdk.constants.Style; import com.mapbox.mapboxsdk.geometry.LatLngBounds; import com.mapbox.mapboxsdk.storage.FileSource; - +import com.mapbox.mapboxsdk.utils.ThreadUtils; import timber.log.Timber; /** @@ -86,6 +85,7 @@ public class MapSnapshotter { private int width; private int height; private String styleUrl = Style.MAPBOX_STREETS; + private String styleJson; private LatLngBounds region; private CameraPosition cameraPosition; private boolean showLogo = true; @@ -112,6 +112,15 @@ public class MapSnapshotter { } /** + * @param styleJson The style json to use + * @return the mutated {@link Options} + */ + public Options withStyleJson(String styleJson) { + this.styleJson = styleJson; + return this; + } + + /** * @param region the region to show in the snapshot. * This is applied after the camera position * @return the mutated {@link Options} @@ -203,12 +212,13 @@ public class MapSnapshotter { * @param options the options to use for the snapshot */ public MapSnapshotter(@NonNull Context context, @NonNull Options options) { + checkThread(); this.context = context.getApplicationContext(); FileSource fileSource = FileSource.getInstance(context); String programCacheDir = context.getCacheDir().getAbsolutePath(); nativeInitialize(this, fileSource, options.pixelRatio, options.width, - options.height, options.styleUrl, options.region, options.cameraPosition, + options.height, options.styleUrl, options.styleJson, options.region, options.cameraPosition, options.showLogo, programCacheDir); } @@ -233,7 +243,7 @@ public class MapSnapshotter { if (this.callback != null) { throw new IllegalStateException("Snapshotter was already started"); } - + checkThread(); this.callback = callback; this.errorHandler = errorHandler; nativeStart(); @@ -274,6 +284,7 @@ public class MapSnapshotter { * the object was created on. */ public void cancel() { + checkThread(); reset(); nativeCancel(); } @@ -455,6 +466,10 @@ public class MapSnapshotter { } } + private void checkThread() { + ThreadUtils.checkThread("MapSnapshotter"); + } + protected void reset() { callback = null; errorHandler = null; @@ -462,7 +477,7 @@ public class MapSnapshotter { protected native void nativeInitialize(MapSnapshotter mapSnapshotter, FileSource fileSource, float pixelRatio, - int width, int height, String styleUrl, + int width, int height, String styleUrl, String styleJson, LatLngBounds region, CameraPosition position, boolean showLogo, String programCacheDir); |