Rework setStyleUrl() logic to avoid NPE as per #6512 (#6574)

* [android] Rework setStyleUrl() logic to avoid NPE as per #6512

* fixup brackets + comment
This commit is contained in:
Tobrun
2016-10-04 15:19:25 +02:00
committed by GitHub
parent 26c32f5c11
commit e103d92b18

View File

@@ -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;
}
/**