33
33
import android .os .MessageQueue ;
34
34
import android .util .SparseArray ;
35
35
import android .view .ViewGroup ;
36
+ import android .view .animation .AccelerateDecelerateInterpolator ;
37
+ import android .view .animation .AccelerateInterpolator ;
38
+ import android .view .animation .BounceInterpolator ;
36
39
import android .view .animation .DecelerateInterpolator ;
40
+ import android .view .animation .LinearInterpolator ;
37
41
38
42
import androidx .annotation .NonNull ;
39
43
import androidx .annotation .StyleRes ;
44
+ import androidx .interpolator .view .animation .FastOutSlowInInterpolator ;
40
45
41
46
import com .google .android .gms .maps .GoogleMap ;
42
47
import com .google .android .gms .maps .Projection ;
59
64
import java .util .ArrayList ;
60
65
import java .util .Collections ;
61
66
import java .util .HashMap ;
62
- import java .util .Iterator ;
63
67
import java .util .LinkedList ;
64
68
import java .util .List ;
65
69
import java .util .Map ;
@@ -85,10 +89,55 @@ public class ClusterRendererMultipleItems<T extends ClusterItem> implements Clus
85
89
private long mAnimationDurationMs ;
86
90
private final Executor mExecutor = Executors .newSingleThreadExecutor ();
87
91
private final Queue <AnimationTask > ongoingAnimations = new LinkedList <>();
92
+ private static TimeInterpolator animationInterp = new DecelerateInterpolator ();
88
93
89
94
private static final int [] BUCKETS = {10 , 20 , 50 , 100 , 200 , 500 , 1000 };
90
95
private ShapeDrawable mColoredCircleBackground ;
91
96
97
+ enum AnimationType {
98
+ LINEAR ,
99
+ EASE_IN ,
100
+ EASE_OUT ,
101
+ EASE_IN_OUT ,
102
+ FAST_OUT_SLOW_IN ,
103
+ BOUNCE ,
104
+ ACCELERATE ,
105
+ DECELERATE
106
+ }
107
+
108
+ void setAnimationType (AnimationType type ) {
109
+ switch (type ) {
110
+ case LINEAR :
111
+ animationInterp = new LinearInterpolator ();
112
+ break ;
113
+ case EASE_IN :
114
+ animationInterp = new AccelerateInterpolator ();
115
+ break ;
116
+ case EASE_OUT :
117
+ animationInterp = new DecelerateInterpolator ();
118
+ break ;
119
+ case EASE_IN_OUT :
120
+ animationInterp = new AccelerateDecelerateInterpolator ();
121
+ break ;
122
+ case FAST_OUT_SLOW_IN :
123
+ animationInterp = new FastOutSlowInInterpolator ();
124
+ break ;
125
+ case BOUNCE :
126
+ animationInterp = new BounceInterpolator ();
127
+ break ;
128
+ case ACCELERATE :
129
+ animationInterp = new AccelerateInterpolator ();
130
+ break ;
131
+ case DECELERATE :
132
+ animationInterp = new DecelerateInterpolator ();
133
+ break ;
134
+ default :
135
+ animationInterp = new LinearInterpolator ();
136
+ break ;
137
+ }
138
+ }
139
+
140
+
92
141
/**
93
142
* Markers that are currently on the map.
94
143
*/
@@ -281,6 +330,7 @@ private class ViewModifier extends Handler {
281
330
public ViewModifier (Looper looper ) {
282
331
super (looper );
283
332
}
333
+
284
334
private static final int RUN_TASK = 0 ;
285
335
private static final int TASK_FINISHED = 1 ;
286
336
private boolean mViewModificationInProgress = false ;
@@ -1121,7 +1171,6 @@ public int hashCode() {
1121
1171
}
1122
1172
}
1123
1173
1124
- private static final TimeInterpolator ANIMATION_INTERP = new DecelerateInterpolator ();
1125
1174
1126
1175
/**
1127
1176
* Animates a markerWithPosition from one position to another. TODO: improve performance for
@@ -1145,7 +1194,7 @@ private AnimationTask(MarkerWithPosition markerWithPosition, LatLng from, LatLng
1145
1194
1146
1195
public void perform () {
1147
1196
valueAnimator = ValueAnimator .ofFloat (0.0f , 1.0f );
1148
- valueAnimator .setInterpolator (ANIMATION_INTERP );
1197
+ valueAnimator .setInterpolator (animationInterp );
1149
1198
valueAnimator .setDuration (mAnimationDurationMs );
1150
1199
valueAnimator .addUpdateListener (this );
1151
1200
valueAnimator .addListener (this );
0 commit comments