From 755e333d8bc6a47896b44b3b2ba04bbf47fb8941 Mon Sep 17 00:00:00 2001
From: AriaLyy <511455842@qq.com>
Date: Wed, 17 Jan 2018 21:15:53 +0800
Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E8=BF=9B=E5=BA=A6=E6=9B=B4?=
=?UTF-8?q?=E6=96=B0=E9=97=B4=E9=9A=94api=EF=BC=8C=E5=9C=A8`aria=5Fconfig.?=
=?UTF-8?q?xml`=E9=85=8D=E7=BD=AE``?=
=?UTF-8?q?=E6=88=96=E5=9C=A8=E4=BB=A3=E7=A0=81=E4=B8=AD=E8=B0=83=E7=94=A8?=
=?UTF-8?q?`AriaManager.getInstance(AriaManager.APP).getDownloadConfig().s?=
=?UTF-8?q?etUpdateInterval(3000)`=E4=BE=BF=E5=8F=AF=E4=BB=A5=E6=94=B9?=
=?UTF-8?q?=E5=8F=98=E8=BF=9B=E5=BA=A6=E5=88=B7=E6=96=B0=E9=97=B4=E9=9A=94?=
=?UTF-8?q?.=20https://github.com/AriaLyy/Aria/issues/190?=
MIME-Version: 1.0
Content-Type: text/plain; charset=UTF-8
Content-Transfer-Encoding: 8bit
---
.../com/arialyy/aria/core/ConfigHelper.java | 19 ++++++++++++
.../arialyy/aria/core/common/AbsFileer.java | 31 ++++++++++++++-----
.../aria/core/download/BaseDListener.java | 5 +++
.../download/downloader/AbsGroupUtil.java | 5 ++-
.../core/download/downloader/Downloader.java | 3 ++
.../arialyy/aria/core/inf/AbsTaskEntity.java | 9 +++---
.../aria/core/upload/BaseUListener.java | 5 +++
.../aria/core/upload/uploader/Uploader.java | 3 ++
DEV_LOG.md | 3 ++
app/src/main/assets/aria_config.xml | 6 ++++
.../simple/download/SingleTaskActivity.java | 1 +
.../com/arialyy/aria/core/Configuration.java | 27 +++++++++++++++-
12 files changed, 103 insertions(+), 14 deletions(-)
diff --git a/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java b/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
index 586ceb4e..1eb12427 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
@@ -86,8 +86,27 @@ class ConfigHelper extends DefaultHandler {
case "queueMod":
loadQueueMod(value);
break;
+ case "updateInterval":
+ loadUpdateInterval(value);
+ break;
+ }
+ }
+ }
+
+ private void loadUpdateInterval(String value) {
+ long temp = 1000;
+ if (!TextUtils.isEmpty(value)) {
+ temp = Long.parseLong(value);
+ if (temp <= 0) {
+ temp = 1000;
}
}
+ if (isDownloadConfig) {
+ mDownloadConfig.updateInterval = temp;
+ }
+ if (isUploadConfig) {
+ mUploadConfig.updateInterval = temp;
+ }
}
private void loadQueueMod(String value) {
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 78c0fe71..01d2fb9f 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
@@ -63,6 +63,7 @@ public abstract class AbsFileer 0) {
@@ -390,7 +405,7 @@ public abstract class AbsFileer config = new SubThreadConfig<>();
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java
index 7c68b96d..ce686b2d 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java
@@ -41,6 +41,7 @@ class BaseDListener(outHandler);
@@ -51,6 +52,7 @@ class BaseDListener {
Downloader(IDownloadListener listener, DownloadTaskEntity taskEntity) {
super(listener, taskEntity);
+ setUpdateInterval(
+ AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getUpdateInterval());
}
@Override protected void checkTask() {
diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java
index be5e1bc8..b63fad34 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java
@@ -36,10 +36,6 @@ public abstract class AbsTaskEntity extends DbEntity {
* HTTP任务组下载
*/
public static final int DG_HTTP = 0x12;
- /**
- * HTTP单文件上传
- */
- public static final int U_HTTP = 0xA1;
/**
* FTP单文件下载
@@ -49,6 +45,11 @@ public abstract class AbsTaskEntity extends DbEntity {
* FTP文件夹下载,为避免登录过多,子任务由单线程进行处理
*/
public static final int D_FTP_DIR = 0x14;
+
+ /**
+ * HTTP单文件上传
+ */
+ public static final int U_HTTP = 0xA1;
/**
* FTP单文件上传
*/
diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java
index a0591d78..48aa5b73 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java
@@ -41,6 +41,7 @@ class BaseUListener(outHandler);
@@ -51,6 +52,7 @@ class BaseUListener {
Uploader(IUploadListener listener, UploadTaskEntity taskEntity) {
super(listener, taskEntity);
mTempFile = new File(mEntity.getFilePath());
+ setUpdateInterval(
+ AriaManager.getInstance(AriaManager.APP).getUploadConfig().getUpdateInterval());
}
/**
diff --git a/DEV_LOG.md b/DEV_LOG.md
index 69d361d2..c429a9e6 100644
--- a/DEV_LOG.md
+++ b/DEV_LOG.md
@@ -1,4 +1,7 @@
## 开发日志
+ + v_3.3.11
+ - 添加进度更新间隔api,在`aria_config.xml`配置``或在代码中调用
+ `AriaManager.getInstance(AriaManager.APP).getDownloadConfig().setUpdateInterval(3000)`便可以改变进度刷新间隔
+ v_3.3.10
- 修复地址切换导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/181
- 添加重置状态的api,当下载信息不改变,只是替换了服务器的对应的文件,可用`Aria.download(this).load(url).resetState()`重置下载状态 https://github.com/AriaLyy/Aria/issues/182
diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml
index 92324c01..ce92a575 100644
--- a/app/src/main/assets/aria_config.xml
+++ b/app/src/main/assets/aria_config.xml
@@ -34,6 +34,9 @@
+
+
+
@@ -54,6 +57,9 @@
+
+
+
\ 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 afa60d39..4ae8dae5 100644
--- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
+++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
@@ -157,6 +157,7 @@ public class SingleTaskActivity extends BaseActivity {
mStart.setText("开始");
setBtState(true);
getBinding().setSpeed("");
+ Log.d(TAG, "cancel");
}
@Download.onTaskFail void taskFail(DownloadTask task) {
diff --git a/aria/src/main/java/com/arialyy/aria/core/Configuration.java b/aria/src/main/java/com/arialyy/aria/core/Configuration.java
index 6ae2b732..1b4b060e 100644
--- a/aria/src/main/java/com/arialyy/aria/core/Configuration.java
+++ b/aria/src/main/java/com/arialyy/aria/core/Configuration.java
@@ -19,6 +19,7 @@ import android.text.TextUtils;
import com.arialyy.aria.core.common.QueueMod;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue;
+import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import java.io.File;
import java.lang.reflect.Field;
@@ -39,6 +40,11 @@ class Configuration {
* 通用配置
*/
public static class BaseConfig {
+ /**
+ * 进度刷新间隔,默认1秒
+ */
+ long updateInterval = 1000;
+
/**
* 旧任务数
*/
@@ -73,6 +79,25 @@ class Configuration {
*/
String queueMod = "wait";
+ public long getUpdateInterval() {
+ return updateInterval;
+ }
+
+ /**
+ * 设置进度更新间隔,该设置对正在运行的任务无效,默认为1000毫秒
+ *
+ * @param updateInterval 不能小于0
+ */
+ public BaseConfig setUpdateInterval(long updateInterval) {
+ if (updateInterval <= 0) {
+ ALog.w("Configuration", "进度更新间隔不能小于0");
+ return this;
+ }
+ this.updateInterval = updateInterval;
+ saveKey("updateInterval", String.valueOf(updateInterval));
+ return this;
+ }
+
public String getQueueMod() {
return queueMod;
}
@@ -272,7 +297,7 @@ class Configuration {
return this;
}
- public void setThreadNum(int threadNum){
+ public void setThreadNum(int threadNum) {
this.threadNum = threadNum;
saveKey("threadNum", String.valueOf(threadNum));
}