[android] - use builder json/url for constructing style object

This commit is contained in:
Tobrun
2018-12-05 18:21:40 +02:00
committed by Tobrun
parent f8f8e0b749
commit 981689477b
3 changed files with 18 additions and 13 deletions

View File

@@ -759,10 +759,10 @@ public final class MapboxMap {
}
style = builder.build(nativeMapView);
if (!TextUtils.isEmpty(style.getUrl())) {
nativeMapView.setStyleUrl(style.getUrl());
} else if (!TextUtils.isEmpty(style.getJson())) {
nativeMapView.setStyleJson(style.getJson());
if (!TextUtils.isEmpty(builder.getUrl())) {
nativeMapView.setStyleUrl(builder.getUrl());
} else if (!TextUtils.isEmpty(builder.getJson())) {
nativeMapView.setStyleJson(builder.getJson());
} else {
// user didn't provide a `from` component,
// flag the style as loaded,

View File

@@ -34,8 +34,6 @@ public class Style {
private final HashMap<String, Layer> layers = new HashMap<>();
private final HashMap<String, Bitmap> images = new HashMap<>();
private final Builder builder;
private String styleUrl;
private String styleJson;
private boolean styleLoaded;
/**
@@ -46,8 +44,6 @@ public class Style {
*/
private Style(@NonNull Builder builder, @NonNull NativeMapView nativeMapView) {
this.builder = builder;
styleUrl = builder.styleUrl;
styleJson = builder.styleJson;
this.nativeMapView = nativeMapView;
}
@@ -56,9 +52,9 @@ public class Style {
*
* @return the style url
*/
@Nullable
@NonNull
public String getUrl() {
return styleUrl;
return nativeMapView.getStyleUrl();
}
/**
@@ -66,9 +62,9 @@ public class Style {
*
* @return the style json
*/
@Nullable
@NonNull
public String getJson() {
return styleJson;
return nativeMapView.getStyleJson();
}
//
@@ -599,6 +595,14 @@ public class Style {
return this;
}
String getUrl() {
return styleUrl;
}
String getJson() {
return styleJson;
}
/**
* Build the composed style.
*/