-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathcode.txt
64 lines (55 loc) · 1.67 KB
/
code.txt
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
package com.hit.wi.t9.settings;
import android.view.animation.AccelerateInterpolator;
import android.view.animation.Animation;
import android.view.animation.DecelerateInterpolator;
import android.view.animation.TranslateAnimation;
/**
* 工厂方法,生成一个飞进飞出的动画
* @author dagger
*
*/
public class FlyAnimationFactory{
public static final int FLYIN_ANIMATION = 0;
public static final int FLYOUT_ANIMATION = 1;
float mWidth, mHeight, mY, mFromX, mToX;
long mDuration;
int mInterpolatorType;
TranslateAnimation animation;
private static FlyAnimationFactory mFlyAnimationFactory = null;
private FlyAnimationFactory(){
}
public static FlyAnimationFactory getInstance(){
if (mFlyAnimationFactory == null){
mFlyAnimationFactory = new FlyAnimationFactory();
}
return mFlyAnimationFactory;
}
/**
*
* @param fromX ABSOLUTE
* @param toX ABSOLUTE
* @param Y ABSOLUTE
* @param duration 速度变化区间从1~1000,动画持续时间
* @param interpolatorType
* @return
*/
public TranslateAnimation getFlyAnimation(float fromX, float toX, float Y, long duration, int interpolatorType){
this.mFromX = fromX;
this.mToX = toX;
this.mY = Y;
this.mDuration = duration;
this.mInterpolatorType = interpolatorType;
animation = new TranslateAnimation(Animation.ABSOLUTE, mFromX,
Animation.ABSOLUTE, mToX,
Animation.ABSOLUTE, mY,
Animation.ABSOLUTE, mY);
if (interpolatorType == FLYIN_ANIMATION){
animation.setInterpolator(new DecelerateInterpolator());
}else{
animation.setInterpolator(new AccelerateInterpolator());
}
animation.setFillAfter(true);
animation.setDuration(mDuration);
return animation;
}
}