diff options
author | Łukasz Paczos <lukas.paczos@gmail.com> | 2018-11-19 16:45:05 +0100 |
---|---|---|
committer | Łukasz Paczos <lukasz.paczos@mapbox.com> | 2018-11-20 12:20:50 +0100 |
commit | e08e143c123c0fd542f1a1a1a615d284ecd2db45 (patch) | |
tree | 34819dda7a0184b914e36e052381a533d0d29440 /platform/android/MapboxGLAndroidSDK/src/main/java/com | |
parent | d0520d02f123557c7c7361053ab1e56318912fa3 (diff) | |
download | qtlocation-mapboxgl-e08e143c123c0fd542f1a1a1a615d284ecd2db45.tar.gz |
[android] getting a constant layer filter fix
Diffstat (limited to 'platform/android/MapboxGLAndroidSDK/src/main/java/com')
12 files changed, 47 insertions, 37 deletions
diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java index 7bb918fb4f..447d51e5b1 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/expressions/Expression.java @@ -4485,7 +4485,7 @@ public class Expression { * @param jsonElement the json element to convert * @return the expression */ - private static Expression convert(@NonNull JsonElement jsonElement) { + public static Expression convert(@NonNull JsonElement jsonElement) { if (jsonElement instanceof JsonArray) { return convert((JsonArray) jsonElement); } else if (jsonElement instanceof JsonPrimitive) { diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java index a89f012fe6..af37a8bee2 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/BackgroundLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java index 76f7b2f9fa..e805b031b8 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/CircleLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; @@ -120,12 +121,12 @@ public class CircleLayer extends Layer { @Nullable public Expression getFilter() { checkThread(); - Expression expression = null; - JsonArray array = (JsonArray) nativeGetFilter(); - if (array != null) { - expression = Expression.Converter.convert(array); + JsonElement jsonElement = nativeGetFilter(); + if (jsonElement != null) { + return Expression.Converter.convert(jsonElement); + } else { + return null; } - return expression; } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java index 864d1d5a20..fada0c483c 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillExtrusionLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; @@ -120,12 +121,12 @@ public class FillExtrusionLayer extends Layer { @Nullable public Expression getFilter() { checkThread(); - Expression expression = null; - JsonArray array = (JsonArray) nativeGetFilter(); - if (array != null) { - expression = Expression.Converter.convert(array); + JsonElement jsonElement = nativeGetFilter(); + if (jsonElement != null) { + return Expression.Converter.convert(jsonElement); + } else { + return null; } - return expression; } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java index 14c80c044c..fba0237352 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/FillLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; @@ -120,12 +121,12 @@ public class FillLayer extends Layer { @Nullable public Expression getFilter() { checkThread(); - Expression expression = null; - JsonArray array = (JsonArray) nativeGetFilter(); - if (array != null) { - expression = Expression.Converter.convert(array); + JsonElement jsonElement = nativeGetFilter(); + if (jsonElement != null) { + return Expression.Converter.convert(jsonElement); + } else { + return null; } - return expression; } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java index 730471190c..3eccd4509a 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HeatmapLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; @@ -120,12 +121,12 @@ public class HeatmapLayer extends Layer { @Nullable public Expression getFilter() { checkThread(); - Expression expression = null; - JsonArray array = (JsonArray) nativeGetFilter(); - if (array != null) { - expression = Expression.Converter.convert(array); + JsonElement jsonElement = nativeGetFilter(); + if (jsonElement != null) { + return Expression.Converter.convert(jsonElement); + } else { + return null; } - return expression; } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java index 22df96f2c6..7e503597ef 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/HillshadeLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java index ea89330c95..e370a366f5 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/Layer.java @@ -104,7 +104,7 @@ public abstract class Layer { @Keep protected native void nativeSetFilter(Object[] filter); - @NonNull + @Nullable @Keep protected native JsonElement nativeGetFilter(); diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java index 662d7c7ea7..d6823e5823 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/LineLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; @@ -120,12 +121,12 @@ public class LineLayer extends Layer { @Nullable public Expression getFilter() { checkThread(); - Expression expression = null; - JsonArray array = (JsonArray) nativeGetFilter(); - if (array != null) { - expression = Expression.Converter.convert(array); + JsonElement jsonElement = nativeGetFilter(); + if (jsonElement != null) { + return Expression.Converter.convert(jsonElement); + } else { + return null; } - return expression; } /** diff --git a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java index f2c5b03a27..2fd658dc98 100644 --- a/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java +++ b/platform/android/MapboxGLAndroidSDK/src/main/java/com/mapbox/mapboxsdk/style/layers/RasterLayer.java @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; 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 0cbbc17d98..25c0a2bb32 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 @@ -11,6 +11,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; import com.mapbox.mapboxsdk.style.types.Formatted; @@ -122,12 +123,12 @@ public class SymbolLayer extends Layer { @Nullable public Expression getFilter() { checkThread(); - Expression expression = null; - JsonArray array = (JsonArray) nativeGetFilter(); - if (array != null) { - expression = Expression.Converter.convert(array); + JsonElement jsonElement = nativeGetFilter(); + if (jsonElement != null) { + return Expression.Converter.convert(jsonElement); + } else { + return null; } - return expression; } /** 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 a11852be68..60bbe941a6 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 @@ -16,6 +16,7 @@ import android.support.annotation.UiThread; import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor; import com.google.gson.JsonArray; +import com.google.gson.JsonElement; import com.mapbox.mapboxsdk.style.expressions.Expression; import com.mapbox.mapboxsdk.style.layers.TransitionOptions; <% if (type === 'symbol') { -%> @@ -148,12 +149,12 @@ public class <%- camelize(type) %>Layer extends Layer { @Nullable public Expression getFilter() { checkThread(); - Expression expression = null; - JsonArray array = (JsonArray) nativeGetFilter(); - if (array != null) { - expression = Expression.Converter.convert(array); + JsonElement jsonElement = nativeGetFilter(); + if (jsonElement != null) { + return Expression.Converter.convert(jsonElement); + } else { + return null; } - return expression; } <% } -%> |