From b2db650aa3ac23ab8c7d82d9ad87070971caed92 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 13 Jun 2017 16:55:30 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20https://github.com/AriaLyy?= =?UTF-8?q?/Aria/issues/36#issuecomment-307994556=20,=20https://github.com?= =?UTF-8?q?/AriaLyy/Aria/issues/40#issuecomment-307784428?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aria/build.gradle | 8 +- .../main/java/com/arialyy/aria/core/Aria.java | 6 + .../aria/core/download/ConnectionHelp.java | 26 +- .../aria/core/download/DownloadReceiver.java | 4 +- .../aria/core/download/SingleThreadTask.java | 16 +- .../com/arialyy/aria/util/CommonUtil.java | 32 +- README.md | 58 +-- app/src/main/assets/aria_config.xml | 339 ++---------------- .../simple/download/SingleTaskActivity.java | 12 +- build.gradle | 4 +- 10 files changed, 157 insertions(+), 348 deletions(-) diff --git a/Aria/build.gradle b/Aria/build.gradle index 3abf9816..32dbc8b6 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -8,8 +8,8 @@ android { defaultConfig { minSdkVersion 9 targetSdkVersion 23 - versionCode 315 - versionName "3.1.5" + versionCode 317 + versionName "3.1.7" } buildTypes { release { @@ -23,8 +23,8 @@ dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' - compile project(':AriaCompiler') -// compile project(':AriaAnnotations') +// compile project(':AriaCompiler') + compile project(':AriaAnnotations') } //apply from: 'jcenter.gradle' diff --git a/Aria/src/main/java/com/arialyy/aria/core/Aria.java b/Aria/src/main/java/com/arialyy/aria/core/Aria.java index f4cfd252..43e679d8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/Aria.java +++ b/Aria/src/main/java/com/arialyy/aria/core/Aria.java @@ -26,6 +26,8 @@ import android.app.Service; import android.content.Context; import android.os.Build; import android.widget.PopupWindow; +import com.arialyy.annotations.Download; +import com.arialyy.annotations.Upload; import com.arialyy.aria.core.download.DownloadReceiver; import com.arialyy.aria.core.scheduler.IDownloadSchedulerListener; import com.arialyy.aria.core.scheduler.ISchedulerListener; @@ -171,7 +173,9 @@ import com.arialyy.aria.core.upload.UploadTask; /** * 上传任务状态监听 + * @deprecated 请使用注解函数的方式来实现事件的获取{@see {@link Upload}} */ + @Deprecated public static class UploadSchedulerListener implements ISchedulerListener { /** @@ -218,7 +222,9 @@ import com.arialyy.aria.core.upload.UploadTask; /** * 下载任务状态监听 + * @deprecated 请使用注解函数的方式来实现事件的获取{@see {@link Download}} */ + @Deprecated public static class DownloadSchedulerListener implements IDownloadSchedulerListener { /** diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/ConnectionHelp.java b/Aria/src/main/java/com/arialyy/aria/core/download/ConnectionHelp.java index efbc17a4..dd3efc4d 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/ConnectionHelp.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/ConnectionHelp.java @@ -71,9 +71,29 @@ class ConnectionHelp { } conn.setRequestProperty("Charset", "UTF-8"); conn.setRequestProperty("User-Agent", - "Mozilla/4.0 (compatible; MSIE 8.0; Windows NT 5.2; Trident/4.0; .NET CLR 1.1.4322; .NET CLR 2.0.50727; .NET CLR 3.0.04506.30; .NET CLR 3.0.4506.2152; .NET CLR 3.5.30729)"); - conn.setRequestProperty("Accept", - "image/gif, image/jpeg, image/pjpeg, image/pjpeg, application/x-shockwave-flash, application/xaml+xml, application/vnd.ms-xpsdocument, application/x-ms-xbap, application/x-ms-application, application/vnd.ms-excel, application/vnd.ms-powerpoint, application/msword, */*"); + "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36"); + StringBuilder accept = new StringBuilder(); + accept.append("image/gif, ") + .append("image/jpeg, ") + .append("image/pjpeg, ") + .append("image/webp, ") + .append("image/*, ") + .append("application/xml") + .append("application/xaml+xml, ") + .append("application/xhtml+xml, ") + .append("application/x-shockwave-flash, ") + .append("application/x-ms-xbap, ") + .append("application/x-ms-application, ") + .append("application/msword, ") + .append("application/vnd.ms-excel, ") + .append("application/vnd.ms-xpsdocument, ") + .append("application/vnd.ms-powerpoint, ") + .append("text/plain, ") + .append("text/html, ") + .append("*/*"); + conn.setRequestProperty("Accept", accept.toString()); + conn.setRequestProperty("Accept-Encoding", "identity"); + conn.setRequestProperty("Accept-Charset", "UTF-8"); conn.setRequestProperty("Connection", "Keep-Alive"); //302获取重定向地址 conn.setInstanceFollowRedirects(false); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java index 364ccf4a..d315e9b0 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java @@ -39,13 +39,13 @@ public class DownloadReceiver implements IReceiver { public Object obj; public ISchedulerListener listener; - /** * 设置最大下载速度,单位:kb + * 该方法为实验性功能,清不要轻易在生产环境中使用。 * * @param maxSpeed 为0表示不限速 */ - public void setMaxSpeed(double maxSpeed) { + @Deprecated public void setMaxSpeed(double maxSpeed) { AriaManager.getInstance(AriaManager.APP).getDownloadConfig().setMsxSpeed(maxSpeed); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java index fbaa6b2c..c4dc1b65 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/SingleThreadTask.java @@ -15,6 +15,7 @@ */ package com.arialyy.aria.core.download; +import android.os.Build; import android.text.TextUtils; import android.util.Log; import com.arialyy.aria.core.AriaManager; @@ -27,7 +28,9 @@ import java.math.BigDecimal; import java.net.HttpURLConnection; import java.net.MalformedURLException; import java.net.URL; +import java.util.HashSet; import java.util.Properties; +import java.util.Set; /** * Created by lyy on 2017/1/18. @@ -41,8 +44,9 @@ final class SingleThreadTask implements Runnable { private int mBufSize; private IDownloadListener mListener; private DownloadStateConstance CONSTANCE; + /** - * speed = (bufSize / 1024) * threadNum / sleepTime; (8192 / 1024) * 4 / 1= 32 kb/s + * speed = (bufSize / 1024) * CoresNum / sleepTime; (8192 / 1024) * 4 / 1= 32 kb/s */ private long mSleepTime = 0; @@ -65,14 +69,17 @@ final class SingleThreadTask implements Runnable { if (-0.9999 < maxSpeed && maxSpeed < 0.00001) { mSleepTime = 0; } else { - BigDecimal db = new BigDecimal(((mBufSize / 1024) / maxSpeed) * 1000); + BigDecimal db = new BigDecimal( + ((mBufSize / 1024) * (filterVersion() ? 1 : CONSTANCE.THREAD_NUM) / maxSpeed) * 1000); db.setScale(0, BigDecimal.ROUND_HALF_UP); mSleepTime = db.longValue(); - //mSleepTime = (long) ((mBufSize / 1024) * CONSTANCE.THREAD_NUM / maxSpeed * 1000); - //mSleepTime = (long) ((mBufSize / 1024) / maxSpeed * 1000); } } + private boolean filterVersion() { + return Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP; + } + @Override public void run() { HttpURLConnection conn; InputStream is; @@ -92,7 +99,6 @@ final class SingleThreadTask implements Runnable { //在头里面请求下载开始位置和结束位置 conn.setRequestProperty("Range", "bytes=" + mConfigEntity.START_LOCATION + "-" + (mConfigEntity.END_LOCATION - 1)); - //"bytes=" + mConfigEntity.START_LOCATION + "-" + (mConfigEntity.END_LOCATION)); } else { Log.w(TAG, "该下载不支持断点"); } diff --git a/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java b/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java index a8fa24d1..d3a13ba9 100644 --- a/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java @@ -26,6 +26,7 @@ import com.arialyy.aria.core.command.CmdFactory; import com.arialyy.aria.core.command.AbsCmd; import com.arialyy.aria.core.inf.AbsTaskEntity; import java.io.File; +import java.io.FileFilter; import java.io.FileInputStream; import java.io.FileNotFoundException; import java.io.FileOutputStream; @@ -40,6 +41,7 @@ import java.util.ArrayList; import java.util.Collections; import java.util.List; import java.util.Properties; +import java.util.regex.Pattern; /** * Created by lyy on 2016/1/22. @@ -47,6 +49,35 @@ import java.util.Properties; public class CommonUtil { private static final String TAG = "CommonUtil"; + /** + * 获取CPU核心数 + */ + public static int getNumCores() { + //Private Class to display only CPU devices in the directory listing + class CpuFilter implements FileFilter { + @Override public boolean accept(File pathname) { + //Check if filename is "cpu", followed by a single digit number + return Pattern.matches("cpu[0-9]", pathname.getName()); + } + } + + try { + //Get directory containing CPU info + File dir = new File("/sys/devices/system/cpu/"); + //Filter to only list the devices we care about + File[] files = dir.listFiles(new CpuFilter()); + Log.d(TAG, "CPU Count: " + files.length); + //Return the number of cores (virtual CPU devices) + return files.length; + } catch (Exception e) { + //Print exception + Log.d(TAG, "CPU Count: Failed."); + e.printStackTrace(); + //Default to return 1 core + return 1; + } + } + /** * 通过流创建文件 */ @@ -75,7 +106,6 @@ public class CommonUtil { } String calculatedDigest = getFileMD5(updateFile); - Log.d(TAG, "fileMd5Code:" + calculatedDigest); if (calculatedDigest == null) { Log.e(TAG, "calculatedDigest null"); return false; diff --git a/README.md b/README.md index a93f1ac4..157fc610 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,8 @@ Aria怎样使用? ## 下载 [![Download](https://api.bintray.com/packages/arialyy/maven/Aria/images/download.svg)](https://bintray.com/arialyy/maven/Aria/_latestVersion)
```java -compile 'com.arialyy.aria:Aria:3.1.5' +compile 'com.arialyy.aria:Aria:3.1.7' +annotationProcessor 'com.arialyy.aria:aria-compiler:3.1.7' ``` ## 示例 @@ -49,7 +50,7 @@ compile 'com.arialyy.aria:Aria:3.1.5' ```java Aria.download(this) .load(DOWNLOAD_URL) - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") //文件保存路径 + .setDownloadPath(DOWNLOAD_PATH) //文件保存路径 .add(); ``` @@ -58,7 +59,7 @@ compile 'com.arialyy.aria:Aria:3.1.5' ```java Aria.download(this) .load(DOWNLOAD_URL) //读取下载地址 - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") //设置文件保存的完整路径 + .setDownloadPath(DOWNLOAD_PATH) //设置文件保存的完整路径 .start(); //启动下载 ``` * 暂停 @@ -84,49 +85,57 @@ compile 'com.arialyy.aria:Aria:3.1.5' ` Aria.download(this).register();`或`Aria.upload(this).register();` ```java - @Override protected void onCreate(Bundle savedInstanceState) { + @Override + protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); Aria.download(this).register(); } ``` * 使用'@Download'或'@Upload'注解你的函数 + **注意:** - 注解回掉采用Apt的方式实现,所以,你不需要担心这会影响你机器的性能 - 被注解的方法**不能被private修饰** - 被注解的方法**只能有一个参数,并且参数类型必须是`DownloadTask`或`UploadTask`** - - 方法名可以为任意字符 + - 方法名可以为任意字符串 + +* 除了在widget(Activity、Fragment、Dialog、Popupwindow)中使用注解方法外,你还可以在Service、Notification等组件中使用注解函数。 ```java - @Download.onPre protected void onPre(DownloadTask task) {} + @Download.onPre + protected void onPre(DownloadTask task) {} - @Download.onTaskStart void taskStart(DownloadTask task) { + @Download.onTaskStart + void taskStart(DownloadTask task) { //通过下载地址可以判断任务是否是你指定的任务 if (task.getKey().equals(DOWNLOAD_URL)) { } } - @Download.onTaskRunning protected void running(DownloadTask task) {} + @Download.onTaskRunning + protected void running(DownloadTask task) {} - @Download.onTaskResume void taskResume(DownloadTask task) {} + @Download.onTaskResume + void taskResume(DownloadTask task) {} - @Download.onTaskStop void taskStop(DownloadTask task) {} + @Download.onTaskStop + void taskStop(DownloadTask task) {} - @Download.onTaskCancel void taskCancel(DownloadTask task) {} + @Download.onTaskCancel + void taskCancel(DownloadTask task) {} - @Download.onTaskFail void taskFail(DownloadTask task) {} + @Download.onTaskFail + void taskFail(DownloadTask task) {} - @Download.onTaskComplete void taskComplete(DownloadTask task) {} + @Download.onTaskComplete + void taskComplete(DownloadTask task) {} - @Download.onNoSupportBreakPoint public void onNoSupportBreakPoint(DownloadTask task) {} + @Download.onNoSupportBreakPoint + public void onNoSupportBreakPoint(DownloadTask task) {} ``` -### 使用广播接收器接收Aria的任务下载状态 -有的时候,你可能希望在广播中接收Aria的下载事件,那么你需要 -* 在[配置文件](#配置文件设置参数)中把` `中的value改为true -* [点击该链接查看注册Aria广播的方式](https://github.com/AriaLyy/Aria/blob/master/BroadCast.md) - ### Aria参数配置 #### 配置文件设置参数 创建`aria_config.xml`文件,将其放在`assets`目录下,添加以下内容 @@ -268,11 +277,18 @@ Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority( ```java Aria.upload(this).load(filePath).cancel(); ``` - + ## 混淆配置 ``` -dontwarn com.arialyy.aria.** -keep class com.arialyy.aria.**{*;} +-keep class **$$DownloadListenerProxy{ *; } +-keep class **$$UploadListenerProxy{ *; } +-keepclasseswithmembernames class * { + @Download.* ; + @Upload.* ; +} + ``` ## 其他 @@ -286,6 +302,8 @@ Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority( ## 开发日志 + + v_3.1.7 修复某些文件下载不了的bug,增加apt注解方法,事件获取更加简单了 + + v_3.1.6 取消任务时onTaskCancel回调两次的bug + v_3.1.5 优化代码结构,增加优先下载任务功能。 + v_3.1.4 修复快速切换,暂停、恢复功能时,概率性出现的重新下载问题,添加onPre()回调,onPre()用于请求地址之前执行界面UI更新操作。 + v_3.1.0 添加Aria配置文件,优化代码 diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index d320a6d3..522cfa0c 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -1,321 +1,56 @@ -# Aria - ![图标](https://github.com/AriaLyy/DownloadUtil/blob/v_2.0/app/src/main/res/mipmap-hdpi/ic_launcher.png)
- Aria项目源于15年工作中遇到的一个文件下载管理的需求,当时被下载折磨的痛不欲生,从那时起便萌生了编写一个简单易用,稳当高效的下载框架,aria经历了1.0到3.0的开发,算是越来越接近当初所制定的目标了。 - - Aria有以下特点: - + 简单、方便 - - 可以在Activity、Service、Fragment、Dialog、popupWindow、Notification等组件中使用 - - 支持任务自动调度,使用者不需要关心任务状态切换的逻辑 - - [通过Aria的事件,能很容易获取当前下载任务的下载状态](#下载状态获取) - - [一句代码加可以获取当前的下载速度](#常用接口) - - [一句代码就可以动态设置最大下载数](#代码中设置参数) - - [通过修改配置文件很容易就能修改下载线程数](#配置文件设置参数) - + 支持https地址下载 - - 在配置文件中很容易就可以设置CA证书的信息 - + 支持300、301、302重定向下载链接下载 - + 支持上传操作 - - - Aria怎样使用? - * [下载](#使用) - * [上传](#上传) - - 如果你觉得Aria对你有帮助,您的star和issues将是对我最大支持.`^_^` - - ## 下载 - [![Download](https://api.bintray.com/packages/arialyy/maven/Aria/images/download.svg)](https://bintray.com/arialyy/maven/Aria/_latestVersion)
- ```java - compile 'com.arialyy.aria:Aria:3.1.5' - ``` - - ## 示例 - ![多任务下载](https://github.com/AriaLyy/DownloadUtil/blob/master/img/download_img.gif) - ![上传](https://github.com/AriaLyy/DownloadUtil/blob/master/img/sing_upload.gif) - - ## 性能 - ![性能展示](https://github.com/AriaLyy/DownloadUtil/blob/master/img/performance.png) - - *** - ## 使用 - 由于Aria涉及到文件和网络的操作,因此需要你在manifest文件中添加以下权限 - ```xml - - - - ``` - - ## 使用Aria进行下载 - * 添加任务(不进行下载),当其他下载任务完成时,将自动下载等待中的任务 - ```java - Aria.download(this) - .load(DOWNLOAD_URL) - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") //文件保存路径 - .add(); - ``` - - * 下载 - - ```java - Aria.download(this) - .load(DOWNLOAD_URL) //读取下载地址 - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") //设置文件保存的完整路径 - .start(); //启动下载 - ``` - * 暂停 - - ```java - Aria.download(this).load(DOWNLOAD_URL).pause(); - ``` - * 恢复下载 - - ```java - Aria.download(this).load(DOWNLOAD_URL).resume(); - ``` - * 取消下载 - - ```java - Aria.download(this).load(DOWNLOAD_URL).cancel(); - ``` - - ### 下载状态获取 - 如果你希望读取下载进度或下载信息,那么你需要创建事件类,并在onResume(Activity、Fragment)或构造函数(Dialog、PopupWindow),将该事件类注册到Aria管理器。 - - * 将对象注册到Aria - - ` Aria.download(this).register();`或`Aria.upload(this).register();` - ```java - @Override protected void onCreate(Bundle savedInstanceState) { - super.onCreate(savedInstanceState); - Aria.download(this).register(); - } - ``` - - * 使用'@Download'或'@Upload'注解你的函数 - **注意:** - - 注解回掉采用Apt的方式实现,所以,你不需要担心这会影响你机器的性能 - - 被注解的方法**不能被private修饰** - - 被注解的方法**只能有一个参数,并且参数类型必须是`DownloadTask`或`UploadTask`** - - 方法名可以为任意字符 - - ```java - @Download.onPre protected void onPre(DownloadTask task) {} - - @Download.onTaskStart void taskStart(DownloadTask task) { - //通过下载地址可以判断任务是否是你指定的任务 - if (task.getKey().equals(DOWNLOAD_URL)) { - } - } - - @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) {} - - ``` - - ### 使用广播接收器接收Aria的任务下载状态 - 有的时候,你可能希望在广播中接收Aria的下载事件,那么你需要 - * 在[配置文件](#配置文件设置参数)中把` `中的value改为true - * [点击该链接查看注册Aria广播的方式](https://github.com/AriaLyy/Aria/blob/master/BroadCast.md) - - ### Aria参数配置 - #### 配置文件设置参数 - 创建`aria_config.xml`文件,将其放在`assets`目录下,添加以下内容 - ```xml - + - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - ``` - - #### 代码中设置参数 - 除了文件方式外修改Aria参数外,同样的,你也可以在代码中动态修改Aria参数
- 通过`Aria.get(this).getDownloadConfig()`或`Aria.get(this).getUploadConfig()`直接获取配置文件,然后修改参数
- 如以下所示: - ```java - // 修改最大下载数,调用完成后,立即生效 - // 如当前下载任务数是4,修改完成后,当前任务数会被Aria自动调度任务数 - Aria.get(this).getDownloadConfig().setMaxTaskNum(3); - ``` - - ### 常用接口 - * 停止所有任务 - - ```java - Aria.download(this).stopAllTask(); - ``` - * 删除所有任务 - - ```java - Aria.download(this).removeAllTask(); - ``` - * 获取当前任务的下载速度 - 速度参数有点特殊,需要[下载事件支持](#下载状态获取) - ``` java - @Override public void onTaskRunning(DownloadTask task) { - //如果你打开了速度单位转换配置,将可以通过以下方法获取带单位的下载速度,如:1 m/s - String convertSpeed = task.getConvertSpeed(); - //如果你有自己的单位格式,可以通过以下方法获取原始byte长度 - long speed = task.getSpeed(); - } - ``` - * 获取下载的文件大小、当前进度百分比 - 同样的,你也可以在DownloadTask对象中获取下载的文件大小 - ``` - @Override public void onTaskRunning(DownloadTask task) { -  //获取文件大小 - long fileSize = task.getFileSize(); - //获取单位转换后的文件大小 - String fileSize1 = task.getConvertFileSize(); - //当前进度百分比 - int percent = task.getPercent(); - } - ``` - * 设置高优先级任务 - 如果你希望优先下载某一个任务,你可以 - ``` java - Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority(); - ``` + + - **tips:为了防止内存泄露的情况,事件类需要使用staic进行修饰** + + - ## 上传 - * 添加任务(只添加,不上传) + + - ```java - Aria.upload(this) - .load(filePath) //文件路径 - .setUploadUrl(uploadUrl) //上传路径 - .setAttachment(fileKey) //服务器读取文件的key - .add(); - ``` + + - * 上传 + + - ```java - Aria.upload(this) - .load(filePath) //文件路径 - .setUploadUrl(uploadUrl) //上传路径 - .setAttachment(fileKey) //服务器读取文件的key - .start(); - ``` - * 取消上传 + + - ```java - Aria.upload(this).load(filePath).cancel(); - ``` + + - ## 混淆配置 - ``` - -dontwarn com.arialyy.aria.** - -keep class com.arialyy.aria.**{*;} - ``` + + - ## 其他 - 有任何问题,可以在[issues](https://github.com/AriaLyy/Aria/issues)给我留言反馈。 + + - *** + + - ## 后续版本开发规划 - * ~~下载任务可以设置优先级~~ - * ~~实现上传队列调度功能~~ + + + - ## 开发日志 - + v_3.1.5 优化代码结构,增加优先下载任务功能。 - + v_3.1.4 修复快速切换,暂停、恢复功能时,概率性出现的重新下载问题,添加onPre()回调,onPre()用于请求地址之前执行界面UI更新操作。 - + v_3.1.0 添加Aria配置文件,优化代码 - + v_3.0.3 修复暂停后删除任务,闪退问题,添加删除记录的api - + v_3.0.2 支持30x重定向链接下载 - + 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 - ------- + + - 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. + \ No newline at end of file diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 51d16fca..144b96c3 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -62,10 +62,10 @@ public class SingleTaskActivity extends BaseActivity { private static final String DOWNLOAD_URL = //"http://kotlinlang.org/docs/kotlin-docs.pdf"; //"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe"; - //"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"; + "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"; //"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815"; - //"http://oqcpqqvuf.bkt.clouddn.com/可用.xlsx"; - "http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk"; + //"http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk"; + //"http://oqcpqqvuf.bkt.clouddn.com/ceshi.txt"; //"http://down8.androidgame-store.com/201706122321/97967927DD4E53D9905ECAA7874C8128/new/game1/19/45319/com.neuralprisma-2.5.2.174-2000174_1494784835.apk?f=web_1"; //不支持断点的链接 //"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; @@ -231,12 +231,6 @@ public class SingleTaskActivity extends BaseActivity { @Download.onTaskComplete void taskComplete(DownloadTask task) { if (task.getKey().equals(DOWNLOAD_URL)) { - //if (CommonUtil.checkMD5("7c1ecf71835d681289bb6c32ff627566", new File(task.getDownloadPath()))){ - //if (CommonUtil.checkMD5("f0c78b33ddc81bb58a712c582b2cd5b0", new File(task.getDownloadPath()))){ - if (CommonUtil.checkMD5("2d3699acfa69e9632262442c46516ad8", new File(task.getDownloadPath()))){ - T.showShort(this, "true"); - L.d(TAG, "true"); - } mUpdateHandler.sendEmptyMessage(DOWNLOAD_COMPLETE); } } diff --git a/build.gradle b/build.gradle index 54224b2e..e24ee924 100644 --- a/build.gradle +++ b/build.gradle @@ -36,8 +36,8 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' -// uploadName = 'AriaPre' - publishVersion = '0.0.6' +// publishVersion = '0.0.6' + publishVersion = '3.1.7' repoName='maven' desc = 'android 下载框架' website = 'https://github.com/AriaLyy/Aria'