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