英文文档

pull/330/head
AriaLyy 7 years ago
parent 71cdf790f9
commit 11160e8f99
  1. 304
      ENGLISH_README.md
  2. 298
      README.md

@ -0,0 +1,304 @@
# Aria
![图标](https://github.com/AriaLyy/DownloadUtil/blob/master/app/src/main/res/mipmap-hdpi/ic_launcher.png)</br>
## [中文文档](https://github.com/AriaLyy/Aria/blob/master/CHINESE_README.md)
Aria project is from the moment taht the work encountered in a file download management needs adn i was tortured at the time of the pain.</br>
Since then i have a idea which is to program a simple and easy to use,stable and efficient download framework.
Aria experienced 1.0 to 3.0 development, be more and more close to the original set by the target.
Aria has the following characteristics:
+ simple and convenient
- can be used in Activity, Service, Fragment, Dialog, popupWindow, Notification and other components
- support the task of automatic scheduling, the user does not need to care about the state of the task switch logic
- [Through the Aria event, it is easy to get the download status of the current download task](#status)
- [a code plus can get the current download speed](#interface)
- [a code can be dynamically set the maximum number of downloads](#parameters)
- [code to achieve speed limit](#interface)
- [It is easy to modify the number of download threads by modifying the configuration file](https://github.com/AriaLyy/Aria/blob/master/app/src/main/assets/aria_config.xml)
- [priority to download a task](#interface)
+ Support https address download
- It is easy to set the CA certificate information in the configuration file
+ Support 300,301,302 redirect download link download
+ Support upload operation
How do we to use Aria?
* [download](#Using)
* [upload](#Upload)
If you feel that Aria is helpful to you, your star and issues will be the greatest support for me.`^_^`
## Download
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion)
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion)
```java
compile 'com.arialyy.aria:aria-core:3.2.0'
annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.0'
```
## For example
![Multi-task download](https://github.com/AriaLyy/DownloadUtil/blob/master/img/download_img.gif)
![download speed limit](https://github.com/AriaLyy/DownloadUtil/blob/master/img/max_speed.gif)
## performance
![Performance display](https://github.com/AriaLyy/DownloadUtil/blob/master/img/performance.png)
***
## Using
Since Aria involves the operation of files and networks, you need to add the following permissions to the manifest file.
```xml
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
```
## Use Aria to download
* Add a task (do not download), when other download tasks are completed, will automatically download the waiting task
```java
Aria.download(this)
.load(DOWNLOAD_URL)
.setDownloadPath(DOWNLOAD_PATH) //file save path
.add();
```
* download
```java
Aria.download(this)
.load(DOWNLOAD_URL) //load download url
.setDownloadPath(DOWNLOAD_PATH) //file save path
.start(); //start download
```
* Pause
```java
Aria.download(this).load(DOWNLOAD_URL).pause();
```
* Resume download
```java
Aria.download(this).load(DOWNLOAD_URL).resume();
```
* Cancel download
```java
Aria.download(this).load(DOWNLOAD_URL).cancel();
```
### status
If you want to read the download progress or download the information, then you need to create an event class and register the event class into the Aria manager in the onResume (Activity, Fragment) or constructor (Dialog, PopupWindow).
1. Register the object to Aria
`Aria.download(this).register();` or `Aria.upload(this).register();`
```java
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
Aria.download(this).register();
}
```
2. Use`@Download` or `@Upload` to annotate your function<br>
**note:**
- Annotation is done by using `Apt`, so you do not need to worry that this will affect your machine's performance
- The annotated method**can not be modified by private**
- The annotated method**can have only one argument, and the parameter type must be either`DownloadTask` or `UploadTask`**
- Method name can be any string
3. In addition to using annotation methods in widget (Activity, Fragment, Dialog, Popupwindow), you can also use annotation functions in components such as Service, Notification, and so on.
```java
@Download.onPre(DOWNLOAD_URL)
protected void onPre(DownloadTask task) {}
@Download.onTaskStart
void taskStart(DownloadTask task) {}
@Download.onTaskRunning
protected void running(DownloadTask task) {}
@Download.onTaskResume
void taskResume(DownloadTask task) {}
@Download.onTaskStop
void taskStop(DownloadTask task) {}
@Download.onTaskCancel
void taskCancel(DownloadTask task) {}
@Download.onTaskFail
void taskFail(DownloadTask task) {}
@Download.onTaskComplete
void taskComplete(DownloadTask task) {}
@Download.onNoSupportBreakPoint
public void onNoSupportBreakPoint(DownloadTask task) {}
```
4. If you want to set up a listener for a single task, or for some specific task.<br>
**Adding a download address for a task in an annotation means that only the task triggers the annotated method.**
```java
@Download.onTaskRunning({
"https://test.xx.apk",
"http://test.xx2.apk"
}) void taskRunning(DownloadTask task) {
mAdapter.setProgress(task.getDownloadEntity());
}
```
In the above example,only the download address is`https://test.xx.apk` and `http://test.xx2.apk`will trigger the`taskRunning(DownloadTask task)`method。
### parameters
#### [Configuration file setting parameters](https://github.com/AriaLyy/Aria/blob/master/app/src/main/assets/aria_config.xml)
#### Set the parameters in the code
In addition to the file mode to modify the Aria parameter, the same, you can also modify the code in the Aria parameters</br>
Get the configuration file directly through`Aria.get(this).getDownloadConfig()`or`Aria.get(this).getUploadConfig()`</br>
and then modify the parameters:
```java
// 修改最大下载数,调用完成后,立即生效
// 如当前下载任务数是4,修改完成后,当前任务数会被Aria自动调度任务数
Aria.get(this).getDownloadConfig().setMaxTaskNum(3);
```
### interface
* Stop all tasks
```java
Aria.download(this).stopAllTask();
```
* Restore all stopped tasks
```java
Aria.download(this).resumeAllTask();
```
* Delete all tasks
```java
Aria.download(this).removeAllTask();
```
* Maximum download speed limit
```java
//单位为 kb
Aria.download(this).setMaxSpeed(speed);
```
* Get download speed for current tasks<br>
Speed parameters a bit special,need to [download the event support](#status)
``` java
@Override public void onTaskRunning(DownloadTask task) {
//If you turn on the speed unit conversion configuration, you can get the download speed with units in the following ways, such as: 1 mb/s
String convertSpeed = task.getConvertSpeed();
//If you have your own unit format, you can get the original byte length by the following method
long speed = task.getSpeed();
}
```
* Get the downloaded file size, the current progress percentage</br>
Likewise, you can also get the downloaded file size in the DownloadTask object
```
@Override public void onTaskRunning(DownloadTask task) {
 //Get the file size
long fileSize = task.getFileSize();
//Get the file size after conversion
String fileSize1 = task.getConvertFileSize();
//The current percentage of progress
int percent = task.getPercent();
}
```
* Set the high priority task<br>
If you want to give priority to download a task, you can
``` java
Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority();
```
* Set the extension field<br>
Sometimes, you may want to store some of your own data when you download it</br>
**TIP**: If you have more data, or the data is more complex, you can first convert the data to JSON, and then save it to Aria's download entity
```java
Aria.download(this).load(DOWNLOAD_URL).setExtendField(str)
```
## Upload
* Add a task (add only, do not upload)
```java
Aria.upload(this)
.load(filePath) //file path
.setUploadUrl(uploadUrl) // upload the path
.setAttachment(fileKey) //The server reads the file's key
.add();
```
* Upload
```java
Aria.upload(this)
.load(filePath) //file path
.setUploadUrl(uploadUrl) //upload the path
.setAttachment(fileKey) //The server reads the file's key
.start();
```
* cancel upload
```java
Aria.upload(this).load(filePath).cancel();
```
## Confused configuration
```
-dontwarn com.arialyy.aria.**
-keep class com.arialyy.aria.**{*;}
-keep class **$$DownloadListenerProxy{ *; }
-keep class **$$UploadListenerProxy{ *; }
-keepclasseswithmembernames class * {
@Download.* <methods>;
@Upload.* <methods>;
}
```
## others
Have any questions that can give me a message in the[issues](https://github.com/AriaLyy/Aria/issues)。
***
## 后续版本开发规划
* ~~http、scoket断点上传~~
* ~~实现上传队列调度功能~~
## Development log
+ v_3.1.9 Repair the stopAll queue without task when the problem of collapse, increase the function for a single task monitor
+ v_3.1.7 repair some files can not download the bug, increase the apt annotation method, the incident is more simple
+ v_3.1.6 When the task is canceled ontaskCancel callback twice
+ v_3.1.5 Optimize the code structure, increase the priority download task function.
+ v_3.1.4 Repair the fast switching, pause, and restore functions, the probability of re-download problems, add onPre () callback, onPre () used to request the interface before the implementation of interface UI update operation.
+ v_3.1.0 Add the Aria configuration file to optimize the code
+ v_3.0.3 Repair the pause after deleting the task, flashing the problem, add the api to delete the record
+ v_3.0.2 supports 30x redirect link download
+ v_3.0.0 add upload task support to fix some bugs that have been discovered
License
-------
Copyright 2016 AriaLyy(https://github.com/AriaLyy/Aria)
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.

@ -1,97 +1,94 @@
# Aria # Aria
![图标](https://github.com/AriaLyy/DownloadUtil/blob/master/app/src/main/res/mipmap-hdpi/ic_launcher.png)</br> ![图标](https://github.com/AriaLyy/DownloadUtil/blob/v_2.0/app/src/main/res/mipmap-hdpi/ic_launcher.png)</br>
[ENGLISH DOC](https://github.com/AriaLyy/Aria/blob/master/ENGLISH_README.md)
## [中文文档](https://github.com/AriaLyy/Aria/blob/master/CHINESE_README.md) Aria项目源于15年工作中遇到的一个文件下载管理的需求,当时被下载折磨的痛不欲生,从那时起便萌生了编写一个简单易用,稳当高效的下载框架,aria经历了1.0到3.0的开发,算是越来越接近当初所制定的目标了。
Aria project is from the moment taht the work encountered in a file download management needs adn i was tortured at the time of the pain.</br> Aria有以下特点:
Since then i have a idea which is to program a simple and easy to use,stable and efficient download framework. + 简单、方便
Aria experienced 1.0 to 3.0 development, be more and more close to the original set by the target. - 可以在Activity、Service、Fragment、Dialog、popupWindow、Notification等组件中使用
- 支持任务自动调度,使用者不需要关心任务状态切换的逻辑
Aria has the following characteristics: - [通过Aria的事件,能很容易获取当前下载任务的下载状态](#下载状态获取)
+ simple and convenient - [一句代码加可以获取当前的下载速度](#常用接口)
- can be used in Activity, Service, Fragment, Dialog, popupWindow, Notification and other components - [一句代码就可以动态设置最大下载数](#代码中设置参数)
- support the task of automatic scheduling, the user does not need to care about the state of the task switch logic - [一句代码实现速度限制](#常用接口)
- [Through the Aria event, it is easy to get the download status of the current download task](#status) - [通过修改配置文件很容易就能修改下载线程数](#配置文件设置参数)
- [a code plus can get the current download speed](#interface) - [优先下载某一个任务](#常用接口)
- [a code can be dynamically set the maximum number of downloads](#parameters)
- [code to achieve speed limit](#interface) + 支持https地址下载
- [It is easy to modify the number of download threads by modifying the configuration file](https://github.com/AriaLyy/Aria/blob/master/app/src/main/assets/aria_config.xml) - 在配置文件中很容易就可以设置CA证书的信息
- [priority to download a task](#interface) + 支持300、301、302重定向下载链接下载
+ 支持上传操作
+ Support https address download
- It is easy to set the CA certificate information in the configuration file
+ Support 300,301,302 redirect download link download Aria怎样使用?
+ Support upload operation * [下载](#使用)
* [上传](#上传)
How do we to use Aria?
* [download](#Using) 如果你觉得Aria对你有帮助,您的star和issues将是对我最大支持.`^_^`
* [upload](#Upload)
## 下载
If you feel that Aria is helpful to you, your star and issues will be the greatest support for me.`^_^`
## Download
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion) [![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion)
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion) [![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion)
```java ```java
compile 'com.arialyy.aria:aria-core:3.2.0' compile 'com.arialyy.aria:Aria:3.1.9'
annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.0' annotationProcessor 'com.arialyy.aria:aria-compiler:3.1.9'
``` ```
## For example ## 示例
![Multi-task download](https://github.com/AriaLyy/DownloadUtil/blob/master/img/download_img.gif) ![多任务下载](https://github.com/AriaLyy/DownloadUtil/blob/master/img/download_img.gif)
![download speed limit](https://github.com/AriaLyy/DownloadUtil/blob/master/img/max_speed.gif) ![网速下载限制](https://github.com/AriaLyy/DownloadUtil/blob/master/img/max_speed.gif)
## performance ## 性能
![Performance display](https://github.com/AriaLyy/DownloadUtil/blob/master/img/performance.png) ![性能展示](https://github.com/AriaLyy/DownloadUtil/blob/master/img/performance.png)
*** ***
## Using ## 使用
Since Aria involves the operation of files and networks, you need to add the following permissions to the manifest file. 由于Aria涉及到文件和网络的操作,因此需要你在manifest文件中添加以下权限
```xml ```xml
<uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/> <uses-permission android:name="android.permission.MOUNT_UNMOUNT_FILESYSTEMS"/>
<uses-permission android:name="android.permission.INTERNET"/> <uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/> <uses-permission android:name="android.permission.WRITE_EXTERNAL_STORAGE"/>
``` ```
## Use Aria to download ## 使用Aria进行下载
* Add a task (do not download), when other download tasks are completed, will automatically download the waiting task * 添加任务(不进行下载),当其他下载任务完成时,将自动下载等待中的任务
```java ```java
Aria.download(this) Aria.download(this)
.load(DOWNLOAD_URL) .load(DOWNLOAD_URL)
.setDownloadPath(DOWNLOAD_PATH) //file save path .setDownloadPath(DOWNLOAD_PATH) //文件保存路径
.add(); .add();
``` ```
* download * 下载
```java ```java
Aria.download(this) Aria.download(this)
.load(DOWNLOAD_URL) //load download url .load(DOWNLOAD_URL) //读取下载地址
.setDownloadPath(DOWNLOAD_PATH) //file save path .setDownloadPath(DOWNLOAD_PATH) //设置文件保存的完整路径
.start(); //start download .start(); //启动下载
``` ```
* Pause * 暂停
```java ```java
Aria.download(this).load(DOWNLOAD_URL).pause(); Aria.download(this).load(DOWNLOAD_URL).pause();
``` ```
* Resume download * 恢复下载
```java ```java
Aria.download(this).load(DOWNLOAD_URL).resume(); Aria.download(this).load(DOWNLOAD_URL).resume();
``` ```
* Cancel download * 取消下载
```java ```java
Aria.download(this).load(DOWNLOAD_URL).cancel(); Aria.download(this).load(DOWNLOAD_URL).cancel();
``` ```
### status ### 下载状态获取
If you want to read the download progress or download the information, then you need to create an event class and register the event class into the Aria manager in the onResume (Activity, Fragment) or constructor (Dialog, PopupWindow). 如果你希望读取下载进度或下载信息,那么你需要创建事件类,并在onResume(Activity、Fragment)或构造函数(Dialog、PopupWindow),将该事件类注册到Aria管理器。
1. Register the object to Aria 1. 将对象注册到Aria
`Aria.download(this).register();` or `Aria.upload(this).register();` `Aria.download(this).register();`或`Aria.upload(this).register();`
```java ```java
@Override @Override
protected void onCreate(Bundle savedInstanceState) { protected void onCreate(Bundle savedInstanceState) {
@ -100,14 +97,14 @@ If you want to read the download progress or download the information, then you
} }
``` ```
2. Use`@Download` or `@Upload` to annotate your function<br> 2. 使用`@Download`或`@Upload`注解你的函数<br>
**note:** **注意:**
- Annotation is done by using `Apt`, so you do not need to worry that this will affect your machine's performance - 注解回掉采用Apt的方式实现,所以,你不需要担心这会影响你机器的性能
- The annotated method**can not be modified by private** - 被注解的方法**不能被private修饰**
- The annotated method**can have only one argument, and the parameter type must be either`DownloadTask` or `UploadTask`** - 被注解的方法**只能有一个参数,并且参数类型必须是`DownloadTask`或`UploadTask`**
- Method name can be any string - 方法名可以为任意字符串
3. In addition to using annotation methods in widget (Activity, Fragment, Dialog, Popupwindow), you can also use annotation functions in components such as Service, Notification, and so on. 3. 除了在widget(Activity、Fragment、Dialog、Popupwindow)中使用注解方法外,你还可以在Service、Notification等组件中使用注解函数。
```java ```java
@Download.onPre(DOWNLOAD_URL) @Download.onPre(DOWNLOAD_URL)
@ -138,8 +135,8 @@ If you want to read the download progress or download the information, then you
public void onNoSupportBreakPoint(DownloadTask task) {} public void onNoSupportBreakPoint(DownloadTask task) {}
``` ```
4. If you want to set up a listener for a single task, or for some specific task.<br> 4. 如果你希望对单个任务,或某一些特定任务设置监听器。<br>
**Adding a download address for a task in an annotation means that only the task triggers the annotated method.** **在注解中添加任务的下载地址,则表示只有该任务才会触发被注解的方法**
```java ```java
@Download.onTaskRunning({ @Download.onTaskRunning({
@ -149,110 +146,173 @@ If you want to read the download progress or download the information, then you
mAdapter.setProgress(task.getDownloadEntity()); mAdapter.setProgress(task.getDownloadEntity());
} }
``` ```
In the above example,only the download address is`https://test.xx.apk` and `http://test.xx2.apk`will trigger the`taskRunning(DownloadTask task)`method。 在上面的例子中,只有下载地址是`https://test.xx.apk`和`http://test.xx2.apk`才会触发
`taskRunning(DownloadTask task)`方法。
### parameters
#### [Configuration file setting parameters](https://github.com/AriaLyy/Aria/blob/master/app/src/main/assets/aria_config.xml) ### Aria参数配置
#### Set the parameters in the code #### 配置文件设置参数
In addition to the file mode to modify the Aria parameter, the same, you can also modify the code in the Aria parameters</br> 创建`aria_config.xml`文件,将其放在`assets`目录下,添加以下内容
Get the configuration file directly through`Aria.get(this).getDownloadConfig()`or`Aria.get(this).getUploadConfig()`</br> ```xml
and then modify the parameters: <?xml version="1.0" encoding="utf-8"?>
<aria>
<!--注意,修改该配置文件中的属性会覆盖代码中所设置的属性-->
<download>
<!--设置下载线程,线程下载数改变后,新的下载任务才会生效-->
<threadNum value="4"/>
<!--是否打开下载广播,默认为false,不建议使用广播,你可以使用Download注解来实现事件回调-->
<openBroadcast value="false"/>
<!--设置下载队列最大任务数, 默认为2-->
<maxTaskNum value="2"/>
<!--设置下载失败,重试次数,默认为10-->
<reTryNum value="10"/>
<!--设置重试间隔,单位为毫秒,默认2000毫秒-->
<reTryInterval value="5000"/>
<!--设置url连接超时时间,单位为毫秒,默认5000毫秒-->
<connectTimeOut value="5000"/>
<!--设置IO流读取时间,单位为毫秒,默认20000毫秒,该时间不能少于10000毫秒-->
<iOTimeOut value="20000"/>
<!--设置写文件buff大小,该数值大小不能小于2048,数值变小,下载速度会变慢-->
<buffSize value="8192"/>
<!--设置https ca 证书信息;path 为assets目录下的CA证书完整路径,name 为CA证书名-->
<ca name="" path=""/>
<!--是否需要转换速度单位,转换完成后为:1b/s、1kb/s、1mb/s、1gb/s、1tb/s,如果不需要将返回byte长度-->
<convertSpeed value="true"/>
<!--设置最大下载速度,单位:kb, 为0表示不限速-->
<maxSpeed value="0"/>
</download>
<upload>
<!--是否打开上传广播,默认为false,不建议使用广播,你可以使用Upload注解来实现事件回调-->
<openBroadcast value="false"/>
<!--设置上传队列最大任务数, 默认为2-->
<maxTaskNum value="2"/>
<!--设置上传失败,重试次数,默认为10-->
<reTryNum value="10"/>
<!--设置重试间隔,单位为毫秒-->
<reTryInterval value="2000"/>
<!--设置url连接超时时间,单位为毫秒,默认5000毫秒-->
<connectTimeOut value="5000"/>
</upload>
</aria>
```
#### 代码中设置参数
除了文件方式外修改Aria参数外,同样的,你也可以在代码中动态修改Aria参数</br>
通过`Aria.get(this).getDownloadConfig()`或`Aria.get(this).getUploadConfig()`直接获取配置文件,然后修改参数</br>
如以下所示:
```java ```java
// 修改最大下载数,调用完成后,立即生效 // 修改最大下载数,调用完成后,立即生效
// 如当前下载任务数是4,修改完成后,当前任务数会被Aria自动调度任务数 // 如当前下载任务数是4,修改完成后,当前任务数会被Aria自动调度任务数
Aria.get(this).getDownloadConfig().setMaxTaskNum(3); Aria.get(this).getDownloadConfig().setMaxTaskNum(3);
``` ```
### interface ### 常用接口
* Stop all tasks * 停止所有任务
```java ```java
Aria.download(this).stopAllTask(); Aria.download(this).stopAllTask();
``` ```
* Restore all stopped tasks * 恢复所有停止的任务
```java ```java
Aria.download(this).resumeAllTask(); Aria.download(this).resumeAllTask();
``` ```
* Delete all tasks * 删除所有任务
```java ```java
Aria.download(this).removeAllTask(); Aria.download(this).removeAllTask();
``` ```
* Maximum download speed limit * 最大下载速度限制
```java ```java
//单位为 kb //单位为 kb
Aria.download(this).setMaxSpeed(speed); Aria.download(this).setMaxSpeed(speed);
``` ```
* Get download speed for current tasks<br> * 获取当前任务的下载速度<br>
Speed parameters a bit special,need to [download the event support](#status) 速度参数有点特殊,需要[下载事件支持](#下载状态获取)
``` java ``` java
@Override public void onTaskRunning(DownloadTask task) { @Override public void onTaskRunning(DownloadTask task) {
//If you turn on the speed unit conversion configuration, you can get the download speed with units in the following ways, such as: 1 mb/s //如果你打开了速度单位转换配置,将可以通过以下方法获取带单位的下载速度,如:1 mb/s
String convertSpeed = task.getConvertSpeed(); String convertSpeed = task.getConvertSpeed();
//If you have your own unit format, you can get the original byte length by the following method //如果你有自己的单位格式,可以通过以下方法获取原始byte长度
long speed = task.getSpeed(); long speed = task.getSpeed();
} }
``` ```
* Get the downloaded file size, the current progress percentage</br> * 获取下载的文件大小、当前进度百分比</br>
Likewise, you can also get the downloaded file size in the DownloadTask object 同样的,你也可以在DownloadTask对象中获取下载的文件大小
``` ```
@Override public void onTaskRunning(DownloadTask task) { @Override public void onTaskRunning(DownloadTask task) {
 //Get the file size  //获取文件大小
long fileSize = task.getFileSize(); long fileSize = task.getFileSize();
//Get the file size after conversion //获取单位转换后的文件大小
String fileSize1 = task.getConvertFileSize(); String fileSize1 = task.getConvertFileSize();
//The current percentage of progress //当前进度百分比
int percent = task.getPercent(); int percent = task.getPercent();
} }
``` ```
* Set the high priority task<br> * 设置高优先级任务<br>
If you want to give priority to download a task, you can 如果你希望优先下载某一个任务,你可以
``` java ``` java
Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority(); Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority();
``` ```
* Set the extension field<br> * 设置扩展字段<br>
Sometimes, you may want to store some of your own data when you download it</br> 有的时候,你可能希望在下载的时候存放一些自己的数据</br>
**TIP**: If you have more data, or the data is more complex, you can first convert the data to JSON, and then save it to Aria's download entity **TIP**: 如果你数据比较多,或者数据比较复杂,你可以先把数据转换为**JSON**,然后再将其存到Aria的下载实体中
```java ```java
Aria.download(this).load(DOWNLOAD_URL).setExtendField(str) Aria.download(this).load(DOWNLOAD_URL).setExtendField(str)
``` ```
## Upload ## 上传
* 添加任务(只添加,不上传)
* Add a task (add only, do not upload)
```java ```java
Aria.upload(this) Aria.upload(this)
.load(filePath) //file path .load(filePath) //文件路径
.setUploadUrl(uploadUrl) // upload the path .setUploadUrl(uploadUrl) //上传路径
.setAttachment(fileKey) //The server reads the file's key .setAttachment(fileKey) //服务器读取文件的key
.add(); .add();
``` ```
* Upload * 上传
```java ```java
Aria.upload(this) Aria.upload(this)
.load(filePath) //file path .load(filePath) //文件路径
.setUploadUrl(uploadUrl) //upload the path .setUploadUrl(uploadUrl) //上传路径
.setAttachment(fileKey) //The server reads the file's key .setAttachment(fileKey) //服务器读取文件的key
.start(); .start();
``` ```
* cancel upload * 取消上传
```java ```java
Aria.upload(this).load(filePath).cancel(); Aria.upload(this).load(filePath).cancel();
``` ```
## Confused configuration ## 混淆配置
``` ```
-dontwarn com.arialyy.aria.** -dontwarn com.arialyy.aria.**
-keep class com.arialyy.aria.**{*;} -keep class com.arialyy.aria.**{*;}
@ -265,8 +325,8 @@ Aria.download(this).load(DOWNLOAD_URL).setExtendField(str)
``` ```
## others ## 其他
Have any questions that can give me a message in the[issues](https://github.com/AriaLyy/Aria/issues) 有任何问题,可以在[issues](https://github.com/AriaLyy/Aria/issues)给我留言反馈
*** ***
@ -275,16 +335,26 @@ Aria.download(this).load(DOWNLOAD_URL).setExtendField(str)
* ~~实现上传队列调度功能~~ * ~~实现上传队列调度功能~~
## Development log ## 开发日志
+ v_3.1.9 Repair the stopAll queue without task when the problem of collapse, increase the function for a single task monitor + v_3.1.9 修复stopAll队列没有任务时崩溃的问题,增加针对单个任务监听的功能
+ v_3.1.7 repair some files can not download the bug, increase the apt annotation method, the incident is more simple + v_3.1.7 修复某些文件下载不了的bug,增加apt注解方法,事件获取更加简单了
+ v_3.1.6 When the task is canceled ontaskCancel callback twice + v_3.1.6 取消任务时onTaskCancel回调两次的bug
+ v_3.1.5 Optimize the code structure, increase the priority download task function. + v_3.1.5 优化代码结构,增加优先下载任务功能。
+ v_3.1.4 Repair the fast switching, pause, and restore functions, the probability of re-download problems, add onPre () callback, onPre () used to request the interface before the implementation of interface UI update operation. + v_3.1.4 修复快速切换,暂停、恢复功能时,概率性出现的重新下载问题,添加onPre()回调,onPre()用于请求地址之前执行界面UI更新操作。
+ v_3.1.0 Add the Aria configuration file to optimize the code + v_3.1.0 添加Aria配置文件,优化代码
+ v_3.0.3 Repair the pause after deleting the task, flashing the problem, add the api to delete the record + v_3.0.3 修复暂停后删除任务,闪退问题,添加删除记录的api
+ v_3.0.2 supports 30x redirect link download + v_3.0.2 支持30x重定向链接下载
+ v_3.0.0 add upload task support to fix some bugs that have been discovered + v_3.0.0 添加上传任务支持,修复一些已发现的bug
+ v_2.4.4 修复不支持断点的下载链接拿不到文件大小的问题
+ v_2.4.3 修复404链接卡顿的问题
+ v_2.4.2 修复失败重试无效的bug
+ v_2.4.1 修复下载慢的问题,修复application、service 不能使用的问题
+ v_2.4.0 支持https链接下载
+ v_2.3.8 修复数据错乱的bug、添加fragment支持
+ v_2.3.6 添加dialog、popupWindow支持
+ v_2.3.3 添加断点支持、修改下载逻辑,让使用更加简单、修复一个内存泄露的bug
+ v_2.3.1 重命名为Aria,下载流程简化
+ v_2.1.1 增加,选择最大下载任务数接口
License License
------- -------

Loading…
Cancel
Save