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

Commit

Permalink
[android] - transition options for layer properties
Browse files Browse the repository at this point in the history
  • Loading branch information
tobrun committed Mar 23, 2017
1 parent a3f40d0 commit 22758cf
Show file tree
Hide file tree
Showing 33 changed files with 2,841 additions and 24 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,44 @@
package com.mapbox.mapboxsdk.style;

public class TransitionOptions {

private long duration;
private long delay;

public TransitionOptions(long duration, long delay) {
this.duration = duration;
this.delay = delay;
}

public long getDuration() {
return duration;
}

public long getDelay() {
return delay;
}

@Override
public boolean equals(Object o) {
if (this == o) {
return true;
}
if (o == null || getClass() != o.getClass()) {
return false;
}

TransitionOptions that = (TransitionOptions) o;

if (duration != that.duration) {
return false;
}
return delay == that.delay;
}

@Override
public int hashCode() {
int result = (int) (duration ^ (duration >>> 32));
result = 31 * result + (int) (delay ^ (delay >>> 32));
return result;
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,8 @@

import static com.mapbox.mapboxsdk.utils.ColorUtils.rgbaToColor;

import com.mapbox.mapboxsdk.style.TransitionOptions;

/**
* The background color or pattern of the map.
*
Expand Down Expand Up @@ -75,6 +77,24 @@ public int getBackgroundColorAsInt() {
}
}

/**
* Get the BackgroundColor property transition options
*
* @return transition options for String
*/
public TransitionOptions getBackgroundColorTransition() {
long[] durations = nativeGetBackgroundColorTransition();
return new TransitionOptions(durations[0], durations[1]);
}

/**
* Set the BackgroundColor property transition options
*
* @param options transition options for String
*/
public void setBackgroundColorTransition(TransitionOptions options) {
nativeSetBackgroundColorTransition(options.getDuration(), options.getDelay());
}

/**
* Get the BackgroundPattern property
Expand All @@ -86,6 +106,25 @@ public PropertyValue<String> getBackgroundPattern() {
return (PropertyValue<String>) new PropertyValue("background-pattern", nativeGetBackgroundPattern());
}

/**
* Get the BackgroundPattern property transition options
*
* @return transition options for String
*/
public TransitionOptions getBackgroundPatternTransition() {
long[] durations = nativeGetBackgroundPatternTransition();
return new TransitionOptions(durations[0], durations[1]);
}

/**
* Set the BackgroundPattern property transition options
*
* @param options transition options for String
*/
public void setBackgroundPatternTransition(TransitionOptions options) {
nativeSetBackgroundPatternTransition(options.getDuration(), options.getDelay());
}

/**
* Get the BackgroundOpacity property
*
Expand All @@ -96,12 +135,42 @@ public PropertyValue<Float> getBackgroundOpacity() {
return (PropertyValue<Float>) new PropertyValue("background-opacity", nativeGetBackgroundOpacity());
}

/**
* Get the BackgroundOpacity property transition options
*
* @return transition options for Float
*/
public TransitionOptions getBackgroundOpacityTransition() {
long[] durations = nativeGetBackgroundOpacityTransition();
return new TransitionOptions(durations[0], durations[1]);
}

/**
* Set the BackgroundOpacity property transition options
*
* @param options transition options for Float
*/
public void setBackgroundOpacityTransition(TransitionOptions options) {
nativeSetBackgroundOpacityTransition(options.getDuration(), options.getDelay());
}

private native Object nativeGetBackgroundColor();

private native long[] nativeGetBackgroundColorTransition();

private native void nativeSetBackgroundColorTransition(long duration, long delay);

private native Object nativeGetBackgroundPattern();

private native long[] nativeGetBackgroundPatternTransition();

private native void nativeSetBackgroundPatternTransition(long duration, long delay);

private native Object nativeGetBackgroundOpacity();

private native long[] nativeGetBackgroundOpacityTransition();

private native void nativeSetBackgroundOpacityTransition(long duration, long delay);

@Override
protected native void finalize() throws Throwable;
Expand Down
Loading

0 comments on commit 22758cf

Please sign in to comment.