@@ -32,16 +32,16 @@ public class SunLayout extends FrameLayout implements MaterialHeadListener {
32
32
private int mEyesSize ;
33
33
private int mLineLevel ;
34
34
private int mMouthStro ;
35
- private int mLineColor ,mLineWidth ,mLineHeight ;
35
+ private int mLineColor , mLineWidth , mLineHeight ;
36
36
37
37
private ObjectAnimator mAnimator ;
38
38
39
39
public SunLayout (Context context ) {
40
- this (context ,null );
40
+ this (context , null );
41
41
}
42
42
43
43
public SunLayout (Context context , AttributeSet attrs ) {
44
- this (context , attrs ,0 );
44
+ this (context , attrs , 0 );
45
45
}
46
46
47
47
public SunLayout (Context context , AttributeSet attrs , int defStyleAttr ) {
@@ -83,16 +83,18 @@ private void init() {
83
83
84
84
/**
85
85
* 设置太阳半径
86
+ *
86
87
* @param sunRadius
87
88
*/
88
- public void setSunRadius (int sunRadius ){
89
+ public void setSunRadius (int sunRadius ) {
89
90
mSunRadius = sunRadius ;
90
91
mSunView .setSunRadius (mSunRadius );
91
92
mLineView .setSunRadius (mSunRadius );
92
93
}
93
94
94
95
/**
95
96
* 设置太阳颜色
97
+ *
96
98
* @param sunColor
97
99
*/
98
100
public void setSunColor (int sunColor ) {
@@ -102,79 +104,86 @@ public void setSunColor(int sunColor) {
102
104
103
105
/**
104
106
* 设置太阳眼睛大小
107
+ *
105
108
* @param eyesSize
106
109
*/
107
- public void setEyesSize (int eyesSize ){
110
+ public void setEyesSize (int eyesSize ) {
108
111
mEyesSize = eyesSize ;
109
112
mSunView .setEyesSize (mEyesSize );
110
113
}
111
114
112
115
/**
113
116
* 设置太阳线的数量等级
117
+ *
114
118
* @param level
115
119
*/
116
- public void setLineLevel (int level ){
120
+ public void setLineLevel (int level ) {
117
121
mLineLevel = level ;
118
122
mLineView .setLineLevel (mLineLevel );
119
123
}
120
124
121
125
/**
122
126
* 设置太阳线的颜色
127
+ *
123
128
* @param lineColor
124
129
*/
125
- public void setLineColor (int lineColor ){
130
+ public void setLineColor (int lineColor ) {
126
131
mLineColor = lineColor ;
127
132
mLineView .setLineColor (mLineColor );
128
133
}
129
134
130
135
/**
131
136
* 设置太阳线的宽度
137
+ *
132
138
* @param lineWidth
133
139
*/
134
- public void setLineWidth (int lineWidth ){
140
+ public void setLineWidth (int lineWidth ) {
135
141
mLineWidth = lineWidth ;
136
142
mLineView .setLineWidth (mLineWidth );
137
143
}
138
144
139
145
/**
140
146
* 设置太阳线的长度
147
+ *
141
148
* @param lineHeight
142
149
*/
143
- public void setLineHeight (int lineHeight ){
150
+ public void setLineHeight (int lineHeight ) {
144
151
mLineHeight = lineHeight ;
145
152
mLineView .setLineHeight (mLineHeight );
146
153
}
147
154
148
155
/**
149
156
* 设置嘴巴粗细
157
+ *
150
158
* @param mouthStro
151
159
*/
152
- public void setMouthStro (int mouthStro ){
160
+ public void setMouthStro (int mouthStro ) {
153
161
mMouthStro = mouthStro ;
154
162
mSunView .setMouthStro (mMouthStro );
155
163
}
156
164
157
165
158
166
/**
159
167
* 开启转圈圈
168
+ *
160
169
* @param v
161
170
*/
162
- public void startSunLineAnim (View v ){
163
- if (mAnimator == null ){
171
+ public void startSunLineAnim (View v ) {
172
+ if (mAnimator == null ) {
164
173
mAnimator = ObjectAnimator .ofFloat (v , "rotation" , 0f , 720f );
165
- mAnimator .setDuration (7 * 1000 );
174
+ mAnimator .setDuration (7 * 1000 );
166
175
mAnimator .setInterpolator (new LinearInterpolator ());
167
176
mAnimator .setRepeatCount (ValueAnimator .INFINITE );
168
177
}
169
- if (!mAnimator .isRunning ())
170
- mAnimator .start ();
178
+ if (!mAnimator .isRunning ())
179
+ mAnimator .start ();
171
180
}
172
181
173
182
/**
174
183
* 停止动画
175
184
*/
176
- public void cancelSunLineAnim (){
177
- if (mAnimator != null ){
185
+ public void cancelSunLineAnim () {
186
+ if (mAnimator != null ) {
178
187
mAnimator .cancel ();
179
188
}
180
189
}
@@ -196,6 +205,12 @@ public void onBegin(MaterialRefreshLayout materialRefreshLayout) {
196
205
@ Override
197
206
public void onPull (MaterialRefreshLayout materialRefreshLayout , float fraction ) {
198
207
float a = Util .limitValue (1 , fraction );
208
+ if (a >= 0.7 ) {
209
+ mLineView .setVisibility (View .VISIBLE );
210
+ } else {
211
+ mLineView .setVisibility (View .GONE );
212
+ }
213
+ mSunView .setPerView (mSunRadius , a );
199
214
ViewCompat .setScaleX (this , a );
200
215
ViewCompat .setScaleY (this , a );
201
216
ViewCompat .setAlpha (this , a );
0 commit comments