Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,11 @@ public interface ClusterRenderer<T extends ClusterItem> {
*/
void setAnimation(boolean animate);

/**
* Sets the length of the animation in milliseconds.
*/
void setAnimationDuration(long animationDurationMs);

/**
* Called when the view is added.
*/
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -81,6 +81,7 @@ public class DefaultClusterRenderer<T extends ClusterItem> implements ClusterRen
private final ClusterManager<T> mClusterManager;
private final float mDensity;
private boolean mAnimate;
private long mAnimationDurationMs;
private final Executor mExecutor = Executors.newSingleThreadExecutor();

private static final int[] BUCKETS = {10, 20, 50, 100, 200, 500, 1000};
Expand Down Expand Up @@ -134,6 +135,7 @@ public class DefaultClusterRenderer<T extends ClusterItem> implements ClusterRen
public DefaultClusterRenderer(Context context, GoogleMap map, ClusterManager<T> clusterManager) {
mMap = map;
mAnimate = true;
mAnimationDurationMs = 300;
mDensity = context.getResources().getDisplayMetrics().density;
mIconGenerator = new IconGenerator(context);
mIconGenerator.setContentView(makeSquareTextView(context));
Expand Down Expand Up @@ -575,6 +577,15 @@ public void setAnimation(boolean animate) {
mAnimate = animate;
}

/**
* {@inheritDoc} The default duration is 300 milliseconds.
* @param animationDurationMs long: The length of the animation, in milliseconds. This value cannot be negative.
*/
@Override
public void setAnimationDuration(long animationDurationMs) {
mAnimationDurationMs = animationDurationMs;
}

private Set<? extends Cluster<T>> immutableOf(Set<? extends Cluster<T>> clusters) {
return clusters != null ? Collections.unmodifiableSet(clusters) : Collections.emptySet();
}
Expand Down Expand Up @@ -1138,6 +1149,7 @@ private AnimationTask(MarkerWithPosition markerWithPosition, LatLng from, LatLng
public void perform() {
ValueAnimator valueAnimator = ValueAnimator.ofFloat(0.0f, 1.0f);
valueAnimator.setInterpolator(ANIMATION_INTERP);
valueAnimator.setDuration(mAnimationDurationMs);
valueAnimator.addUpdateListener(this);
valueAnimator.addListener(this);
valueAnimator.start();
Expand Down