Skip to content
This repository was archived by the owner on Jan 8, 2022. It is now read-only.

Commit ceac3da

Browse files
committed
- hide set color api because:
* it make my develop become hard * it is no use for user
1 parent 8afc950 commit ceac3da

File tree

10 files changed

+60
-27
lines changed

10 files changed

+60
-27
lines changed

.idea/misc.xml

Lines changed: 1 addition & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

LoadingDialog/.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
11
/build
2+
/src/main/java/com.xiasuhuei321.loadingdialog/需要完成的工作笔记.txt

LoadingDialog/src/main/java/com/xiasuhuei321/loadingdialog/view/LoadCircleView.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,8 +72,8 @@ protected void onMeasure(int widthMeasureSpec, int heightMeasureSpec) {
7272
@Override
7373
protected void onDraw(Canvas canvas) {
7474
// 圆心坐标 (center,center)
75-
int center = mWidth / 2;
76-
int radius = mWidth / 2 - 8;
75+
int center = mWidth >> 1;
76+
int radius = (mWidth >> 1) - 8;
7777
if (currentLineIndex >= 12)
7878
currentLineIndex = 0;
7979
// canvas.rotate(currentLineIndex * 30, center, center);

LoadingDialog/src/main/java/com/xiasuhuei321/loadingdialog/view/LoadingDialog.java

Lines changed: 31 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -2,9 +2,11 @@
22

33
import android.app.Dialog;
44
import android.content.Context;
5+
import android.content.DialogInterface;
56
import android.os.Handler;
67
import android.os.Message;
78
import android.support.annotation.ColorInt;
9+
import android.util.Log;
810
import android.util.TypedValue;
911
import android.view.LayoutInflater;
1012
import android.view.View;
@@ -80,6 +82,12 @@ public void onBackPressed() {
8082
mLoadingDialog.setContentView(layout, new LinearLayout.LayoutParams(
8183
LinearLayout.LayoutParams.MATCH_PARENT,
8284
LinearLayout.LayoutParams.MATCH_PARENT));
85+
mLoadingDialog.setOnDismissListener(new DialogInterface.OnDismissListener() {
86+
@Override
87+
public void onDismiss(DialogInterface dialog) {
88+
mContext = null;
89+
}
90+
});
8391
initStyle();
8492
}
8593

@@ -168,6 +176,8 @@ private void initStyle() {
168176
//----------------------------------对外提供的api------------------------------//
169177

170178
/**
179+
* please invoke show() method at last,because it's
180+
* return value is void
171181
* 请在最后调用show,因此show返回值为void会使链式api断开
172182
*/
173183
public void show() {
@@ -177,18 +187,27 @@ public void show() {
177187
mCircleLoadView.setVisibility(View.GONE);
178188
mLoadingDialog.show();
179189
mLoadingView.startAnim();
180-
} else if(loadStyle == STYLE_LINE) {
190+
Log.e("show", "style_ring");
191+
} else if (loadStyle == STYLE_LINE) {
181192
mCircleLoadView.setVisibility(View.VISIBLE);
182193
mLoadingView.setVisibility(View.GONE);
183194
mLoadingDialog.show();
195+
Log.e("show", "style_line");
184196
}
185197
}
186198

187-
public void setLoadStyle(int style) {
199+
/**
200+
* set load style
201+
* 设置load的样式,目前支持转圈圈和菊花转圈圈
202+
*
203+
* @param style
204+
*/
205+
public LoadingDialog setLoadStyle(int style) {
188206
if (style >= 3) {
189207
throw new IllegalArgumentException("Your style is wrong!");
190208
}
191209
this.loadStyle = style;
210+
return this;
192211
}
193212

194213
/**
@@ -242,6 +261,8 @@ public LoadingDialog setFailedText(String msg) {
242261
}
243262

244263
/**
264+
* when you need a successful feedback,please invoke
265+
* this method in success's callback
245266
* 当你需要一个成功的反馈的时候,在加载成功的回调中调用此方法
246267
*/
247268
public void loadSuccess() {
@@ -253,6 +274,8 @@ public void loadSuccess() {
253274
}
254275

255276
/**
277+
* when you need a fail feedback,please invoke this
278+
* method in failed callback
256279
* 当你需要一个失败的反馈的时候,在加载失败的回调中调用此方法
257280
*/
258281
public void loadFailed() {
@@ -329,9 +352,10 @@ public int getSpeed() {
329352
}
330353

331354
/**
332-
* 此方法改变成功失败绘制的颜色
355+
* 此方法改变成功失败绘制的颜色,此方法增加了处理的复杂性,暂时不公开此方法。
356+
* 而且暂时没有做到方便调用,真的要用的话十分的麻烦,暂时隐藏,后续不确定是否公开。
333357
*/
334-
public LoadingDialog setDrawColor(@ColorInt int color) {
358+
private LoadingDialog setDrawColor(@ColorInt int color) {
335359
mFailedView.setDrawColor(color);
336360
mSuccessView.setDrawColor(color);
337361
loadingText.setTextColor(color);
@@ -378,10 +402,10 @@ public LoadingDialog setShowTime(long time) {
378402
}
379403

380404
/**
405+
* set the size of load text size
381406
* 设置加载字体大小
382407
*
383-
* @param size 尺寸,单位sp
384-
* 来将sp转换为对应的px值
408+
* @param size 尺寸,单位sp,来将sp转换为对应的px值
385409
* @return 这个对象
386410
*/
387411
public LoadingDialog setTextSize(float size) {
@@ -396,6 +420,7 @@ public static void initStyle(StyleManager style) {
396420
}
397421

398422
/**
423+
* dispatch the event when draw finish
399424
* 传递绘制完成的事件
400425
*
401426
* @param o 回调接口

LoadingDialog/src/main/java/com/xiasuhuei321/loadingdialog/view/RightDiaView.java

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@
1111
/**
1212
* Created by [email protected] on 2016/11/5.
1313
* desc:
14-
* TODO: 目前这个对勾还有点问题,在下个版本发布之前解决这个问题!问题在两条线的交点
1514
*/
1615

1716
public class RightDiaView extends View {

LoadingDialog/src/main/java/com/xiasuhuei321/loadingdialog/需要完成的工作笔记.txt

Lines changed: 0 additions & 3 deletions
This file was deleted.

app/src/main/AndroidManifest.xml

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,8 @@
2121
<activity
2222
android:name=".SampleActivity"
2323
android:screenOrientation="portrait" />
24-
<activity android:name=".TempActivity" />
24+
<activity android:name=".TempActivity"
25+
android:screenOrientation="portrait"/>
2526
</application>
2627

2728
</manifest>

app/src/main/java/com/xiasuhuei321/sample/MainActivity.java

Lines changed: 19 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,8 @@ public class MainActivity extends AppCompatActivity implements View.OnClickListe
3535
private long delayedTime = 1000L;
3636
private int repeatTime = 0;
3737
private boolean intercept_back_event = false;
38-
private int color = Color.argb(100, 255, 255, 255);
38+
private int color = Color.argb(255, 255, 255, 255);
39+
private int style = LoadingDialog.STYLE_LINE;
3940

4041
@Override
4142
protected void onCreate(Bundle savedInstanceState) {
@@ -94,8 +95,12 @@ public void onClick(View v) {
9495
case R.id.btn1:
9596
ld = new LoadingDialog(this);
9697
ld.setInterceptBack(intercept_back_event)
97-
.setLoadingText("加载中...");
98-
h.sendEmptyMessage(LOADING);
98+
.setLoadingText("加载中...")
99+
.setLoadStyle(style)
100+
.show();
101+
102+
// h.sendEmptyMessage(LOADING);
103+
99104
saveForThesePeopleWhoDoNotCallCloseAndUseInterceptBackMethod(intercept_back_event);
100105
break;
101106

@@ -106,7 +111,8 @@ public void onClick(View v) {
106111
.setInterceptBack(intercept_back_event)
107112
.setLoadSpeed(speed)
108113
.setRepeatCount(repeatTime)
109-
.setDrawColor(color)
114+
// .setDrawColor(color)
115+
.setLoadStyle(style)
110116
.show();
111117
h.sendEmptyMessageDelayed(LOAD_SUCCESS, delayedTime);
112118
saveForThesePeopleWhoDoNotCallCloseAndUseInterceptBackMethod(intercept_back_event);
@@ -119,8 +125,9 @@ public void onClick(View v) {
119125
.setInterceptBack(intercept_back_event)
120126
.setLoadSpeed(speed)
121127
.setRepeatCount(repeatTime)
122-
.setDrawColor(color)
128+
// .setDrawColor(color)
123129
.setShowTime(5000)//延时5秒自动关闭,默认1秒
130+
.setLoadStyle(style)
124131
.show();
125132
h.sendEmptyMessageDelayed(LOAD_FAILED, delayedTime);
126133
saveForThesePeopleWhoDoNotCallCloseAndUseInterceptBackMethod(intercept_back_event);
@@ -133,8 +140,9 @@ public void onClick(View v) {
133140
.setInterceptBack(intercept_back_event)
134141
.setLoadSpeed(speed)
135142
.closeSuccessAnim()
136-
.setDrawColor(color)
143+
// .setDrawColor(color)
137144
.setRepeatCount(repeatTime)
145+
.setLoadStyle(style)
138146
.show();
139147
h.sendEmptyMessageDelayed(LOAD_WITHOUT_ANIM_SUCCESS, delayedTime);
140148
saveForThesePeopleWhoDoNotCallCloseAndUseInterceptBackMethod(intercept_back_event);
@@ -147,9 +155,10 @@ public void onClick(View v) {
147155
.setInterceptBack(intercept_back_event)
148156
.setLoadSpeed(speed)
149157
.closeFailedAnim()
150-
.setDrawColor(color)
158+
// .setDrawColor(color)
151159
.setSize(SizeUtils.dip2px(this, 100))
152160
.setRepeatCount(repeatTime)
161+
.setLoadStyle(style)
153162
.show();
154163
h.sendEmptyMessageDelayed(LOAD_WITHOUT_ANIM_FAILED, delayedTime);
155164
saveForThesePeopleWhoDoNotCallCloseAndUseInterceptBackMethod(intercept_back_event);
@@ -217,11 +226,12 @@ public boolean onOptionsItemSelected(MenuItem item) {
217226
Toast.makeText(this, "now the loading callback will be draw:" + (repeatTime + 1) + " times", Toast.LENGTH_LONG).show();
218227
break;
219228
case R.id.color:
220-
color = color == Color.argb(100, 255, 255, 255) ? Color.BLUE : Color.argb(100, 255, 255, 255);
229+
color = color == Color.argb(255, 255, 255, 255) ? Color.BLUE : Color.argb(255, 255, 255, 255);
221230
Toast.makeText(this, "now the color is:" + color, Toast.LENGTH_LONG).show();
222231
break;
223232
case R.id.style:
224-
233+
style = style == LoadingDialog.STYLE_LINE ? LoadingDialog.STYLE_RING : LoadingDialog.STYLE_LINE;
234+
Toast.makeText(this, "now the style is changed", Toast.LENGTH_SHORT).show();
225235
break;
226236
}
227237
return true;

app/src/main/java/com/xiasuhuei321/sample/SampleApplication.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,6 @@
33
import android.app.Application;
44

55
import com.xiasuhuei321.loadingdialog.manager.StyleManager;
6-
import com.xiasuhuei321.loadingdialog.view.LoadingDialog;
76

87
/**
98
* Created by [email protected] on 2016/11/12.
@@ -18,9 +17,9 @@ public void onCreate() {
1817

1918
//在这里调用方法设置s的属性
2019
//code here...
21-
s.Anim(false).repeatTime(0).contentSize(-1).intercept(true)
22-
.setLoadStyle(LoadingDialog.STYLE_LINE);
20+
// s.Anim(true).repeatTime(0).contentSize(-1).intercept(true)
21+
// .setLoadStyle(LoadingDialog.STYLE_LINE);
2322

24-
LoadingDialog.initStyle(s);
23+
// LoadingDialog.initStyle(s);
2524
}
2625
}

app/src/main/res/menu/select.xml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,7 @@
1919

2020
<item
2121
android:id="@+id/color"
22+
android:visible="false"
2223
android:title="@string/change_color" />
2324

2425
<item

0 commit comments

Comments
 (0)