[android] - add binding integration for expressions (#10654)
This commit is contained in:
File diff suppressed because it is too large
Load Diff
@@ -2,6 +2,7 @@ package com.mapbox.mapboxsdk.style.layers;
|
||||
|
||||
import android.support.annotation.NonNull;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
|
||||
/**
|
||||
@@ -88,6 +89,14 @@ public abstract class Layer {
|
||||
}
|
||||
|
||||
private Object convertValue(Object value) {
|
||||
return value != null && value instanceof Function ? ((Function) value).toValueObject() : value;
|
||||
if (value != null) {
|
||||
if (value instanceof Function) {
|
||||
return ((Function) value).toValueObject();
|
||||
} else if (value instanceof Expression) {
|
||||
return ((Expression) value).toArray();
|
||||
}
|
||||
}
|
||||
return value;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -402,7 +402,7 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_TRANSFORM {}
|
||||
|
||||
// FILL_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
// FILL_TRANSLATE_ANCHOR: Controls the frame of reference for `fill-translate`.
|
||||
|
||||
/**
|
||||
* The fill is translated relative to the map.
|
||||
@@ -414,7 +414,7 @@ public final class Property {
|
||||
public static final String FILL_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
|
||||
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
* Controls the frame of reference for `fill-translate`.
|
||||
*/
|
||||
@StringDef({
|
||||
FILL_TRANSLATE_ANCHOR_MAP,
|
||||
@@ -423,7 +423,7 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface FILL_TRANSLATE_ANCHOR {}
|
||||
|
||||
// LINE_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
// LINE_TRANSLATE_ANCHOR: Controls the frame of reference for `line-translate`.
|
||||
|
||||
/**
|
||||
* The line is translated relative to the map.
|
||||
@@ -435,7 +435,7 @@ public final class Property {
|
||||
public static final String LINE_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
|
||||
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
* Controls the frame of reference for `line-translate`.
|
||||
*/
|
||||
@StringDef({
|
||||
LINE_TRANSLATE_ANCHOR_MAP,
|
||||
@@ -444,7 +444,7 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface LINE_TRANSLATE_ANCHOR {}
|
||||
|
||||
// ICON_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
// ICON_TRANSLATE_ANCHOR: Controls the frame of reference for `icon-translate`.
|
||||
|
||||
/**
|
||||
* Icons are translated relative to the map.
|
||||
@@ -456,7 +456,7 @@ public final class Property {
|
||||
public static final String ICON_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
|
||||
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
* Controls the frame of reference for `icon-translate`.
|
||||
*/
|
||||
@StringDef({
|
||||
ICON_TRANSLATE_ANCHOR_MAP,
|
||||
@@ -465,7 +465,7 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface ICON_TRANSLATE_ANCHOR {}
|
||||
|
||||
// TEXT_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
// TEXT_TRANSLATE_ANCHOR: Controls the frame of reference for `text-translate`.
|
||||
|
||||
/**
|
||||
* The text is translated relative to the map.
|
||||
@@ -477,7 +477,7 @@ public final class Property {
|
||||
public static final String TEXT_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
|
||||
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
* Controls the frame of reference for `text-translate`.
|
||||
*/
|
||||
@StringDef({
|
||||
TEXT_TRANSLATE_ANCHOR_MAP,
|
||||
@@ -486,7 +486,7 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface TEXT_TRANSLATE_ANCHOR {}
|
||||
|
||||
// CIRCLE_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
// CIRCLE_TRANSLATE_ANCHOR: Controls the frame of reference for `circle-translate`.
|
||||
|
||||
/**
|
||||
* The circle is translated relative to the map.
|
||||
@@ -498,7 +498,7 @@ public final class Property {
|
||||
public static final String CIRCLE_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
|
||||
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
* Controls the frame of reference for `circle-translate`.
|
||||
*/
|
||||
@StringDef({
|
||||
CIRCLE_TRANSLATE_ANCHOR_MAP,
|
||||
@@ -549,7 +549,7 @@ public final class Property {
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
public @interface CIRCLE_PITCH_ALIGNMENT {}
|
||||
|
||||
// FILL_EXTRUSION_TRANSLATE_ANCHOR: Controls the translation reference point.
|
||||
// FILL_EXTRUSION_TRANSLATE_ANCHOR: Controls the frame of reference for `fill-extrusion-translate`.
|
||||
|
||||
/**
|
||||
* The fill extrusion is translated relative to the map.
|
||||
@@ -561,7 +561,7 @@ public final class Property {
|
||||
public static final String FILL_EXTRUSION_TRANSLATE_ANCHOR_VIEWPORT = "viewport";
|
||||
|
||||
/**
|
||||
* Controls the translation reference point.
|
||||
* Controls the frame of reference for `fill-extrusion-translate`.
|
||||
*/
|
||||
@StringDef({
|
||||
FILL_EXTRUSION_TRANSLATE_ANCHOR_MAP,
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -11,6 +11,7 @@ import android.support.annotation.ColorInt;
|
||||
|
||||
import com.mapbox.mapboxsdk.style.functions.Function;
|
||||
import com.mapbox.mapboxsdk.style.functions.CameraFunction;
|
||||
import com.mapbox.mapboxsdk.style.expressions.Expression;
|
||||
|
||||
/**
|
||||
* Constructs paint/layout properties for Layers
|
||||
@@ -36,6 +37,7 @@ public class PropertyFactory {
|
||||
* @param function the visibility function
|
||||
* @return property wrapper around a String function
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> PropertyValue<Function<T, String>> visibility(Function<T, String> function) {
|
||||
return new LayoutPropertyValue<>("visibility", function);
|
||||
}
|
||||
@@ -63,6 +65,16 @@ public class PropertyFactory {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param expression an expression statement
|
||||
* @return property wrapper around an expression statement
|
||||
*/
|
||||
public static PropertyValue<Expression> <%- camelizeWithLeadingLowercase(property.name) %>(Expression expression) {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", expression);
|
||||
}
|
||||
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
|
||||
/**
|
||||
@@ -72,6 +84,7 @@ public class PropertyFactory {
|
||||
* @param function a wrapper function for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
@Deprecated
|
||||
public static <T> PropertyValue<Function<T, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(Function<T, <%- propertyType(property) %>> function) {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", function);
|
||||
}
|
||||
@@ -85,6 +98,7 @@ public class PropertyFactory {
|
||||
* @param function a wrapper {@link CameraFunction} for <%- propertyType(property) %>
|
||||
* @return property wrapper around a <%- propertyType(property) %> function
|
||||
*/
|
||||
@Deprecated
|
||||
public static <Z extends Number> PropertyValue<CameraFunction<Z, <%- propertyType(property) %>>> <%- camelizeWithLeadingLowercase(property.name) %>(CameraFunction<Z, <%- propertyType(property) %>> function) {
|
||||
return new PaintPropertyValue<>("<%- property.name %>", function);
|
||||
}
|
||||
@@ -102,6 +116,15 @@ public class PropertyFactory {
|
||||
return new LayoutPropertyValue<>("<%- property.name %>", value);
|
||||
}
|
||||
|
||||
/**
|
||||
* <%- propertyFactoryMethodDoc(property) %>
|
||||
*
|
||||
* @param value a <%- propertyType(property) %> value
|
||||
* @return property wrapper around <%- propertyType(property) %>
|
||||
*/
|
||||
public static PropertyValue<Expression> <%- camelizeWithLeadingLowercase(property.name) %>(Expression value) {
|
||||
return new LayoutPropertyValue<>("<%- property.name %>", value);
|
||||
}
|
||||
|
||||
<% if (supportsPropertyFunction(property)) { -%>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user