You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
 
 
laoyuyu 01eeaf470c Update README.md 7 years ago
Aria as 热启动bug修改 7 years ago
AriaAnnotations 合并代码 8 years ago
AriaCompiler 合并代码 8 years ago
app 修复 https://github.com/AriaLyy/Aria/issues/47 8 years ago
aria/src/main 添加获取扩展字段的方法 8 years ago
gradle/wrapper merge dev code 8 years ago
img 增加速度限制说明 8 years ago
.gitignore 忽略cache 8 years ago
BroadCast.md 3.1.2代码合并 8 years ago
CHINESE_README.md chinese readme 8 years ago
DownloadApi.md Update DownloadApi.md 8 years ago
LICENSE Added files via upload 9 years ago
README.md Update README.md 7 years ago
build.gradle 合并代码 8 years ago
gradle.properties 速度单位转换 8 years ago
gradlew 修复目录结构 9 years ago
gradlew.bat 修复目录结构 9 years ago
settings.gradle 用注解实现回调 8 years ago

README.md

Aria

图标

中文文档

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.
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:

How do we to use Aria?

If you feel that Aria is helpful to you, your star and issues will be the greatest support for me.^_^

Download

Download Download

compile 'com.arialyy.aria:aria-core:3.2.0'
annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.0'

For example

Multi-task download download speed limit

performance

Performance display


Using

Since Aria involves the operation of files and networks, you need to add the following permissions to the manifest file.

<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

    Aria.download(this)
        .load(DOWNLOAD_URL)
        .setDownloadPath(DOWNLOAD_PATH)	//file save path
        .add();
    
  • download

    Aria.download(this)
        .load(DOWNLOAD_URL)     //load download url
        .setDownloadPath(DOWNLOAD_PATH)    //file save path
        .start();   //start download
    
  • Pause

    Aria.download(this).load(DOWNLOAD_URL).pause();
    
  • Resume download

    Aria.download(this).load(DOWNLOAD_URL).resume();
    
  • Cancel download

    Aria.download(this).load(DOWNLOAD_URL).cancel();
    

downloadStatus

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();

@Override
protected void onCreate(Bundle savedInstanceState) {
   super.onCreate(savedInstanceState);
   Aria.download(this).register();
 }
  1. Use@Download or @Upload to annotate your function
    note:

    • Annotation is done by using Apt, so you do not need to worry that this will affect your machine's performance
    • The annotated methodcan not be modified by private
    • The annotated methodcan have only one argument, and the parameter type must be eitherDownloadTask or UploadTask
    • Method name can be any string
  2. 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.

@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) {}

  1. If you want to set up a listener for a single task, or for some specific task.
    Adding a download address for a task in an annotation means that only the task triggers the annotated method.
@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 ishttps://test.xx.apk and http://test.xx2.apkwill trigger thetaskRunning(DownloadTask task)method。

parameters

Configuration file setting parameters

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
Get the configuration file directly throughAria.get(this).getDownloadConfig()orAria.get(this).getUploadConfig()
and then modify the parameters:

// 修改最大下载数,调用完成后,立即生效
// 如当前下载任务数是4,修改完成后,当前任务数会被Aria自动调度任务数
Aria.get(this).getDownloadConfig().setMaxTaskNum(3);

interface

  • Stop all tasks
Aria.download(this).stopAllTask();
  • Restore all stopped tasks
Aria.download(this).resumeAllTask();
  • Delete all tasks
Aria.download(this).removeAllTask();
  • Maximum download speed limit
//单位为 kb
Aria.download(this).setMaxSpeed(speed);
@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
    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
    If you want to give priority to download a task, you can
Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority();
  • Set the extension field
    Sometimes, you may want to store some of your own data when you download it
    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
Aria.download(this).load(DOWNLOAD_URL).setExtendField(str)

Upload

  • Add a task (add only, do not upload)
Aria.upload(this)
    .load(filePath)     //file path
    .setUploadUrl(uploadUrl)  // upload the path
    .setAttachment(fileKey)   //The server reads the file's key
    .add();
  • Upload
Aria.upload(this)
    .load(filePath)     //file path
    .setUploadUrl(uploadUrl)  //upload the path
    .setAttachment(fileKey)   //The server reads the file's key
    .start();
  • cancel upload
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 theissues


后续版本开发规划

  • 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.