[android] expose symbol placement transition duration option

This commit is contained in:
Łukasz Paczos
2019-02-04 13:10:17 +01:00
committed by Łukasz Paczos
parent e45c3926c2
commit 8ad13cd577
7 changed files with 97 additions and 17 deletions

View File

@@ -375,9 +375,16 @@ public class Style {
/**
* <p>
* Set the transition duration for style changes.
* Set the transition options for style changes.
* </p>
* The default value for delay and duration is zero, so any changes take effect without animation.
* If not set, any changes take effect without animation, besides symbols,
* which will fade in/out with a default duration after symbol collision detection.
* <p>
* To disable symbols fade in/out animation,
* pass transition options with {@link TransitionOptions#enablePlacementTransitions} equal to false.
* <p>
* Both {@link TransitionOptions#duration} and {@link TransitionOptions#delay}
* will also change the behavior of the symbols fade in/out animation if the placement transition is enabled.
*
* @param transitionOptions the transition options
*/
@@ -388,9 +395,17 @@ public class Style {
/**
* <p>
* Get the transition for style changes.
* Get the transition options for style changes.
* </p>
* The default value for delay and transition is zero, so any changes take effect without animation.
* By default, any changes take effect without animation, besides symbols,
* which will fade in/out with a default duration after symbol collision detection.
* <p>
* To disable symbols fade in/out animation,
* pass transition options with {@link TransitionOptions#enablePlacementTransitions} equal to false
* into {@link #setTransition(TransitionOptions)}.
* <p>
* Both {@link TransitionOptions#duration} and {@link TransitionOptions#delay}
* will also change the behavior of the symbols fade in/out animation if the placement transition is enabled.
*
* @return TransitionOptions the transition options
*/

View File

@@ -1,8 +1,6 @@
package com.mapbox.mapboxsdk.style.layers;
import android.support.annotation.Keep;
import android.support.annotation.NonNull;
import android.support.annotation.Nullable;
/**
* Resembles transition property from the style specification.
@@ -15,6 +13,8 @@ public class TransitionOptions {
private long duration;
@Keep
private long delay;
@Keep
private boolean enablePlacementTransitions;
/**
* Create a transition property based on duration and a delay.
@@ -23,8 +23,21 @@ public class TransitionOptions {
* @param delay the delay to start the transition
*/
public TransitionOptions(long duration, long delay) {
this(duration, delay, true);
}
/**
* Create a transition property.
*
* @param duration the duration of the transition
* @param delay the delay to start the transition
* @param enablePlacementTransitions the flag that describes whether the fade in/out symbol placement transition
* should be enabled. Defaults to true.
*/
public TransitionOptions(long duration, long delay, boolean enablePlacementTransitions) {
this.duration = duration;
this.delay = delay;
this.enablePlacementTransitions = enablePlacementTransitions;
}
/**
@@ -33,12 +46,30 @@ public class TransitionOptions {
* @param duration the duration of the transition
* @param delay the delay to start the transition
* @return a new transition property object
* @deprecated use {@link #fromTransitionOptions(long, long, boolean)} instead
*/
@Keep
@Deprecated
public static TransitionOptions fromTransitionOptions(long duration, long delay) {
// Invoked from JNI only
return new TransitionOptions(duration, delay);
}
/**
* Create a transition property.
*
* @param duration the duration of the transition
* @param delay the delay to start the transition
* @param enablePlacementTransitions the flag that describes whether the fade in/out symbol placement transition
* should be enabled. Defaults to true.
* @return a new transition property object
*/
@Keep
static TransitionOptions fromTransitionOptions(long duration, long delay, boolean enablePlacementTransitions) {
// Invoked from JNI only
return new TransitionOptions(duration, delay, enablePlacementTransitions);
}
/**
* Get the transition duration.
*
@@ -57,8 +88,17 @@ public class TransitionOptions {
return delay;
}
/**
* Get the flag that describes whether the fade in/out symbol placement transition should be enabled.
*
* @return true if the fade in/out symbol placement transition should be enabled, false otherwise
*/
public boolean isEnablePlacementTransitions() {
return enablePlacementTransitions;
}
@Override
public boolean equals(@Nullable Object o) {
public boolean equals(Object o) {
if (this == o) {
return true;
}
@@ -71,22 +111,26 @@ public class TransitionOptions {
if (duration != that.duration) {
return false;
}
return delay == that.delay;
if (delay != that.delay) {
return false;
}
return enablePlacementTransitions == that.enablePlacementTransitions;
}
@Override
public int hashCode() {
int result = (int) (duration ^ (duration >>> 32));
result = 31 * result + (int) (delay ^ (delay >>> 32));
result = 31 * result + (enablePlacementTransitions ? 1 : 0);
return result;
}
@NonNull
@Override
public String toString() {
return "TransitionOptions{"
+ "duration=" + duration
+ ", delay=" + delay
+ ", enablePlacementTransitions=" + enablePlacementTransitions
+ '}';
}
}