From bfac9d700f816041f2205924c1dea1e018d6bc8b Mon Sep 17 00:00:00 2001 From: Mikhail Pozdnyakov Date: Thu, 21 Mar 2019 17:20:39 +0200 Subject: [android] Fix style code generation if array default value is missing --- .../java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java | 2 +- platform/android/scripts/generate-style-code.js | 6 +++++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java index 94e6303c3a..ae2c6d98f6 100644 --- a/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java +++ b/platform/android/MapboxGLAndroidSDKTestApp/src/androidTest/java/com/mapbox/mapboxsdk/testapp/style/SymbolLayerTest.java @@ -598,7 +598,7 @@ public class SymbolLayerTest extends BaseLayerTest { assertNull(layer.getTextVariableAnchor().getValue()); // Set and Get - String[] propertyValue = [undefined]; + String[] propertyValue = new String[0]; layer.setProperties(textVariableAnchor(propertyValue)); assertEquals(layer.getTextVariableAnchor().getValue(), propertyValue); } diff --git a/platform/android/scripts/generate-style-code.js b/platform/android/scripts/generate-style-code.js index 6f64a38a67..688a3aa527 100755 --- a/platform/android/scripts/generate-style-code.js +++ b/platform/android/scripts/generate-style-code.js @@ -198,7 +198,11 @@ global.defaultValueJava = function(property) { switch (property.value) { case 'string': case 'enum': - return '[' + property['default'] + "]"; + if (property['default'] !== undefined) { + return '[' + property['default'] + ']'; + } else { + return 'new String[0]'; + } case 'number': var result ='new Float[] {'; for (var i = 0; i < property.length; i++) { -- cgit v1.2.1