@@ -174,16 +174,31 @@ protected void onDraw(Canvas canvas) {
174
174
}
175
175
176
176
private void animateInHorizontal () {
177
- ValueAnimator animator = ValueAnimator .ofFloat (0.0f , getHeight ());
178
- animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
179
- @ Override
180
- public void onAnimationUpdate (ValueAnimator valueAnimator ) {
181
- pathIn = new Path ();
182
- pathIn .moveTo (0.0f , (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
183
- pathIn .lineTo (getWidth (), (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
184
- rotatable .setPathIn (pathIn );
185
- }
186
- });
177
+ ValueAnimator animator ;
178
+ if (!rotatable .getApplyHorizontal ()) {
179
+ animator = ValueAnimator .ofFloat (0.0f , getHeight ());
180
+ animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
181
+ @ Override
182
+ public void onAnimationUpdate (ValueAnimator valueAnimator ) {
183
+ pathIn = new Path ();
184
+ pathIn .moveTo (0.0f , (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
185
+ pathIn .lineTo (getWidth (), (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
186
+ rotatable .setPathIn (pathIn );
187
+ }
188
+ });
189
+ }
190
+ else {
191
+ animator = ValueAnimator .ofFloat (-getWidth (),0.0f );
192
+ animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
193
+ @ Override
194
+ public void onAnimationUpdate (ValueAnimator valueAnimator ) {
195
+ pathIn = new Path ();
196
+ pathIn .moveTo ((Float ) valueAnimator .getAnimatedValue (), 2 *getHeight ()/3.0f );
197
+ pathIn .lineTo ((Float ) valueAnimator .getAnimatedValue () +90000.0F , 2 *getHeight ()/3.0f );
198
+ rotatable .setPathIn (pathIn );
199
+ }
200
+ });
201
+ }
187
202
animator .addListener (new AnimatorListenerAdapter ()
188
203
{
189
204
@ Override
@@ -198,16 +213,31 @@ public void onAnimationEnd(Animator animation)
198
213
}
199
214
200
215
private void animateOutHorizontal () {
201
- ValueAnimator animator = ValueAnimator .ofFloat (getHeight (), getHeight () * 2.0f );
202
- animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
203
- @ Override
204
- public void onAnimationUpdate (ValueAnimator valueAnimator ) {
205
- pathOut = new Path ();
206
- pathOut .moveTo (0.0f , (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
207
- pathOut .lineTo (getWidth (), (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
208
- rotatable .setPathOut (pathOut );
209
- }
210
- });
216
+ ValueAnimator animator ;
217
+ if (!rotatable .getApplyHorizontal ()) {
218
+ animator = ValueAnimator .ofFloat (getHeight (), getHeight () * 2.0f );
219
+ animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
220
+ @ Override
221
+ public void onAnimationUpdate (ValueAnimator valueAnimator ) {
222
+ pathOut = new Path ();
223
+ pathOut .moveTo (0.0f , (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
224
+ pathOut .lineTo (getWidth (), (Float ) valueAnimator .getAnimatedValue () - paint .getFontMetrics ().bottom );
225
+ rotatable .setPathOut (pathOut );
226
+ }
227
+ });
228
+ }
229
+ else {
230
+ animator = ValueAnimator .ofFloat (0.0f ,getWidth ()+10.0f );
231
+ animator .addUpdateListener (new ValueAnimator .AnimatorUpdateListener () {
232
+ @ Override
233
+ public void onAnimationUpdate (ValueAnimator valueAnimator ) {
234
+ pathOut = new Path ();
235
+ pathOut .moveTo ((Float ) valueAnimator .getAnimatedValue (), 2 *getHeight ()/3.0f );
236
+ pathOut .lineTo ((Float ) valueAnimator .getAnimatedValue () + 90000.0F , 2 *getHeight ()/3.0f );
237
+ rotatable .setPathOut (pathOut );
238
+ }
239
+ });
240
+ }
211
241
animator .setInterpolator (rotatable .getInterpolator ());
212
242
animator .setDuration (rotatable .getAnimationDuration ());
213
243
animator .start ();
0 commit comments