[![](https://jitpack.io/v/LinweiJ/LoadingDialog.svg)](https://jitpack.io/#LinweiJ/LoadingDialog)
## 1、为何使用它?
开发过程中一个简单的提交表单场景:
1、提交信息,显示"信息提交中,请稍后...";
2、信息提交成功,显示"信息提交成功";
3、等待 2 s,返回上一页面。
这时,就需要使用加载框了。
## 2、如何引用它?
先在 project的build.gradle 添加:
```
allprojects {
repositories {
...
maven { url "https://jitpack.io" }
}
}
```
然后在module的build.gradle 添加:
```
dependencies {
implementation 'com.github.LinweiJ.LoadingDialog:loadingDialog:0.2.0'
//使用LottieLoadingDialog,需另外添加
implementation 'com.github.LinweiJ.LoadingDialog:lottieLoadingDialog:0.2.0'
implementation 'com.airbnb.android:lottie:2.7.0'
}
```
## 3、全新使用
重新设计后 使用更简洁了
### 3.1、Simple
#### 3.1.1 方法及参数
| 方法 | 描述 | 参数 |
| ---------------------------------------- | --------------------- | ------------ |
| SimpleLoadingDialog(@NonNull Context context) | 创建SimpleLoadingDialog | Context |
| showFirst(String message) | 第一次显示 | 显示文字内容 |
| showResult(String message) | 显示结果(切换文字而已) | 显示文字内容 |
| dismissDelay(long delayMillis, DismissDelayEndCallback callback) | 延时消失 | 延时消失时间,消失时回调 |
#### 3.1.2 使用(try it)
```java
//SimpleLoadingDialog
SimpleLoadingDialog mSimpleLoadingDialog = new SimpleLoadingDialog(this);
//显示加载框
mSimpleLoadingDialog.showFirst("加载中.....");
//模拟延时操作
mHandler.postDelayed(new Runnable() {
@Override
public void run() {
//显示结果
mSimpleLoadingDialog.showResult("加载6秒后加载成功");
//延时消失
mSimpleLoadingDialog.dismissDelay(5000, new LoadingDialog.DismissDelayEndCallback() {
@Override
public void onEnd(LoadingDialog dialog) {
Toast.makeText(mActivity, "加载成功显示5秒消失了", Toast.LENGTH_SHORT).show();
}
});
}
}, 6000);
```
#### 3.1.3 效果图
![loadingDialog.gif](https://github.com/LinweiJ/LoadingDialog/blob/master/screen_shot/ld_3_1.gif)
### 3.2、Lottie
#### 3.2.1 方法及参数
| 方法 | 描述 | 参数 |
| ---------------------------------------- | --------------------- | ---------------------------------- |
| LottieLoadingDialog(@NonNull Context context) | 创建LottieLoadingDialog | Context context |
| showFirst(String message, int typeLottie, @Nullable String jsonFileName, int lottieRepeatCount) | 第一次显示 | 显示文字内容,Lottie动画Type,Lottie动画文件(可空), 重复次数(INFINITE(-1)无限次) |
| showResult(String message, int typeLottie, @Nullable String jsonFileName, int lottieRepeatCount) | 显示结果(切换文字及Lottie动画而已) | 显示文字内容,Lottie动画Type,Lottie动画文件(可空), 重复次数(INFINITE(-1)无限次) |
| dismissDelay(long delayMillis, DismissDelayEndCallback callback) | 延时消失 | 延时消失时间,消失时回调 |
#### 3.2.2 使用(try it)
```java
//LottieLoadingDialog
LottieLoadingDialog mLottieLoadingDialog = new LottieLoadingDialog(this);
//显示加载框
mLottieLoadingDialog.showFirst("加载中...", LLD_TYPE_LOADING_1, null, INFINITE);
new Handler().postDelayed(new Runnable() {
@Override
public void run() {
//显示结果
mLottieLoadingDialog.showResult("加载4秒后加载成功...", LLD_TYPE_SUCCESS_1, null, 0);
//延时消失
mLottieLoadingDialog.dismissDelay(2000, new LoadingDialog.DismissDelayEndCallback() {
@Override
public void onEnd(LoadingDialog dialog) {
Toast.makeText(mActivity, "加载成功显示2秒消失了", Toast.LENGTH_LONG).show();
}
});
}
}, 4000);
```
#### 3.2.3 效果图
![loadingDialog.gif](https://github.com/LinweiJ/LoadingDialog/blob/master/screen_shot/ld_3_2.gif)
### 3.3、其他
#### 3.3.1 、不可取消
```java
//跟Dialog一样样的
mLottieLoadingDialog.setCancelable(false);
mLottieLoadingDialog.setCanceledOnTouchOutside(false);
```
#### 3.3.2 、效果图
![loadingDialog.gif](https://github.com/LinweiJ/LoadingDialog/blob/master/screen_shot/ld_3_3.gif)
#### 3.3.3 、立即消失
```java
//跟Dialog一样样的
mLottieLoadingDialog.cancel();
or
mLottieLoadingDialog.dismiss();
```
## 4. 自定义
#### 4.1 构造函数
- 继承LoadingDialog
- 构造函数调用super方法
```java
public class SimpleLoadingDialog extends LoadingDialog {
public SimpleLoadingDialog(@NonNull Context context) {
super(context);
}
...
```
#### 4.2 initView
- 在initView中初始化UI布局
```java
/**
* 初始化view
*/
@Override
protected void initView() {
this.setContentView(R.layout.layout_loading_dialog_simple);
mTvLoadingDialogText = (TextView) this.findViewById(R.id.tv_loading_dialog_text);
}
```
#### 4.3 showFirst
- 传递并设置显示内容参数
- 调用Dialog的show()方法
```java
/**
* 第一次显示
*/
public void showFirst(String message) {
mTvLoadingDialogText.setText(message);
this.show();
}
```
#### 4.4 showResult
- 传递并设置显示内容参数
```java
/**
* 结果
*
* @param message
*/
public void showResult(String message) {
if (isShowing()) {
mTvLoadingDialogText.setText(message);
}
}
```
#### 4.5 dismissDelay
- 延时关闭加载框
- 关闭时调用DismissDelayEndCallback的onEnd方法
```java
@Override
public void dismissDelay(long delayMillis, DismissDelayEndCallback callback) {
super.dismissDelay(delayMillis, callback);
}
```
#### 4.6 DismissDelayEndCallback
- 延时关闭加载框的回调
```java
/**
* 延时消失回调
*/
public interface DismissDelayEndCallback {
void onEnd(LoadingDialog dialog);
}
```
## 5、更多
更多细节可以参考 demo/ 示例
## 6、使用到的第三方库
- [lottie](https://github.com/airbnb/lottie-android)
## 7、版本0.2.0的改进思路
1. 对0.1.0进行重构;
2. 针对LoadingDialog使用场景,增加三个接入接口(开始显示处理,结果显示处理,消失处理);
3. 对于三个接入接口,我们可以更加自由地定义效果;
4. 针对简单使用原则(懒),提供Simple、Lottie两种快速构建的Builder(也提供一些定制化方法)。
5. 主要还是自己在0.1.0使用过程的一些体验,进行的改进,希望也对你们有所帮助。
# License
```
Copyright 2017~2018 LinWeiJia
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
```
没有合适的资源?快使用搜索试试~ 我知道了~
资源详情
资源评论
资源推荐
收起资源包目录
LoadingDialog (731个子文件)
5gmna9KakU6XbwYii1XLRvro2oo= 10KB
5gmna9KakU6XbwYii1XLRvro2oo= 10KB
5Y79wGsjV7pMtgw_psCY+Q43umQ= 7KB
5Y79wGsjV7pMtgw_psCY+Q43umQ= 7KB
62_g54jy1LNXP5vm7BW7IiO3FqM= 9KB
62_g54jy1LNXP5vm7BW7IiO3FqM= 9KB
67BXlWc2eTDV6zNWMViI8YJZh+I= 54KB
67BXlWc2eTDV6zNWMViI8YJZh+I= 54KB
7CGCaZDoU6gQWGNUZYqsDtpNdMc= 33KB
7CGCaZDoU6gQWGNUZYqsDtpNdMc= 33KB
7ZV2OfInFBY66MJzFpJEGhn5W_M= 33KB
7ZV2OfInFBY66MJzFpJEGhn5W_M= 33KB
a_baddW6LGRroAgBiaei1c6VaSk= 10KB
a_baddW6LGRroAgBiaei1c6VaSk= 10KB
AeXKHQNhhNJD+mhlOZH_+e3dsu8= 9KB
AeXKHQNhhNJD+mhlOZH_+e3dsu8= 9KB
androidResources 24KB
resources-debug.ap_ 467KB
demo-debug.apk 1.95MB
B6Kf5Ls3pVcxqzgKfcTtRUviKCE= 27KB
B6Kf5Ls3pVcxqzgKfcTtRUviKCE= 27KB
gradlew.bat 2KB
executionHistory.bin 830KB
classAnalysis.bin 486KB
jarAnalysis.bin 103KB
outputFiles.bin 92KB
fileHashes.bin 72KB
taskHistory.bin 42KB
sha1-checksums.bin 19KB
resourceHashesCache.bin 18KB
md5-checksums.bin 18KB
desugar_graph.bin 235B
graph.bin 235B
graph.bin 235B
graph.bin 235B
graph.bin 235B
graph.bin 235B
graph.bin 235B
desugar_graph.bin 235B
7acace46a9c67a7e6c4ea9f31ca0a0f2.bin 9B
89e29ec948e41ba7cd0b44c10271b31b.bin 9B
21b3b1b0c9306488e1415218f2aeb43f.bin 4B
f44103d5d3fde570a61647b7501d81dd.bin 4B
last-build.bin 1B
CdirhouBfcSTHwwNK+zQvTwUEWw= 7KB
CdirhouBfcSTHwwNK+zQvTwUEWw= 7KB
LottieLoadingDialog.class 4KB
LottieLoadingDialog.class 4KB
MainActivity.class 3KB
LoadingDialog.class 2KB
LoadingDialog.class 2KB
SimpleLoadingDialog.class 2KB
SimpleLoadingDialog.class 2KB
LottieLoadingDialog$1.class 2KB
LottieLoadingDialog$1.class 2KB
MainActivity$4.class 1KB
MainActivity$2.class 1KB
MainActivity$3.class 1KB
MainActivity$1.class 1KB
MainActivity$1$1.class 1KB
MainActivity$4$1.class 1KB
MainActivity$2$1.class 1KB
MainActivity$3$1.class 1KB
LoadingDialog$1.class 1KB
LoadingDialog$1.class 1KB
BuildConfig.class 692B
BuildConfig.class 654B
BuildConfig.class 654B
BuildConfig.class 636B
BuildConfig.class 636B
LoadingDialog$DismissDelayEndCallback.class 370B
LoadingDialog$DismissDelayEndCallback.class 370B
cVnoCYuRr9BWOQKDAuCG85qeI+4= 704KB
cVnoCYuRr9BWOQKDAuCG85qeI+4= 704KB
classes.dex 2.91MB
classes.dex 335KB
classes.dex 7KB
classes.dex 5KB
classes.dex 4KB
LottieLoadingDialog.dex 4KB
MainActivity.dex 3KB
LoadingDialog.dex 2KB
SimpleLoadingDialog.dex 2KB
LottieLoadingDialog$1.dex 2KB
MainActivity$3.dex 2KB
MainActivity$4.dex 2KB
MainActivity$2.dex 2KB
MainActivity$1$1.dex 2KB
MainActivity$2$1.dex 2KB
MainActivity$4$1.dex 2KB
MainActivity$3$1.dex 2KB
MainActivity$1.dex 2KB
LoadingDialog$1.dex 1KB
BuildConfig.dex 964B
LoadingDialog$DismissDelayEndCallback.dex 940B
BuildConfig.dex 924B
BuildConfig.dex 908B
dNLZcN5CoB0BLW4zN9ZTdZCMEJA= 2KB
dNLZcN5CoB0BLW4zN9ZTdZCMEJA= 2KB
eh715OLUSnTLy7zA4sbdqztMwMg= 368KB
共 731 条
- 1
- 2
- 3
- 4
- 5
- 6
- 8
是真的三水
- 粉丝: 2
- 资源: 4
上传资源 快速赚钱
- 我的内容管理 展开
- 我的资源 快来上传第一个资源
- 我的收益 登录查看自己的收益
- 我的积分 登录查看自己的积分
- 我的C币 登录后查看C币余额
- 我的收藏
- 我的下载
- 下载帮助
安全验证
文档复制为VIP权益,开通VIP直接复制
信息提交成功
评论0