From 5f44dffa40b9a23e08e3bd38b433942d0be3b20d Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@QQ.com> Date: Sat, 4 Mar 2017 14:29:44 +0800 Subject: [PATCH 1/7] Update README.md --- README.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/README.md b/README.md index 25ccf3af..bc3b6642 100644 --- a/README.md +++ b/README.md @@ -1,6 +1,6 @@ # Aria ![图标](https://github.com/AriaLyy/DownloadUtil/blob/v_2.0/app/src/main/res/mipmap-hdpi/ic_launcher.png)
-Aria,致力于让下载傻瓜化
+Aria,让下载更简单。
+ Aria有以下特点: - 简单 - 可在Dialog、popupWindow等组件中使用 From 1b143efa07db26e9daa6e09abc07b3484d1d7695 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 7 Mar 2017 14:27:14 +0800 Subject: [PATCH 2/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D404=E9=93=BE=E6=8E=A5?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E5=8D=A1=E9=A1=BF=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/modules.xml | 2 +- .../arialyy/aria/core/task/DownloadUtil.java | 36 ++++++++++--------- README.md | 9 +++-- app/proguard-rules.pro | 17 --------- app/src/main/res/values/strings.xml | 2 +- 5 files changed, 26 insertions(+), 40 deletions(-) delete mode 100644 app/proguard-rules.pro diff --git a/.idea/modules.xml b/.idea/modules.xml index 5f6de159..9f4bd159 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -2,8 +2,8 @@ - + diff --git a/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java index 6f14d883..7bebb4f1 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java @@ -40,18 +40,18 @@ public class DownloadUtil implements IDownloadUtil, Runnable { /** * 线程数 */ - private final int THREAD_NUM; + private final int THREAD_NUM; //下载监听 - private IDownloadListener mListener; - private int mConnectTimeOut = 5000 * 4; //连接超时时间 - private int mReadTimeOut = 5000 * 20; //流读取的超时时间 - private boolean isNewTask = true; + private IDownloadListener mListener; + private int mConnectTimeOut = 5000 * 4; //连接超时时间 + private int mReadTimeOut = 5000 * 20; //流读取的超时时间 + private boolean isNewTask = true; private boolean isSupportBreakpoint = true; - private Context mContext; - private DownloadEntity mDownloadEntity; + private Context mContext; + private DownloadEntity mDownloadEntity; private ExecutorService mFixedThreadPool; - private File mDownloadFile; //下载的文件 - private File mConfigFile;//下载信息配置文件 + private File mDownloadFile; //下载的文件 + private File mConfigFile;//下载信息配置文件 private SparseArray mTask = new SparseArray<>(); private DownloadStateConstance mConstance; @@ -223,8 +223,11 @@ public class DownloadUtil implements IDownloadUtil, Runnable { mListener.supportBreakpoint(false); Log.w(TAG, "该下载链接不支持断点下载"); handleBreakpoint(conn); + } else if (code == HttpURLConnection.HTTP_NOT_FOUND) { + Log.w(TAG, "任务【" + mDownloadEntity.getDownloadUrl() + "】下载失败,错误码:404"); + //mListener.onCancel(); } else { - failDownload("任务【" + mDownloadEntity.getDownloadUrl() + "】下载失败,返回码:" + code); + failDownload("任务【" + mDownloadEntity.getDownloadUrl() + "】下载失败,错误码:" + code); } } catch (IOException e) { failDownload("下载失败【downloadUrl:" @@ -263,7 +266,8 @@ public class DownloadUtil implements IDownloadUtil, Runnable { //RandomAccessFile file = new RandomAccessFile(mDownloadFile.getPath(), "rwd"); ////设置文件长度 //file.setLength(fileLength); - BufferedRandomAccessFile file = new BufferedRandomAccessFile(mDownloadFile.getPath(), "rwd", 8192); + BufferedRandomAccessFile file = + new BufferedRandomAccessFile(mDownloadFile.getPath(), "rwd", 8192); //设置文件长度 file.setLength(fileLength); mListener.onPostPre(fileLength); @@ -362,12 +366,12 @@ public class DownloadUtil implements IDownloadUtil, Runnable { */ final static class ConfigEntity { //文件大小 - long FILE_SIZE; + long FILE_SIZE; String DOWNLOAD_URL; - int THREAD_ID; - long START_LOCATION; - long END_LOCATION; - File TEMP_FILE; + int THREAD_ID; + long START_LOCATION; + long END_LOCATION; + File TEMP_FILE; boolean isSupportBreakpoint = true; String CONFIG_FILE_PATH; } diff --git a/README.md b/README.md index bc3b6642..987517ea 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ 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:2.4.2' +compile 'com.arialyy.aria:Aria:2.4.3' ``` ## 示例 @@ -133,16 +133,15 @@ Aria支持https下载,如果你希望使用自己的ca证书,那么你需要 ``` *** + ## 开发日志 + + 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.3 添加断点支持、修改下载逻辑,让使用更加简单、修复一个内存泄露的bug + v_2.3.1 重命名为Aria,下载流程简化 + v_2.1.1 增加,选择最大下载任务数接口 diff --git a/app/proguard-rules.pro b/app/proguard-rules.pro deleted file mode 100644 index 80105608..00000000 --- a/app/proguard-rules.pro +++ /dev/null @@ -1,17 +0,0 @@ -# Add project specific ProGuard rules here. -# By default, the flags in this file are appended to flags specified -# in D:\sdk/tools/proguard/proguard-android.txt -# You can edit the include path and order by changing the proguardFiles -# directive in build.gradle. -# -# For more details, see -# http://developer.android.com/guide/developing/tools/proguard.html - -# Add any project specific keep options here: - -# If your project uses WebView with JS, uncomment the following -# and specify the fully qualified class name to the JavaScript interface -# class: -#-keepclassmembers class fqcn.of.javascript.interface.for.webview { -# public *; -#} diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index dfa38c80..510df605 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -25,7 +25,7 @@ - http://g37.gdl.netease.com/onmyoji_netease.apk + http://g37.gdl.netease.com/onmyoji_netease_1.apk http://static.gaoshouyou.com/d/eb/f2/dfeba30541f209ab8a50d847fc1661ce.apk http://rs.0.gaoshouyou.com/d/51/46/58514d126c46b8a3f27fc8c7db3b09ec.apk http://rs.0.gaoshouyou.com/d/23/69/07238f952669727878d7a0e180534c8b.apk From 89dfe61d394b06129460a0a4a12f6b7cc42a4fa6 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Mon, 13 Mar 2017 12:36:46 +0800 Subject: [PATCH 3/7] =?UTF-8?q?=E3=80=82=E3=80=82?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- .idea/modules.xml | 2 -- 2 files changed, 1 insertion(+), 3 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d199810..fbb68289 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@
- + diff --git a/.idea/modules.xml b/.idea/modules.xml index 5f6de159..b0a774eb 100644 --- a/.idea/modules.xml +++ b/.idea/modules.xml @@ -3,9 +3,7 @@ - - From cce0f18b970d1c465c25f8b06a1ee48872797081 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Mon, 13 Mar 2017 12:59:29 +0800 Subject: [PATCH 4/7] .. --- .idea/misc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb68289..5d199810 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + From 2255b0fe0cc039ca078cb47e2cb749d31f6aa0ff Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Mon, 13 Mar 2017 15:05:32 +0800 Subject: [PATCH 5/7] .. --- .idea/misc.xml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 5d199810..fbb68289 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + From 4d6d87375ed3249e2c1902f20797059fae4fb766 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 14 Mar 2017 19:41:37 +0800 Subject: [PATCH 6/7] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8D=E6=94=AF?= =?UTF-8?q?=E6=8C=81=E6=96=AD=E7=82=B9=E6=96=87=E4=BB=B6=E5=A4=A7=E5=B0=8F?= =?UTF-8?q?=E6=89=BE=E4=B8=8D=E5=88=B0=E7=9A=84=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .idea/misc.xml | 2 +- Aria/build.gradle | 2 +- .../main/java/com/arialyy/aria/core/task/DownloadUtil.java | 4 +++- app/build.gradle | 2 +- .../com/arialyy/simple/single_task/SingleTaskActivity.java | 3 ++- gradle/wrapper/gradle-wrapper.properties | 4 ++-- 6 files changed, 10 insertions(+), 7 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index fbb68289..5d199810 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -37,7 +37,7 @@ - + diff --git a/Aria/build.gradle b/Aria/build.gradle index b6e5869b..2aa5183d 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.library' android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion '25.0.2' defaultConfig { minSdkVersion 9 diff --git a/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java index 6f14d883..95ff96a9 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java @@ -244,7 +244,8 @@ public class DownloadUtil implements IDownloadUtil, Runnable { //不支持断点只能单线程下载 if (!isSupportBreakpoint) { ConfigEntity entity = new ConfigEntity(); - entity.FILE_SIZE = conn.getContentLength(); + long len = conn.getContentLength();; + entity.FILE_SIZE = len; entity.DOWNLOAD_URL = mDownloadEntity.getDownloadUrl(); entity.TEMP_FILE = mDownloadFile; entity.THREAD_ID = 0; @@ -254,6 +255,7 @@ public class DownloadUtil implements IDownloadUtil, Runnable { entity.isSupportBreakpoint = isSupportBreakpoint; SingleThreadTask task = new SingleThreadTask(mConstance, mListener, entity); mFixedThreadPool.execute(task); + mListener.onPostPre(len); mListener.onStart(0); return; } diff --git a/app/build.gradle b/app/build.gradle index f8fe4165..b863586e 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -2,7 +2,7 @@ apply plugin: 'com.android.application' android { compileSdkVersion 23 - buildToolsVersion "23.0.2" + buildToolsVersion '25.0.2' defaultConfig { applicationId "com.arialyy.simple" diff --git a/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java index 4d0bdff2..b888a99a 100644 --- a/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java @@ -55,7 +55,8 @@ 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/21/e8/61218d78d0e8b79df68dbc18dd484c97.apk"; + //"http://static.gaoshouyou.com/d/21/e8/61218d78d0e8b79df68dbc18dd484c97.apk"; + "http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; @Bind(R.id.progressBar) HorizontalProgressBarWithNumber mPb; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index ab4c9191..6a77bf60 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,6 +1,6 @@ -#Mon Oct 24 17:59:34 CST 2016 +#Tue Mar 14 19:13:43 CST 2017 distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists -distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip +distributionUrl=https\://services.gradle.org/distributions/gradle-3.3-all.zip From 3e79720d431caebae92deba288b0f5384a3122ee Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 14 Mar 2017 20:09:22 +0800 Subject: [PATCH 7/7] bug fix --- README.md | 2 +- .../single_task/SingleTaskActivity.java | 61 ------------------- 2 files changed, 1 insertion(+), 62 deletions(-) diff --git a/README.md b/README.md index 25ccf3af..d6c50696 100644 --- a/README.md +++ b/README.md @@ -17,7 +17,7 @@ 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:2.4.2' +compile 'com.arialyy.aria:Aria:2.4.4' ``` ## 示例 diff --git a/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java index b888a99a..9de01d3c 100644 --- a/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java @@ -201,67 +201,6 @@ public class SingleTaskActivity extends BaseActivity { .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") .setDownloadName("test.apk") .start(); - //DownloadEntity entity = new DownloadEntity(); - //entity.setDownloadUrl(DOWNLOAD_URL); - //entity.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk"); - //entity.setFileName("test.apk"); - //DownloadUtil util = new DownloadUtil(this, entity, new IDownloadListener() { - // long fileSize = 1; - // @Override public void supportBreakpoint(boolean support) { - // - // } - // - // @Override public void onCancel() { - // - // } - // - // @Override public void onFail() { - // - // } - // - // @Override public void onPre() { - // - // } - // - // @Override public void onPostPre(long fileSize) { - // this.fileSize = fileSize; - // } - // - // @Override public void onProgress(long currentLocation) { - // long current = currentLocation; - // long len = fileSize; - // if (len == 0) { - // mPb.setProgress(0); - // } else { - // mPb.setProgress((int) ((current * 100) / len)); - // } - // } - // - // @Override public void onChildComplete(long finishLocation) { - // - // } - // - // @Override public void onStart(long startLocation) { - // - // } - // - // @Override public void onChildResume(long resumeLocation) { - // - // } - // - // @Override public void onResume(long resumeLocation) { - // - // } - // - // @Override public void onStop(long stopLocation) { - // - // } - // - // @Override public void onComplete() { - // - // } - //}); - //util.startDownload(); } private void stop() {