From e68da0719c9d96d3b16f216ee5dcabc087b85be7 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Mon, 9 Oct 2017 21:42:58 +0800 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E5=90=8C=E4=B8=80?= =?UTF-8?q?=E6=97=B6=E9=97=B4=E8=B0=83=E7=94=A8=E5=A4=9A=E4=B8=AAstart?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E4=BB=BB=E5=8A=A1=E9=87=8D=E5=A4=8D?= =?UTF-8?q?=E9=97=AE=E9=A2=98=20https://github.com/AriaLyy/Aria/issues/130?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Aria/build.gradle | 3 +- .../aria/core/command/normal/StartCmd.java | 2 +- .../arialyy/aria/core/common/AbsFileer.java | 5 +- .../aria/core/queue/pool/BaseExecutePool.java | 63 +++++++++++-------- AriaAnnotations/build.gradle | 2 +- AriaCompiler/build.gradle | 2 +- AriaFtpPlug/bintray-release.gradle | 2 +- AriaFtpPlug/build.gradle | 2 +- .../simple/download/SingleTaskActivity.java | 38 ++++++++--- app/src/main/res/values/strings.xml | 9 +++ build.gradle | 4 +- gradle.properties | 6 +- 12 files changed, 90 insertions(+), 48 deletions(-) diff --git a/Aria/build.gradle b/Aria/build.gradle index 7f47d267..cca5c941 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -24,7 +24,8 @@ dependencies { compile 'com.android.support:appcompat-v7:23.1.1' compile project(':AriaAnnotations') compile 'com.arialyy.aria:aria-ftp-plug:1.0.1' + // compile project(':AriaFtpPlug') } -apply from: 'bintray-release.gradle' +//apply from: 'bintray-release.gradle' diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java index 5a3a0190..7c502251 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java @@ -21,8 +21,8 @@ import android.util.Log; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.common.QueueMod; import com.arialyy.aria.core.inf.AbsTask; -import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.AbsTaskEntity; +import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.util.NetUtils; /** diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java index ed7a56b5..8a2032b8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java @@ -85,6 +85,9 @@ public abstract class AbsFileer implements IPool { * @param maxNum 下载数 */ public void setMaxNum(int maxNum) { - try { - ArrayBlockingQueue temp = new ArrayBlockingQueue<>(maxNum); - TASK task; - while ((task = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS)) != null) { - temp.offer(task); + synchronized (AriaManager.LOCK) { + try { + ArrayBlockingQueue temp = new ArrayBlockingQueue<>(maxNum); + TASK task; + while ((task = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS)) != null) { + temp.offer(task); + } + mExecuteQueue = temp; + mSize = maxNum; + } catch (InterruptedException e) { + e.printStackTrace(); } - mExecuteQueue = temp; - mSize = maxNum; - } catch (InterruptedException e) { - e.printStackTrace(); } } @@ -107,33 +109,37 @@ public class BaseExecutePool implements IPool { * @param newTask 新任务 */ boolean putNewTask(TASK newTask) { - String url = newTask.getKey(); - boolean s = mExecuteQueue.offer(newTask); - Log.w(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】")); - if (s) { - mExecuteMap.put(CommonUtil.keyToHashKey(url), newTask); + synchronized (AriaManager.LOCK) { + String url = newTask.getKey(); + boolean s = mExecuteQueue.offer(newTask); + Log.w(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】")); + if (s) { + mExecuteMap.put(CommonUtil.keyToHashKey(url), newTask); + } + return s; } - return s; } /** * 队列满时,将移除下载队列中的第一个任务 */ boolean pollFirstTask() { - try { - TASK oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS); - if (oldTask == null) { - Log.e(TAG, "移除任务失败"); + synchronized (AriaManager.LOCK) { + try { + TASK oldTask = mExecuteQueue.poll(TIME_OUT, TimeUnit.MICROSECONDS); + if (oldTask == null) { + Log.e(TAG, "移除任务失败"); + return false; + } + oldTask.stop(); + String key = CommonUtil.keyToHashKey(oldTask.getKey()); + mExecuteMap.remove(key); + } catch (InterruptedException e) { + e.printStackTrace(); return false; } - oldTask.stop(); - String key = CommonUtil.keyToHashKey(oldTask.getKey()); - mExecuteMap.remove(key); - } catch (InterruptedException e) { - e.printStackTrace(); - return false; + return true; } - return true; } @Override public TASK pollTask() { @@ -183,7 +189,10 @@ public class BaseExecutePool implements IPool { } String convertKey = CommonUtil.keyToHashKey(key); TASK task = mExecuteMap.get(convertKey); - if (mExecuteQueue.remove(task)) { + final int oldQueueSize = mExecuteQueue.size(); + boolean isSuccess = mExecuteQueue.remove(task); + final int newQueueSize = mExecuteQueue.size(); + if (isSuccess && newQueueSize != oldQueueSize) { mExecuteMap.remove(convertKey); return true; } diff --git a/AriaAnnotations/build.gradle b/AriaAnnotations/build.gradle index a9f2139b..0b581ad5 100644 --- a/AriaAnnotations/build.gradle +++ b/AriaAnnotations/build.gradle @@ -11,4 +11,4 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } -apply from: 'bintray-release.gradle' \ No newline at end of file +//apply from: 'bintray-release.gradle' \ No newline at end of file diff --git a/AriaCompiler/build.gradle b/AriaCompiler/build.gradle index a76e8659..38de01a1 100644 --- a/AriaCompiler/build.gradle +++ b/AriaCompiler/build.gradle @@ -14,4 +14,4 @@ dependencies { compile project(':AriaAnnotations') } -apply from: 'bintray-release.gradle' \ No newline at end of file +//apply from: 'bintray-release.gradle' \ No newline at end of file diff --git a/AriaFtpPlug/bintray-release.gradle b/AriaFtpPlug/bintray-release.gradle index 9a0dd3e7..df278a4a 100644 --- a/AriaFtpPlug/bintray-release.gradle +++ b/AriaFtpPlug/bintray-release.gradle @@ -3,7 +3,7 @@ publish { artifactId = 'aria-ftp-plug' userOrg = rootProject.userOrg groupId = rootProject.groupId - uploadName = 'AriaFtpPlug' + uploadName = 'FtpPlug' publishVersion = rootProject.publishVersion description = rootProject.description website = rootProject.website diff --git a/AriaFtpPlug/build.gradle b/AriaFtpPlug/build.gradle index 0b581ad5..a9f2139b 100644 --- a/AriaFtpPlug/build.gradle +++ b/AriaFtpPlug/build.gradle @@ -11,4 +11,4 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } -//apply from: 'bintray-release.gradle' \ No newline at end of file +apply from: 'bintray-release.gradle' \ 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 e1c8de2e..f1588ffc 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -46,14 +46,14 @@ 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://sitcac.daxincf.cn/wp-content/uploads/swift_vido/01/element.mp4_1"; //"http://120.25.196.56:8000/filereq?id=15692406294&ipncid=105635&client=android&filename=20170819185541.avi"; //"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt"; //"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815"; //"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://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-"; //"http://172.18.104.50:8080/download/_302turn"; @@ -72,8 +72,8 @@ public class SingleTaskActivity extends BaseActivity { * 设置start 和 stop 按钮状态 */ private void setBtState(boolean state) { - mStart.setEnabled(state); - mStop.setEnabled(!state); + //mStart.setEnabled(state); + //mStop.setEnabled(!state); } @Override public boolean onCreateOptionsMenu(Menu menu) { @@ -195,11 +195,23 @@ public class SingleTaskActivity extends BaseActivity { public void onClick(View view) { switch (view.getId()) { case R.id.start: - Aria.download(SingleTaskActivity.this) - .load(DOWNLOAD_URL, true) - .addHeader("groupName", "value") - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") - .start(); + startD(); + startD(); + startD(); + startD(); + startD(); + startD(); + //new Thread(new Runnable() { + // @Override public void run() { + // startD(); + // } + //}).start(); + // + //new Thread(new Runnable() { + // @Override public void run() { + // startD(); + // } + //}).start(); break; case R.id.stop: Aria.download(this).load(DOWNLOAD_URL).stop(); @@ -209,4 +221,12 @@ public class SingleTaskActivity extends BaseActivity { break; } } + + private void startD(){ + Aria.download(SingleTaskActivity.this) + .load(DOWNLOAD_URL, true) + .addHeader("groupName", "value") + .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") + .start(); + } } \ No newline at end of file diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index 6ec4cea8..e14beb6d 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -24,6 +24,10 @@ 鲜果消消乐 航海奇迹 + test_1 + test_2 + test_3 + https://g37.gdl.netease.com/onmyoji_netease_10_1.0.20.apk @@ -32,6 +36,11 @@ http://rs.0.gaoshouyou.com/d/23/69/07238f952669727878d7a0e180534c8b.apk http://rs.0.gaoshouyou.com/d/e7/3d/73e716d3353de5b479fcf7da8d36a5ef.apk http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk + + http://dby-resource-android.duobeiyun.com/jz22a8508b4265466b9fb4bb29082eaa2d.zip + http://dby-resource-android.duobeiyun.com/jz05fa8faf068145fcb25c93c8091297ad.zip + http://dby-resource-android.duobeiyun.com/jz684e1b4c2f6b4576979e60fd95edebad.zip + diff --git a/build.gradle b/build.gradle index b8c4e13f..b11b48a3 100644 --- a/build.gradle +++ b/build.gradle @@ -37,8 +37,8 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.3.3_dev' -// publishVersion = '1.0.1' //FTP插件 +// publishVersion = '3.3.3_dev_3' + publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架' website = 'https://github.com/AriaLyy/Aria' diff --git a/gradle.properties b/gradle.properties index 56fde3f4..36ed63a9 100644 --- a/gradle.properties +++ b/gradle.properties @@ -16,6 +16,6 @@ #org.gradle.daemon=true #org.gradle.jvmargs=-agentlib:jdwp=transport=dt_socket,server=y,suspend=n,address=5005 # gradle proxy https://chaosleong.github.io/2017/02/10/Configuring-Gradle-Proxy/ -systemProp.socksProxyHost=127.0.0.1 -systemProp.socksProxyPort=51110 -systemprop.socksProxyVersion=5 \ No newline at end of file +#systemProp.socksProxyHost=127.0.0.1 +#systemProp.socksProxyPort=60777 +#systemprop.socksProxyVersion=5 \ No newline at end of file From ca3cebcfc0eea3ad05edb61d9324008a3c64805e Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 10 Oct 2017 09:48:56 +0800 Subject: [PATCH 2/2] 3.3.3 --- Aria/build.gradle | 4 ++-- AriaAnnotations/build.gradle | 2 +- AriaCompiler/build.gradle | 2 +- AriaFtpPlug/build.gradle | 2 +- DEV_LOG.md | 1 + README.md | 4 ++-- build.gradle | 4 ++-- 7 files changed, 10 insertions(+), 9 deletions(-) diff --git a/Aria/build.gradle b/Aria/build.gradle index cca5c941..587b9ad5 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -23,9 +23,9 @@ dependencies { testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' compile project(':AriaAnnotations') - compile 'com.arialyy.aria:aria-ftp-plug:1.0.1' + compile 'com.arialyy.aria:aria-ftp-plug:1.0.3' // compile project(':AriaFtpPlug') } -//apply from: 'bintray-release.gradle' +apply from: 'bintray-release.gradle' diff --git a/AriaAnnotations/build.gradle b/AriaAnnotations/build.gradle index 0b581ad5..a9f2139b 100644 --- a/AriaAnnotations/build.gradle +++ b/AriaAnnotations/build.gradle @@ -11,4 +11,4 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } -//apply from: 'bintray-release.gradle' \ No newline at end of file +apply from: 'bintray-release.gradle' \ No newline at end of file diff --git a/AriaCompiler/build.gradle b/AriaCompiler/build.gradle index 38de01a1..a76e8659 100644 --- a/AriaCompiler/build.gradle +++ b/AriaCompiler/build.gradle @@ -14,4 +14,4 @@ dependencies { compile project(':AriaAnnotations') } -//apply from: 'bintray-release.gradle' \ No newline at end of file +apply from: 'bintray-release.gradle' \ No newline at end of file diff --git a/AriaFtpPlug/build.gradle b/AriaFtpPlug/build.gradle index a9f2139b..0b581ad5 100644 --- a/AriaFtpPlug/build.gradle +++ b/AriaFtpPlug/build.gradle @@ -11,4 +11,4 @@ dependencies { compile fileTree(dir: 'libs', include: ['*.jar']) } -apply from: 'bintray-release.gradle' \ No newline at end of file +//apply from: 'bintray-release.gradle' \ No newline at end of file diff --git a/DEV_LOG.md b/DEV_LOG.md index ca6582e3..3db7b4e7 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,5 @@ ## 开发日志 + + v_3.3.3 修复进度条错乱的问题,修复同一时间多次调用start导致重复下载的问题 + v_3.3.2 新加reTry(),修复上一个版本不会回调失败事件的问题;增加running状态下5秒钟保存一次数据库的功能;修复FTP断点上传文件不完整的问题 + v_3.3.1 增加网络事件,网络未连接,将不会重试下载,修复删除未开始任务,状态回调错误 + v_3.3.0 增加任务组子任务暂停和开始控制功能、修复5.0系统以上数据库多生成两个字段的bug、去掉addSchedulerListener事件 diff --git a/README.md b/README.md index 9c3d977d..ece79ca5 100644 --- a/README.md +++ b/README.md @@ -29,8 +29,8 @@ Aria有以下特点: [![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.22' -annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.22' +compile 'com.arialyy.aria:aria-core:3.3.3' +annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.3' ``` *** diff --git a/build.gradle b/build.gradle index b11b48a3..0a49f17d 100644 --- a/build.gradle +++ b/build.gradle @@ -37,8 +37,8 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' -// publishVersion = '3.3.3_dev_3' - publishVersion = '1.0.3' //FTP插件 + publishVersion = '3.3.3' +// publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架' website = 'https://github.com/AriaLyy/Aria'