diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2018-11-06 12:37:14 +0100 |
---|---|---|
committer | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2018-11-06 17:39:13 +0100 |
commit | bb55bae76db4454affa2cacca956e726a2b43a4b (patch) | |
tree | 83bf5561aa60f7deae423a54760908277bc88824 /platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox | |
parent | 39423cc653c60d5948d6eda0161d05efd633dad6 (diff) | |
download | qtlocation-mapboxgl-bb55bae76db4454affa2cacca956e726a2b43a4b.tar.gz |
[android] verify if `text-field` is not null before performing compatibility operations
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox')
2 files changed, 18 insertions, 8 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java index 079292c512..81d5bcfd8c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/SymbolLayer.java @@ -372,13 +372,18 @@ public class SymbolLayer extends Layer { if (propertyValue.isExpression()) { return (PropertyValue<String>) propertyValue; } else { + String text = null; + Formatted formatted = (Formatted) nativeGetTextField(); - StringBuilder builder = new StringBuilder(); - for (FormattedSection section : formatted.getFormattedSections()) { - builder.append(section.getText()); + if (formatted != null) { + StringBuilder builder = new StringBuilder(); + for (FormattedSection section : formatted.getFormattedSections()) { + builder.append(section.getText()); + } + text = builder.toString(); } - return (PropertyValue<String>) new PropertyValue("text-field", builder.toString()); + return (PropertyValue<String>) new PropertyValue("text-field", text); } } diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs index 0e6cad78f6..c6ae12b028 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/layer.java.ejs @@ -181,13 +181,18 @@ public class <%- camelize(type) %>Layer extends Layer { if (propertyValue.isExpression()) { return (PropertyValue<String>) propertyValue; } else { + String text = null; + Formatted formatted = (Formatted) nativeGetTextField(); - StringBuilder builder = new StringBuilder(); - for (FormattedSection section : formatted.getFormattedSections()) { - builder.append(section.getText()); + if (formatted != null) { + StringBuilder builder = new StringBuilder(); + for (FormattedSection section : formatted.getFormattedSections()) { + builder.append(section.getText()); + } + text = builder.toString(); } - return (PropertyValue<String>) new PropertyValue("text-field", builder.toString()); + return (PropertyValue<String>) new PropertyValue("text-field", text); } <% } else { -%> return (PropertyValue<<%- propertyType(property) %>>) new PropertyValue("<%- property.name %>", nativeGet<%- camelize(property.name) %>()); |