* [android] Rework setStyleUrl() logic to avoid NPE as per #6512 * fixup brackets + comment
This commit is contained in:
@@ -155,8 +155,8 @@ public class MapView extends FrameLayout {
|
||||
|
||||
private PointF focalPoint;
|
||||
|
||||
private String styleUrl;
|
||||
private String initalStyle;
|
||||
private String styleUrl = Style.MAPBOX_STREETS;
|
||||
private boolean styleWasSet = false;
|
||||
|
||||
private List<OnMapReadyCallback> onMapReadyCallbackList;
|
||||
private SnapshotRequest snapshotRequest;
|
||||
@@ -283,7 +283,7 @@ public class MapView extends FrameLayout {
|
||||
// style url
|
||||
String style = options.getStyle();
|
||||
if (!TextUtils.isEmpty(style)) {
|
||||
initalStyle = style;
|
||||
styleUrl = style;
|
||||
}
|
||||
|
||||
// MyLocationView
|
||||
@@ -429,7 +429,7 @@ public class MapView extends FrameLayout {
|
||||
, savedInstanceState.getInt(MapboxConstants.STATE_ATTRIBUTION_MARGIN_BOTTOM));
|
||||
|
||||
mapboxMap.setDebugActive(savedInstanceState.getBoolean(MapboxConstants.STATE_DEBUG_ACTIVE));
|
||||
mapboxMap.setStyleUrl(savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL));
|
||||
styleUrl = savedInstanceState.getString(MapboxConstants.STATE_STYLE_URL);
|
||||
|
||||
// User location
|
||||
try {
|
||||
@@ -573,7 +573,7 @@ public class MapView extends FrameLayout {
|
||||
*/
|
||||
@UiThread
|
||||
public void onPause() {
|
||||
// Register for connectivity changes
|
||||
// Unregister for connectivity changes
|
||||
if (connectivityReceiver != null) {
|
||||
getContext().unregisterReceiver(connectivityReceiver);
|
||||
connectivityReceiver = null;
|
||||
@@ -594,10 +594,9 @@ public class MapView extends FrameLayout {
|
||||
nativeMapView.update();
|
||||
myLocationView.onResume();
|
||||
|
||||
if (styleUrl == null) {
|
||||
// user supplied style through xml
|
||||
// user has failed to supply a style url
|
||||
setStyleUrl(initalStyle == null ? Style.MAPBOX_STREETS : initalStyle);
|
||||
// In case that no style was set or was loaded through MapboxMapOptions
|
||||
if (!styleWasSet) {
|
||||
setStyleUrl(styleUrl);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -860,6 +859,7 @@ public class MapView extends FrameLayout {
|
||||
|
||||
styleUrl = url;
|
||||
nativeMapView.setStyleUrl(url);
|
||||
styleWasSet = true;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
Reference in New Issue
Block a user