Skip to content

Commit f01a49d

Browse files
committed
fix some bug ......
1 parent d1d529b commit f01a49d

File tree

1 file changed

+32
-17
lines changed

1 file changed

+32
-17
lines changed

library/src/main/java/com/cjj/SunLayout.java

Lines changed: 32 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -32,16 +32,16 @@ public class SunLayout extends FrameLayout implements MaterialHeadListener {
3232
private int mEyesSize;
3333
private int mLineLevel;
3434
private int mMouthStro;
35-
private int mLineColor,mLineWidth,mLineHeight;
35+
private int mLineColor, mLineWidth, mLineHeight;
3636

3737
private ObjectAnimator mAnimator;
3838

3939
public SunLayout(Context context) {
40-
this(context,null);
40+
this(context, null);
4141
}
4242

4343
public SunLayout(Context context, AttributeSet attrs) {
44-
this(context, attrs,0);
44+
this(context, attrs, 0);
4545
}
4646

4747
public SunLayout(Context context, AttributeSet attrs, int defStyleAttr) {
@@ -83,16 +83,18 @@ private void init() {
8383

8484
/**
8585
* 设置太阳半径
86+
*
8687
* @param sunRadius
8788
*/
88-
public void setSunRadius(int sunRadius){
89+
public void setSunRadius(int sunRadius) {
8990
mSunRadius = sunRadius;
9091
mSunView.setSunRadius(mSunRadius);
9192
mLineView.setSunRadius(mSunRadius);
9293
}
9394

9495
/**
9596
* 设置太阳颜色
97+
*
9698
* @param sunColor
9799
*/
98100
public void setSunColor(int sunColor) {
@@ -102,79 +104,86 @@ public void setSunColor(int sunColor) {
102104

103105
/**
104106
* 设置太阳眼睛大小
107+
*
105108
* @param eyesSize
106109
*/
107-
public void setEyesSize(int eyesSize){
110+
public void setEyesSize(int eyesSize) {
108111
mEyesSize = eyesSize;
109112
mSunView.setEyesSize(mEyesSize);
110113
}
111114

112115
/**
113116
* 设置太阳线的数量等级
117+
*
114118
* @param level
115119
*/
116-
public void setLineLevel(int level){
120+
public void setLineLevel(int level) {
117121
mLineLevel = level;
118122
mLineView.setLineLevel(mLineLevel);
119123
}
120124

121125
/**
122126
* 设置太阳线的颜色
127+
*
123128
* @param lineColor
124129
*/
125-
public void setLineColor(int lineColor){
130+
public void setLineColor(int lineColor) {
126131
mLineColor = lineColor;
127132
mLineView.setLineColor(mLineColor);
128133
}
129134

130135
/**
131136
* 设置太阳线的宽度
137+
*
132138
* @param lineWidth
133139
*/
134-
public void setLineWidth(int lineWidth){
140+
public void setLineWidth(int lineWidth) {
135141
mLineWidth = lineWidth;
136142
mLineView.setLineWidth(mLineWidth);
137143
}
138144

139145
/**
140146
* 设置太阳线的长度
147+
*
141148
* @param lineHeight
142149
*/
143-
public void setLineHeight(int lineHeight){
150+
public void setLineHeight(int lineHeight) {
144151
mLineHeight = lineHeight;
145152
mLineView.setLineHeight(mLineHeight);
146153
}
147154

148155
/**
149156
* 设置嘴巴粗细
157+
*
150158
* @param mouthStro
151159
*/
152-
public void setMouthStro(int mouthStro){
160+
public void setMouthStro(int mouthStro) {
153161
mMouthStro = mouthStro;
154162
mSunView.setMouthStro(mMouthStro);
155163
}
156164

157165

158166
/**
159167
* 开启转圈圈
168+
*
160169
* @param v
161170
*/
162-
public void startSunLineAnim(View v){
163-
if(mAnimator == null){
171+
public void startSunLineAnim(View v) {
172+
if (mAnimator == null) {
164173
mAnimator = ObjectAnimator.ofFloat(v, "rotation", 0f, 720f);
165-
mAnimator.setDuration(7*1000);
174+
mAnimator.setDuration(7 * 1000);
166175
mAnimator.setInterpolator(new LinearInterpolator());
167176
mAnimator.setRepeatCount(ValueAnimator.INFINITE);
168177
}
169-
if(!mAnimator.isRunning())
170-
mAnimator.start();
178+
if (!mAnimator.isRunning())
179+
mAnimator.start();
171180
}
172181

173182
/**
174183
* 停止动画
175184
*/
176-
public void cancelSunLineAnim(){
177-
if (mAnimator != null){
185+
public void cancelSunLineAnim() {
186+
if (mAnimator != null) {
178187
mAnimator.cancel();
179188
}
180189
}
@@ -196,6 +205,12 @@ public void onBegin(MaterialRefreshLayout materialRefreshLayout) {
196205
@Override
197206
public void onPull(MaterialRefreshLayout materialRefreshLayout, float fraction) {
198207
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);
199214
ViewCompat.setScaleX(this, a);
200215
ViewCompat.setScaleY(this, a);
201216
ViewCompat.setAlpha(this, a);

0 commit comments

Comments
 (0)