-
Notifications
You must be signed in to change notification settings - Fork 522
Expand file tree
/
Copy pathAnimationFactory.java
More file actions
83 lines (65 loc) · 2.58 KB
/
Copy pathAnimationFactory.java
File metadata and controls
83 lines (65 loc) · 2.58 KB
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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
package uk.co.deanwild.materialshowcaseview;
import android.graphics.Point;
import android.view.View;
import android.view.animation.AccelerateDecelerateInterpolator;
import com.nineoldandroids.animation.Animator;
import com.nineoldandroids.animation.AnimatorSet;
import com.nineoldandroids.animation.ObjectAnimator;
public class AnimationFactory implements IAnimationFactory{
private static final String ALPHA = "alpha";
private static final float INVISIBLE = 0f;
private static final float VISIBLE = 1f;
private final AccelerateDecelerateInterpolator interpolator;
public AnimationFactory() {
interpolator = new AccelerateDecelerateInterpolator();
}
@Override
public void fadeInView(View target, long duration, final AnimationStartListener listener) {
ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE, VISIBLE);
oa.setDuration(duration).addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
listener.onAnimationStart();
}
@Override
public void onAnimationEnd(Animator animator) {
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
oa.start();
}
@Override
public void fadeOutView(View target, long duration, final AnimationEndListener listener) {
ObjectAnimator oa = ObjectAnimator.ofFloat(target, ALPHA, INVISIBLE);
oa.setDuration(duration).addListener(new Animator.AnimatorListener() {
@Override
public void onAnimationStart(Animator animator) {
}
@Override
public void onAnimationEnd(Animator animator) {
listener.onAnimationEnd();
}
@Override
public void onAnimationCancel(Animator animator) {
}
@Override
public void onAnimationRepeat(Animator animator) {
}
});
oa.start();
}
@Override
public void animateTargetToPoint(MaterialShowcaseView showcaseView, Point point) {
AnimatorSet set = new AnimatorSet();
ObjectAnimator xAnimator = ObjectAnimator.ofInt(showcaseView, "showcaseX", point.x);
ObjectAnimator yAnimator = ObjectAnimator.ofInt(showcaseView, "showcaseY", point.y);
set.playTogether(xAnimator, yAnimator);
set.setInterpolator(interpolator);
set.start();
}
}