Skip to content
This repository has been archived by the owner on Aug 8, 2023. It is now read-only.

Commit

Permalink
[android] - add UI thread checking when invoking Layer and Source met…
Browse files Browse the repository at this point in the history
…hods
  • Loading branch information
tobrun committed May 24, 2018
1 parent 5e6298d commit fd67d90
Show file tree
Hide file tree
Showing 19 changed files with 378 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,6 +36,7 @@ public BackgroundLayer(long nativePtr) {
* @param layerId the id of the layer
*/
public BackgroundLayer(String layerId) {
super();
initialize(layerId);
}

Expand All @@ -61,6 +62,7 @@ public BackgroundLayer withProperties(@NonNull PropertyValue<?>... properties) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getBackgroundColor() {
checkThread();
return (PropertyValue<String>) new PropertyValue("background-color", nativeGetBackgroundColor());
}

Expand All @@ -72,6 +74,7 @@ public PropertyValue<String> getBackgroundColor() {
*/
@ColorInt
public int getBackgroundColorAsInt() {
checkThread();
PropertyValue<String> value = getBackgroundColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
Expand All @@ -86,6 +89,7 @@ public int getBackgroundColorAsInt() {
* @return transition options for String
*/
public TransitionOptions getBackgroundColorTransition() {
checkThread();
return nativeGetBackgroundColorTransition();
}

Expand All @@ -95,6 +99,7 @@ public TransitionOptions getBackgroundColorTransition() {
* @param options transition options for String
*/
public void setBackgroundColorTransition(TransitionOptions options) {
checkThread();
nativeSetBackgroundColorTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -105,6 +110,7 @@ public void setBackgroundColorTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getBackgroundPattern() {
checkThread();
return (PropertyValue<String>) new PropertyValue("background-pattern", nativeGetBackgroundPattern());
}

Expand All @@ -114,6 +120,7 @@ public PropertyValue<String> getBackgroundPattern() {
* @return transition options for String
*/
public TransitionOptions getBackgroundPatternTransition() {
checkThread();
return nativeGetBackgroundPatternTransition();
}

Expand All @@ -123,6 +130,7 @@ public TransitionOptions getBackgroundPatternTransition() {
* @param options transition options for String
*/
public void setBackgroundPatternTransition(TransitionOptions options) {
checkThread();
nativeSetBackgroundPatternTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -133,6 +141,7 @@ public void setBackgroundPatternTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getBackgroundOpacity() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("background-opacity", nativeGetBackgroundOpacity());
}

Expand All @@ -142,6 +151,7 @@ public PropertyValue<Float> getBackgroundOpacity() {
* @return transition options for Float
*/
public TransitionOptions getBackgroundOpacityTransition() {
checkThread();
return nativeGetBackgroundOpacityTransition();
}

Expand All @@ -151,6 +161,7 @@ public TransitionOptions getBackgroundOpacityTransition() {
* @param options transition options for Float
*/
public void setBackgroundOpacityTransition(TransitionOptions options) {
checkThread();
nativeSetBackgroundOpacityTransition(options.getDuration(), options.getDelay());
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,6 +37,7 @@ public CircleLayer(long nativePtr) {
* @param sourceId the id of the source
*/
public CircleLayer(String layerId, String sourceId) {
super();
initialize(layerId, sourceId);
}

Expand All @@ -48,6 +49,7 @@ public CircleLayer(String layerId, String sourceId) {
* @param sourceLayer the source layer to set
*/
public void setSourceLayer(String sourceLayer) {
checkThread();
nativeSetSourceLayer(sourceLayer);
}

Expand All @@ -68,6 +70,7 @@ public CircleLayer withSourceLayer(String sourceLayer) {
* @return sourceLayer the source layer to get
*/
public String getSourceLayer() {
checkThread();
return nativeGetSourceLayer();
}

Expand All @@ -77,6 +80,7 @@ public String getSourceLayer() {
* @param filter the expression filter to set
*/
public void setFilter(Expression filter) {
checkThread();
nativeSetFilter(filter.toArray());
}

Expand All @@ -98,6 +102,7 @@ public CircleLayer withFilter(Expression filter) {
*/
@Nullable
public Expression getFilter() {
checkThread();
Expression expression = null;
JsonArray array = (JsonArray) nativeGetFilter();
if (array != null) {
Expand Down Expand Up @@ -126,6 +131,7 @@ public CircleLayer withProperties(@NonNull PropertyValue<?>... properties) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleRadius() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("circle-radius", nativeGetCircleRadius());
}

Expand All @@ -135,6 +141,7 @@ public PropertyValue<Float> getCircleRadius() {
* @return transition options for Float
*/
public TransitionOptions getCircleRadiusTransition() {
checkThread();
return nativeGetCircleRadiusTransition();
}

Expand All @@ -144,6 +151,7 @@ public TransitionOptions getCircleRadiusTransition() {
* @param options transition options for Float
*/
public void setCircleRadiusTransition(TransitionOptions options) {
checkThread();
nativeSetCircleRadiusTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -154,6 +162,7 @@ public void setCircleRadiusTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleColor() {
checkThread();
return (PropertyValue<String>) new PropertyValue("circle-color", nativeGetCircleColor());
}

Expand All @@ -165,6 +174,7 @@ public PropertyValue<String> getCircleColor() {
*/
@ColorInt
public int getCircleColorAsInt() {
checkThread();
PropertyValue<String> value = getCircleColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
Expand All @@ -179,6 +189,7 @@ public int getCircleColorAsInt() {
* @return transition options for String
*/
public TransitionOptions getCircleColorTransition() {
checkThread();
return nativeGetCircleColorTransition();
}

Expand All @@ -188,6 +199,7 @@ public TransitionOptions getCircleColorTransition() {
* @param options transition options for String
*/
public void setCircleColorTransition(TransitionOptions options) {
checkThread();
nativeSetCircleColorTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -198,6 +210,7 @@ public void setCircleColorTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleBlur() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("circle-blur", nativeGetCircleBlur());
}

Expand All @@ -207,6 +220,7 @@ public PropertyValue<Float> getCircleBlur() {
* @return transition options for Float
*/
public TransitionOptions getCircleBlurTransition() {
checkThread();
return nativeGetCircleBlurTransition();
}

Expand All @@ -216,6 +230,7 @@ public TransitionOptions getCircleBlurTransition() {
* @param options transition options for Float
*/
public void setCircleBlurTransition(TransitionOptions options) {
checkThread();
nativeSetCircleBlurTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -226,6 +241,7 @@ public void setCircleBlurTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleOpacity() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("circle-opacity", nativeGetCircleOpacity());
}

Expand All @@ -235,6 +251,7 @@ public PropertyValue<Float> getCircleOpacity() {
* @return transition options for Float
*/
public TransitionOptions getCircleOpacityTransition() {
checkThread();
return nativeGetCircleOpacityTransition();
}

Expand All @@ -244,6 +261,7 @@ public TransitionOptions getCircleOpacityTransition() {
* @param options transition options for Float
*/
public void setCircleOpacityTransition(TransitionOptions options) {
checkThread();
nativeSetCircleOpacityTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -254,6 +272,7 @@ public void setCircleOpacityTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float[]> getCircleTranslate() {
checkThread();
return (PropertyValue<Float[]>) new PropertyValue("circle-translate", nativeGetCircleTranslate());
}

Expand All @@ -263,6 +282,7 @@ public PropertyValue<Float[]> getCircleTranslate() {
* @return transition options for Float[]
*/
public TransitionOptions getCircleTranslateTransition() {
checkThread();
return nativeGetCircleTranslateTransition();
}

Expand All @@ -272,6 +292,7 @@ public TransitionOptions getCircleTranslateTransition() {
* @param options transition options for Float[]
*/
public void setCircleTranslateTransition(TransitionOptions options) {
checkThread();
nativeSetCircleTranslateTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -282,6 +303,7 @@ public void setCircleTranslateTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleTranslateAnchor() {
checkThread();
return (PropertyValue<String>) new PropertyValue("circle-translate-anchor", nativeGetCircleTranslateAnchor());
}

Expand All @@ -292,6 +314,7 @@ public PropertyValue<String> getCircleTranslateAnchor() {
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getCirclePitchScale() {
checkThread();
return (PropertyValue<String>) new PropertyValue("circle-pitch-scale", nativeGetCirclePitchScale());
}

Expand All @@ -302,6 +325,7 @@ public PropertyValue<String> getCirclePitchScale() {
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getCirclePitchAlignment() {
checkThread();
return (PropertyValue<String>) new PropertyValue("circle-pitch-alignment", nativeGetCirclePitchAlignment());
}

Expand All @@ -312,6 +336,7 @@ public PropertyValue<String> getCirclePitchAlignment() {
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleStrokeWidth() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("circle-stroke-width", nativeGetCircleStrokeWidth());
}

Expand All @@ -321,6 +346,7 @@ public PropertyValue<Float> getCircleStrokeWidth() {
* @return transition options for Float
*/
public TransitionOptions getCircleStrokeWidthTransition() {
checkThread();
return nativeGetCircleStrokeWidthTransition();
}

Expand All @@ -330,6 +356,7 @@ public TransitionOptions getCircleStrokeWidthTransition() {
* @param options transition options for Float
*/
public void setCircleStrokeWidthTransition(TransitionOptions options) {
checkThread();
nativeSetCircleStrokeWidthTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -340,6 +367,7 @@ public void setCircleStrokeWidthTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<String> getCircleStrokeColor() {
checkThread();
return (PropertyValue<String>) new PropertyValue("circle-stroke-color", nativeGetCircleStrokeColor());
}

Expand All @@ -351,6 +379,7 @@ public PropertyValue<String> getCircleStrokeColor() {
*/
@ColorInt
public int getCircleStrokeColorAsInt() {
checkThread();
PropertyValue<String> value = getCircleStrokeColor();
if (value.isValue()) {
return rgbaToColor(value.getValue());
Expand All @@ -365,6 +394,7 @@ public int getCircleStrokeColorAsInt() {
* @return transition options for String
*/
public TransitionOptions getCircleStrokeColorTransition() {
checkThread();
return nativeGetCircleStrokeColorTransition();
}

Expand All @@ -374,6 +404,7 @@ public TransitionOptions getCircleStrokeColorTransition() {
* @param options transition options for String
*/
public void setCircleStrokeColorTransition(TransitionOptions options) {
checkThread();
nativeSetCircleStrokeColorTransition(options.getDuration(), options.getDelay());
}

Expand All @@ -384,6 +415,7 @@ public void setCircleStrokeColorTransition(TransitionOptions options) {
*/
@SuppressWarnings("unchecked")
public PropertyValue<Float> getCircleStrokeOpacity() {
checkThread();
return (PropertyValue<Float>) new PropertyValue("circle-stroke-opacity", nativeGetCircleStrokeOpacity());
}

Expand All @@ -393,6 +425,7 @@ public PropertyValue<Float> getCircleStrokeOpacity() {
* @return transition options for Float
*/
public TransitionOptions getCircleStrokeOpacityTransition() {
checkThread();
return nativeGetCircleStrokeOpacityTransition();
}

Expand All @@ -402,6 +435,7 @@ public TransitionOptions getCircleStrokeOpacityTransition() {
* @param options transition options for Float
*/
public void setCircleStrokeOpacityTransition(TransitionOptions options) {
checkThread();
nativeSetCircleStrokeOpacityTransition(options.getDuration(), options.getDelay());
}

Expand Down
Loading

0 comments on commit fd67d90

Please sign in to comment.