11[ ![ ] ( https://jitpack.io/v/LinweiJ/LoadingDialog.svg )] ( https://jitpack.io/#LinweiJ/LoadingDialog )
22
3- ##1 、为何使用它?
3+ ## 1、为何使用它?
44
55开发过程中一个简单的提交表单场景:
66
1414
1515## 2、如何引用它?
1616
17- [ ![ ] ( https://jitpack.io/v/LinweiJ/LoadingDialog.svg )] ( https://jitpack.io/#LinweiJ/LoadingDialog )
18-
1917先在 project的build.gradle 添加:
2018```
2119allprojects {
@@ -28,7 +26,7 @@ allprojects {
2826然后在module的build.gradle 添加:
2927```
3028dependencies {
31- compile 'com.github.LinweiJ:LoadingDialog:0.2.0'
29+ implementation 'com.github.LinweiJ:LoadingDialog:0.2.0'
3230}
3331```
3432
@@ -84,8 +82,8 @@ mHandler.postDelayed(new Runnable() {
8482| 方法 | 描述 | 参数 |
8583| ---------------------------------------- | --------------------- | ---------------------------------- |
8684| LottieLoadingDialog(@NonNull Context context) | 创建LottieLoadingDialog | Context context |
87- | showFirst(String message, int typeLottie, @Nullable String jsonFileName) | 第一次显示 | 显示文字内容,Lottie动画Type,Lottie动画文件(可空) |
88- | showResult(String message, int typeLottie, @Nullable String jsonFileName) | 显示结果(切换文字及Lottie动画而已) | 显示文字内容,Lottie动画Type,Lottie动画文件(可空) |
85+ | showFirst(String message, int typeLottie, @Nullable String jsonFileName, int lottieRepeatCount ) | 第一次显示 | 显示文字内容,Lottie动画Type,Lottie动画文件(可空), 重复次数(INFINITE(-1)无限次) |
86+ | showResult(String message, int typeLottie, @Nullable String jsonFileName, int lottieRepeatCount ) | 显示结果(切换文字及Lottie动画而已) | 显示文字内容,Lottie动画Type,Lottie动画文件(可空), 重复次数(INFINITE(-1)无限次 ) |
8987| dismissDelay(long delayMillis, DismissDelayEndCallback callback) | 延时消失 | 延时消失时间,消失时回调 |
9088
9189
@@ -96,12 +94,12 @@ mHandler.postDelayed(new Runnable() {
9694// LottieLoadingDialog
9795LottieLoadingDialog mLottieLoadingDialog = new LottieLoadingDialog (this );
9896// 显示加载框
99- mLottieLoadingDialog. showFirst(" 加载中..." , TYPE_LOADING_1 , null );
97+ mLottieLoadingDialog. showFirst(" 加载中..." , TYPE_LOADING_1 , null , INFINITE );
10098new Handler (). postDelayed(new Runnable () {
10199 @Override
102100 public void run () {
103101 // 显示结果
104- mLottieLoadingDialog. showResult(" 加载4秒后加载成功..." , TYPE_SUCCESS_1 , null );
102+ mLottieLoadingDialog. showResult(" 加载4秒后加载成功..." , TYPE_SUCCESS_1 , null , 0 );
105103 // 延时消失
106104 mLottieLoadingDialog. dismissDelay(2000 , new LoadingDialog .DismissDelayEndCallback () {
107105 @Override
@@ -130,17 +128,92 @@ mLottieLoadingDialog.setCanceledOnTouchOutside(false);
130128
131129#### 3.3.2 、效果图
132130
131+ #### 3.3.2 、立即消失
132+
133+ ``` java
134+ // 跟Dialog一样样的
135+ mLottieLoadingDialog. cancel();
136+ or
137+ mLottieLoadingDialog. dismiss();
138+ ```
133139
134140
135141## 4. 自定义
136142
137- ####
143+ #### 4.1 构造函数
144+ - 继承LoadingDialog
145+ - 构造函数调用super方法
146+ ``` java
147+ public class SimpleLoadingDialog extends LoadingDialog {
138148
139-
149+ public SimpleLoadingDialog (@NonNull Context context ) {
150+ super (context);
151+ }
152+ ...
153+ ```
154+ #### 4.2 initView
155+ - 在initView中初始化UI 布局
156+ ```java
157+ /**
158+ * 初始化view
159+ */
160+ @Override
161+ protected void initView () {
162+ this . setContentView(R . layout. layout_loading_dialog_simple);
163+ mTvLoadingDialogText = (TextView ) this . findViewById(R . id. tv_loading_dialog_text);
164+ }
165+ ```
166+ #### 4.3 showFirst
167+ - 传递并设置显示内容参数
168+ - 调用Dialog的show ()方法
169+ ```java
170+ /**
171+ * 第一次显示
172+ */
173+ public void showFirst (String message ) {
174+ mTvLoadingDialogText. setText(message);
175+ this . show();
176+ }
177+ ```
178+ #### 4.4 showResult
179+ - 传递并设置显示内容参数
180+ ```java
181+ /**
182+ * 结果
183+ *
184+ * @param message
185+ */
186+ public void showResult (String message ) {
187+ if (isShowing()) {
188+ mTvLoadingDialogText. setText(message);
189+ }
190+ }
191+ ```
192+ #### 4.5 dismissDelay
193+ - 延时关闭加载框
194+ - 关闭时调用DismissDelayEndCallback 的onEnd方法
195+ ```java
196+ @Override
197+ public void dismissDelay (long delayMillis , DismissDelayEndCallback callback ) {
198+ super . dismissDelay(delayMillis, callback);
199+ }
200+ ```
201+ #### 4.6 DismissDelayEndCallback
202+ - 延时关闭加载框的回调
203+ ```java
204+ /**
205+ * 延时消失回调
206+ */
207+ public interface DismissDelayEndCallback {
208+
209+ void onEnd (LoadingDialog dialog );
210+
211+ }
212+ ```
140213
141214## 5 、更多
142215
143- 更多细节可以参考 app / 示例
216+ 更多细节可以参考 demo / 示例
144217
145218
146219
0 commit comments