- Notifications
You must be signed in to change notification settings - Fork 10
Expand file tree
/
Copy pathAnimHelper.java
More file actions
Latest commit
90 lines (73 loc) · 3.95 KB
/
Copy pathAnimHelper.java
File metadata and controls
90 lines (73 loc) · 3.95 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
84
85
86
87
88
89
90
packagecom.realmo.utils;
importandroid.content.Context;
importandroid.support.v4.view.ViewCompat;
importandroid.support.v4.view.ViewPropertyAnimatorListener;
importandroid.support.v4.view.animation.FastOutSlowInInterpolator;
importandroid.view.View;
importandroid.view.ViewGroup;
importandroid.view.animation.Interpolator;
publicclassAnimHelper {
privateAnimHelper() {
thrownewRuntimeException("AnimHelper cannot be initialized!");
}
publicstaticfinalInterpolatorINTERPOLATOR = newFastOutSlowInInterpolator();
publicstaticfinalintDURATION = 300;
publicstaticvoidscaleShow(Viewview, ViewPropertyAnimatorListenerlistener) {
ViewCompat.animate(view).scaleX(1.0f).scaleY(1.0f).alpha(1.0f).setDuration(DURATION).setListener(listener).setInterpolator(INTERPOLATOR).withLayer().start();
}
publicstaticvoidscaleHide(Viewview, ViewPropertyAnimatorListenerlistener) {
ViewCompat.animate(view).scaleX(0f).scaleY(0f).alpha(0f).setDuration(DURATION).setListener(listener).setInterpolator(INTERPOLATOR).withLayer().start();
}
publicstaticvoidalphaShow(Viewview, ViewPropertyAnimatorListenerlistener) {
ViewCompat.animate(view).alpha(1.0f).setDuration(DURATION).setListener(listener).setInterpolator(INTERPOLATOR).withLayer().start();
}
publicstaticvoidalphaHide(Viewview, ViewPropertyAnimatorListenerlistener) {
ViewCompat.animate(view).alpha(0f).setDuration(DURATION).setListener(listener).setInterpolator(INTERPOLATOR).withLayer().start();
}
publicstaticvoidtranslateUp(Viewview, ViewPropertyAnimatorListenerlistener) {
ViewCompat.animate(view).translationY(0).setDuration(DURATION).setListener(listener).setInterpolator(INTERPOLATOR).withLayer().start();
}
publicstaticvoidtranslateDown(Viewview, ViewPropertyAnimatorListenerlistener) {
intheight = view.getHeight();
ViewGroup.LayoutParamsparams = view.getLayoutParams();
ViewGroup.MarginLayoutParamslayoutParams = paramsinstanceofViewGroup.MarginLayoutParams ? ((ViewGroup.MarginLayoutParams) params) : null;
if (layoutParams != null) height += layoutParams.bottomMargin;
ViewCompat.animate(view).translationY(height).setDuration(DURATION).setListener(listener).setInterpolator(INTERPOLATOR).withLayer().start();
}
publicstaticfloatfloatEvaluator(floatoriginalSize, floatfinalSize, floatpercent) {
return (finalSize - originalSize) * percent + originalSize;
}
publicstaticintargbEvaluator(intstartColor, intendColor, floatpercent) {
intstartA = (startColor >> 24) & 0xff;
intstartR = (startColor >> 16) & 0xff;
intstartG = (startColor >> 8) & 0xff;
intstartB = startColor & 0xff;
intendA = (endColor >> 24) & 0xff;
intendR = (endColor >> 16) & 0xff;
intendG = (endColor >> 8) & 0xff;
intendB = endColor & 0xff;
return ((startA + (int) (percent * (endA - startA))) << 24) |
((startR + (int) (percent * (endR - startR))) << 16) |
((startG + (int) (percent * (endG - startG))) << 8) |
((startB + (int) (percent * (endB - startB))));
}
publicstaticfloatscaleEvaluator(floatoriginalSize, floatfinalSize, floatpercent) {
floatcalcSize = (finalSize - originalSize) * percent + originalSize;
returncalcSize / originalSize;
}
/*
// 获得状态栏的高度
public static int getStatusBarHeight(Context context) {
int statusHeight = -1;
try {
Class<?> clazz = Class.forName("com.android.internal.R$dimen");
Object object = clazz.newInstance();
int height = Integer.parseInt(clazz.getField("status_bar_height").get(object).toString());
statusHeight = context.getResources().getDimensionPixelSize(height);
} catch (Exception e) {
e.printStackTrace();
}
return statusHeight;
}
*/
}