Do not take snapshot if map is stopped. (#390)
This commit is contained in:
@@ -81,6 +81,7 @@ public final class MapboxMap {
|
|||||||
private Style style;
|
private Style style;
|
||||||
|
|
||||||
private boolean debugActive;
|
private boolean debugActive;
|
||||||
|
private boolean started;
|
||||||
|
|
||||||
MapboxMap(NativeMap map, Transform transform, UiSettings ui, Projection projection,
|
MapboxMap(NativeMap map, Transform transform, UiSettings ui, Projection projection,
|
||||||
OnGesturesManagerInteractionListener listener, CameraChangeDispatcher cameraChangeDispatcher,
|
OnGesturesManagerInteractionListener listener, CameraChangeDispatcher cameraChangeDispatcher,
|
||||||
@@ -143,6 +144,7 @@ public final class MapboxMap {
|
|||||||
* Called when the hosting Activity/Fragment onStart() method is called.
|
* Called when the hosting Activity/Fragment onStart() method is called.
|
||||||
*/
|
*/
|
||||||
void onStart() {
|
void onStart() {
|
||||||
|
started = true;
|
||||||
locationComponent.onStart();
|
locationComponent.onStart();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -150,6 +152,7 @@ public final class MapboxMap {
|
|||||||
* Called when the hosting Activity/Fragment onStop() method is called.
|
* Called when the hosting Activity/Fragment onStop() method is called.
|
||||||
*/
|
*/
|
||||||
void onStop() {
|
void onStop() {
|
||||||
|
started = false;
|
||||||
locationComponent.onStop();
|
locationComponent.onStop();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -2003,6 +2006,9 @@ public final class MapboxMap {
|
|||||||
* @param callback Callback method invoked when the snapshot is taken.
|
* @param callback Callback method invoked when the snapshot is taken.
|
||||||
*/
|
*/
|
||||||
public void snapshot(@NonNull SnapshotReadyCallback callback) {
|
public void snapshot(@NonNull SnapshotReadyCallback callback) {
|
||||||
|
if (!started) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
nativeMapView.addSnapshotCallback(callback);
|
nativeMapView.addSnapshotCallback(callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ import android.view.LayoutInflater
|
|||||||
import android.view.ViewGroup
|
import android.view.ViewGroup
|
||||||
import android.widget.TextView
|
import android.widget.TextView
|
||||||
import androidx.appcompat.app.AppCompatActivity
|
import androidx.appcompat.app.AppCompatActivity
|
||||||
import androidx.recyclerview.widget.RecyclerView
|
|
||||||
import com.mapbox.mapboxsdk.maps.MapView
|
import com.mapbox.mapboxsdk.maps.MapView
|
||||||
import com.mapbox.mapboxsdk.maps.Style
|
import com.mapbox.mapboxsdk.maps.Style
|
||||||
import com.mapbox.mapboxsdk.testapp.R
|
import com.mapbox.mapboxsdk.testapp.R
|
||||||
@@ -141,7 +140,11 @@ open class GLSurfaceRecyclerViewActivity : AppCompatActivity() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun bind(mapItem: MapItem) {
|
fun bind(mapItem: MapItem) {
|
||||||
mapView.getMapAsync { mapboxMap -> mapboxMap.setStyle(mapItem.style) }
|
mapView.getMapAsync { mapboxMap ->
|
||||||
|
mapboxMap.setStyle(mapItem.style) {
|
||||||
|
mapboxMap.snapshot { }
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user