diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java index fc10fb5a..ddc81b6b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java @@ -16,6 +16,7 @@ package com.arialyy.aria.core.command.normal; +import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity; @@ -43,10 +44,25 @@ public class CancelAllCmd extends AbsNormalCmd { @Override public void executeCmd() { removeAll(); - if (mTaskEntity instanceof DownloadTaskEntity) { + if (mTaskEntity instanceof DownloadTaskEntity + || mTaskEntity instanceof DownloadGroupTaskEntity) { handleDownloadRemove(); + handleDownloadRemove(); + handleDownloadGroupRemove(); } else if (mTaskEntity instanceof UploadTaskEntity) { handleUploadRemove(); + handleUploadRemove(); + } + } + + /** + * 处理下载任务组的删除操作 + */ + private void handleDownloadGroupRemove() { + List allEntity = DbEntity.findAllData(DownloadGroupTaskEntity.class); + if (allEntity == null || allEntity.size() == 0) return; + for (DownloadGroupTaskEntity entity : allEntity) { + CommonUtil.delDownloadGroupTaskConfig(removeFile, entity); } } 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 fa0cc8b9..f862764c 100644 --- a/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java @@ -216,6 +216,39 @@ public class CommonUtil { return md5; } + /** + * 删除下载任务组的配置 + * + * @param removeFile {@code true} 不仅删除任务数据库记录,还会删除已经删除完成的文件 + * {@code false}如果任务已经完成,只删除任务数据库记录 + */ + public static void delDownloadGroupTaskConfig(boolean removeFile, + DownloadGroupTaskEntity tEntity) { + DownloadGroupEntity entity = tEntity.getEntity(); + List tasks = + DbEntity.findDatas(DownloadTaskEntity.class, "groupName=?", tEntity.key); + if (tasks != null && !tasks.isEmpty()) { + for (DownloadTaskEntity taskEntity : tasks) { + delDownloadTaskConfig(removeFile, taskEntity); + } + } + + File dir = new File(tEntity.getEntity().getDirPath()); + if (removeFile) { + if (dir.exists()) { + dir.delete(); + } + } else { + if (!tEntity.getEntity().isComplete()) { + dir.delete(); + } + } + if (entity != null) { + entity.deleteData(); + } + tEntity.deleteData(); + } + /** * 删除上传任务的配置 * @@ -246,6 +279,7 @@ public class CommonUtil { */ public static void delDownloadTaskConfig(boolean removeFile, DownloadTaskEntity tEntity) { DownloadEntity dEntity = tEntity.getEntity(); + if (dEntity == null) return; File file = new File(dEntity.getDownloadPath()); if (removeFile) { if (file.exists()) { diff --git a/AriaCompiler/src/main/java/com/arialyy/compiler/AriaProcessor.java b/AriaCompiler/src/main/java/com/arialyy/compiler/AriaProcessor.java index 72c4b985..9bdef7d9 100644 --- a/AriaCompiler/src/main/java/com/arialyy/compiler/AriaProcessor.java +++ b/AriaCompiler/src/main/java/com/arialyy/compiler/AriaProcessor.java @@ -16,6 +16,7 @@ package com.arialyy.compiler; import com.arialyy.annotations.Download; +import com.arialyy.annotations.DownloadGroup; import com.arialyy.annotations.Upload; import com.google.auto.service.AutoService; import java.util.LinkedHashSet; @@ -54,16 +55,15 @@ import javax.lang.model.element.TypeElement; annotataions.add(Download.onTaskStart.class.getCanonicalName()); annotataions.add(Download.onTaskStop.class.getCanonicalName()); //下载任务的注解 - annotataions.add(Download.onPre.class.getCanonicalName()); - annotataions.add(Download.onNoSupportBreakPoint.class.getCanonicalName()); - annotataions.add(Download.onTaskCancel.class.getCanonicalName()); - annotataions.add(Download.onTaskComplete.class.getCanonicalName()); - annotataions.add(Download.onTaskFail.class.getCanonicalName()); - annotataions.add(Download.onTaskPre.class.getCanonicalName()); - annotataions.add(Download.onTaskResume.class.getCanonicalName()); - annotataions.add(Download.onTaskRunning.class.getCanonicalName()); - annotataions.add(Download.onTaskStart.class.getCanonicalName()); - annotataions.add(Download.onTaskStop.class.getCanonicalName()); + annotataions.add(DownloadGroup.onPre.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskCancel.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskComplete.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskFail.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskPre.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskResume.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskRunning.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskStart.class.getCanonicalName()); + annotataions.add(DownloadGroup.onTaskStop.class.getCanonicalName()); //上传任务的注解 annotataions.add(Upload.onPre.class.getCanonicalName()); annotataions.add(Upload.onNoSupportBreakPoint.class.getCanonicalName()); diff --git a/DEV_LOG.md b/DEV_LOG.md index 1871693c..d3b7a3f2 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,6 @@ ## 开发日志 + + v_3.2.26 修复任务组有时注解不起作用的问题 + + v_3.2.25 修复删除任务组文件,记录无法删除的问题 + v_3.2.17 修复一个版本兼容性问题,线程中使用Aria出错问题 + v_3.2.15 修复大型文件分段下载失败的问题,修复中文URL乱码问题 + v_3.2.14 修复恢复所有任务的api接口,不能恢复下载组任务的问题 diff --git a/build.gradle b/build.gradle index cfa58547..172a0867 100644 --- a/build.gradle +++ b/build.gradle @@ -37,7 +37,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.2.25' + publishVersion = '3.2.26' repoName='maven' desc = 'android 下载框架' website = 'https://github.com/AriaLyy/Aria' diff --git a/gradle.properties b/gradle.properties index 299cc485..d6407bdb 100644 --- a/gradle.properties +++ b/gradle.properties @@ -13,3 +13,7 @@ # http://www.gradle.org/docs/current/userguide/multi_project_builds.html#sec:decoupled_projects # org.gradle.parallel=true #Wed Dec 07 20:19:22 CST 2016 +# gradle proxy https://chaosleong.github.io/2017/02/10/Configuring-Gradle-Proxy/ +#systemProp.socksProxyHost=127.0.0.1 +#systemProp.socksProxyPort=58224 +#systemprop.socksProxyVersion=5