readme 修改
This commit is contained in:
40
BroadCast.md
40
BroadCast.md
@ -6,32 +6,32 @@ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|||||||
@Override public void onReceive(Context context, Intent intent) {
|
@Override public void onReceive(Context context, Intent intent) {
|
||||||
String action = intent.getAction();
|
String action = intent.getAction();
|
||||||
//可以通过intent获取到下载实体,下载实体中包含了各种下载状态
|
//可以通过intent获取到下载实体,下载实体中包含了各种下载状态
|
||||||
DownloadEntity entity = intent.getParcelableExtra(DownloadManager.ENTITY);
|
DownloadEntity entity = intent.getParcelableExtra(Aria.ENTITY);
|
||||||
switch (action) {
|
switch (action) {
|
||||||
case DownloadManager.ACTION_PRE: //预处理
|
case Aria.ACTION_PRE: //预处理
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_POST_PRE: //预处理完成
|
case Aria.ACTION_POST_PRE: //预处理完成
|
||||||
//预处理完成,便可以获取文件的下载长度了
|
//预处理完成,便可以获取文件的下载长度了
|
||||||
len = entity.getFileSize();
|
len = entity.getFileSize();
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_START: //开始下载
|
case Aria.ACTION_START: //开始下载
|
||||||
L.d(TAG, "download start");
|
L.d(TAG, "download start");
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_RESUME: //恢复下载
|
case Aria.ACTION_RESUME: //恢复下载
|
||||||
L.d(TAG, "download resume");
|
L.d(TAG, "download resume");
|
||||||
long location = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 1);
|
long location = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 1);
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_RUNNING: //下载中
|
case Aria.ACTION_RUNNING: //下载中
|
||||||
long current = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 0);
|
long current = intent.getLongExtra(DownloadManager.CURRENT_LOCATION, 0);
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_STOP: //停止下载
|
case Aria.ACTION_STOP: //停止下载
|
||||||
L.d(TAG, "download stop");
|
L.d(TAG, "download stop");
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_COMPLETE: //下载完成
|
case Aria.ACTION_COMPLETE: //下载完成
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_CANCEL: //取消下载
|
case Aria.ACTION_CANCEL: //取消下载
|
||||||
break;
|
break;
|
||||||
case DownloadManager.ACTION_FAIL: // 下载失败
|
case Aria.ACTION_FAIL: // 下载失败
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -44,15 +44,15 @@ private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
|||||||
super.onResume();
|
super.onResume();
|
||||||
IntentFilter filter = new IntentFilter();
|
IntentFilter filter = new IntentFilter();
|
||||||
filter.addDataScheme(getPackageName());
|
filter.addDataScheme(getPackageName());
|
||||||
filter.addAction(DownloadManager.ACTION_PRE);
|
filter.addAction(Aria.ACTION_PRE);
|
||||||
filter.addAction(DownloadManager.ACTION_POST_PRE);
|
filter.addAction(Aria.ACTION_POST_PRE);
|
||||||
filter.addAction(DownloadManager.ACTION_RESUME);
|
filter.addAction(Aria.ACTION_RESUME);
|
||||||
filter.addAction(DownloadManager.ACTION_START);
|
filter.addAction(Aria.ACTION_START);
|
||||||
filter.addAction(DownloadManager.ACTION_RUNNING);
|
filter.addAction(Aria.ACTION_RUNNING);
|
||||||
filter.addAction(DownloadManager.ACTION_STOP);
|
filter.addAction(Aria.ACTION_STOP);
|
||||||
filter.addAction(DownloadManager.ACTION_CANCEL);
|
filter.addAction(Aria.ACTION_CANCEL);
|
||||||
filter.addAction(DownloadManager.ACTION_COMPLETE);
|
filter.addAction(Aria.ACTION_COMPLETE);
|
||||||
filter.addAction(DownloadManager.ACTION_FAIL);
|
filter.addAction(Aria.ACTION_FAIL);
|
||||||
registerReceiver(mReceiver, filter);
|
registerReceiver(mReceiver, filter);
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
|
53
README.md
53
README.md
@ -15,7 +15,7 @@ Aria,致力于让下载傻瓜化</br>
|
|||||||
## 下载
|
## 下载
|
||||||
[](https://bintray.com/arialyy/maven/Aria/_latestVersion)</br>
|
[](https://bintray.com/arialyy/maven/Aria/_latestVersion)</br>
|
||||||
```java
|
```java
|
||||||
compile 'com.arialyy.aria:Aria:2.3.2'
|
compile 'com.arialyy.aria:Aria:2.3.3'
|
||||||
```
|
```
|
||||||
|
|
||||||
|
|
||||||
@ -29,12 +29,13 @@ compile 'com.arialyy.aria:Aria:2.3.2'
|
|||||||
|
|
||||||
***
|
***
|
||||||
## 使用
|
## 使用
|
||||||
### 一、Aria 是实体驱动型的工具,所以,第一步,你需要创建一个下载实体
|
### 一、只需要以下参数,你便能很简单的使用Aria下载文件了
|
||||||
```java
|
```java
|
||||||
DownloadEntity mEntity = new DownloadEntity();
|
Aria.whit(this)
|
||||||
mEntity.setFileName(fileName); //设置文件名
|
.load(DOWNLOAD_URL) //下载地址,必填
|
||||||
mEntity.setDownloadUrl(downloadUrl); //设置下载链接
|
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") //文件保存路径,必填
|
||||||
mEntity.setDownloadPath(downloadPath); //设置存放路径
|
.setDownloadName("test.apk") //文件名,必填
|
||||||
|
.start();
|
||||||
```
|
```
|
||||||
### 二、为了能接收到Aria传递的数据,你需要把你的Activity或fragment注册到Aria管理器中,注册的方式很简单,在onResume
|
### 二、为了能接收到Aria传递的数据,你需要把你的Activity或fragment注册到Aria管理器中,注册的方式很简单,在onResume
|
||||||
```java
|
```java
|
||||||
@ -43,26 +44,44 @@ compile 'com.arialyy.aria:Aria:2.3.2'
|
|||||||
Aria.whit(this).addSchedulerListener(new MySchedulerListener());
|
Aria.whit(this).addSchedulerListener(new MySchedulerListener());
|
||||||
}
|
}
|
||||||
```
|
```
|
||||||
### 三、还记得上面的DownloadEntity吗?现在是时候使用它进行下载了
|
### 三、通过下载链接,你还能使用Aria执行很多操作,如:
|
||||||
|
- 添加任务(不进行下载)
|
||||||
|
|
||||||
|
```java
|
||||||
|
Aria.whit(this).load(DOWNLOAD_URL)
|
||||||
|
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") //文件保存路径,必填
|
||||||
|
.setDownloadName("test.apk") //文件名,必填
|
||||||
|
.add();
|
||||||
|
```
|
||||||
- 启动下载
|
- 启动下载
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Aria.whit(this).load(mEntity).start();
|
Aria.whit(this).load(DOWNLOAD_URL).start();
|
||||||
```
|
```
|
||||||
- 暂停下载
|
- 暂停下载
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Aria.whit(this).load(mEntity).stop();
|
Aria.whit(this).load(DOWNLOAD_URL).stop();
|
||||||
```
|
```
|
||||||
- 恢复下载
|
- 恢复下载
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Aria.whit(this).load(mEntity).resume();
|
Aria.whit(this).load(DOWNLOAD_URL).resume();
|
||||||
```
|
```
|
||||||
- 取消下载
|
- 取消下载
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Aria.whit(this).load(mEntity).cancel();
|
Aria.whit(this).load(DOWNLOAD_URL).cancel();
|
||||||
|
```
|
||||||
|
- 获取当前下载进度
|
||||||
|
|
||||||
|
```java
|
||||||
|
Aria.whit(this).load(DOWNLOAD_URL).getCurrentProgress();
|
||||||
|
```
|
||||||
|
- 获取文件大小
|
||||||
|
|
||||||
|
```java
|
||||||
|
Aria.whit(this).load(DOWNLOAD_URL).getFileSize();
|
||||||
```
|
```
|
||||||
|
|
||||||
### 四、关于Aria,你还需要知道的一些东西
|
### 四、关于Aria,你还需要知道的一些东西
|
||||||
@ -86,7 +105,7 @@ compile 'com.arialyy.aria:Aria:2.3.2'
|
|||||||
```java
|
```java
|
||||||
Aria.get(this).setReTryInterval(5000);
|
Aria.get(this).setReTryInterval(5000);
|
||||||
```
|
```
|
||||||
- 设置是否打开广播,如果你需要在Service后台获取下载完成情况,那么你需要打开Aria广播,[Aria广播配置](https://github.com/AriaLyy/Aria/blob/v_2.0/BroadCast.md)
|
- 设置是否打开广播,如果你需要在Service后台获取下载完成情况,那么你需要打开Aria广播,[Aria广播配置](https://github.com/AriaLyy/Aria/blob/v_2.0/BroadCast.md)
|
||||||
|
|
||||||
```java
|
```java
|
||||||
Aria.get(this).openBroadcast(true);
|
Aria.get(this).openBroadcast(true);
|
||||||
@ -94,9 +113,13 @@ compile 'com.arialyy.aria:Aria:2.3.2'
|
|||||||
|
|
||||||
***
|
***
|
||||||
## 开发日志
|
## 开发日志
|
||||||
+ v_2.1.0 修复大量bug
|
+ v_2.3.3
|
||||||
+ v_2.1.1 增加,选择最大下载任务数接口
|
- 添加断点支持
|
||||||
|
- 修改下载逻辑,让使用更加简单
|
||||||
|
- 修复一个内存泄露的bug
|
||||||
+ v_2.3.1 重命名为Aria,下载流程简化
|
+ v_2.3.1 重命名为Aria,下载流程简化
|
||||||
|
+ v_2.1.1 增加,选择最大下载任务数接口
|
||||||
|
+ v_2.1.0 修复大量bug
|
||||||
|
|
||||||
License
|
License
|
||||||
-------
|
-------
|
||||||
@ -113,4 +136,4 @@ License
|
|||||||
distributed under the License is distributed on an "AS IS" BASIS,
|
distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
See the License for the specific language governing permissions and
|
See the License for the specific language governing permissions and
|
||||||
limitations under the License.
|
limitations under the License.
|
||||||
|
Reference in New Issue
Block a user