From 846235a8263f23dcccd91c23060ba3d5c2a5d823 Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Tue, 26 Nov 2019 19:28:01 +0800 Subject: [PATCH] fix bug https://github.com/AriaLyy/Aria/issues/533 fix bug https://github.com/AriaLyy/Aria/issues/535 --- .../aria/core/command/ResumeAllCmd.java | 25 ++----------------- .../aria/core/command/ResumeThread.java | 22 ++++++++-------- .../arialyy/aria/core/command/StartCmd.java | 3 ++- README.md | 2 +- .../core/download/SingleTaskActivity.java | 2 +- build.gradle | 2 +- 6 files changed, 19 insertions(+), 37 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java index 667598ac..71b07041 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java @@ -16,29 +16,10 @@ package com.arialyy.aria.core.command; import com.arialyy.aria.core.AriaManager; -import com.arialyy.aria.core.common.AbsEntity; -import com.arialyy.aria.core.download.DGTaskWrapper; -import com.arialyy.aria.core.download.DTaskWrapper; -import com.arialyy.aria.core.download.DownloadEntity; -import com.arialyy.aria.core.download.DownloadGroupEntity; import com.arialyy.aria.core.inf.IEntity; -import com.arialyy.aria.core.inf.IOptionConstant; -import com.arialyy.aria.core.manager.TaskWrapperManager; -import com.arialyy.aria.core.queue.DGroupTaskQueue; -import com.arialyy.aria.core.queue.DTaskQueue; -import com.arialyy.aria.core.queue.UTaskQueue; -import com.arialyy.aria.core.task.AbsTask; -import com.arialyy.aria.core.upload.UTaskWrapper; -import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.wrapper.AbsTaskWrapper; -import com.arialyy.aria.core.wrapper.ITaskWrapper; -import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.util.ALog; -import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.NetUtils; -import java.util.ArrayList; -import java.util.List; -import java.util.concurrent.Executors; /** * Created by AriaL on 2017/6/13. @@ -50,7 +31,6 @@ import java.util.concurrent.Executors; */ final class ResumeAllCmd extends AbsNormalCmd { - ResumeAllCmd(T entity, int taskType) { super(entity, taskType); } @@ -60,8 +40,7 @@ final class ResumeAllCmd extends AbsNormalCmd { ALog.w(TAG, "恢复任务失败,网络未连接"); return; } - new Thread(new ResumeThread(isDownloadCmd, IEntity.STATE_COMPLETE)).start(); + new Thread(new ResumeThread(isDownloadCmd, + String.format("state!=%s", IEntity.STATE_COMPLETE))).start(); } - - } diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/ResumeThread.java b/Aria/src/main/java/com/arialyy/aria/core/command/ResumeThread.java index 64efead9..32f442d6 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/ResumeThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/ResumeThread.java @@ -47,11 +47,11 @@ public class ResumeThread implements Runnable { private String TAG = CommonUtil.getClassName(getClass()); private List mWaitList = new ArrayList<>(); private boolean isDownloadCmd; - private int excludeState; + private String sqlCondition; - ResumeThread(boolean isDownload, int excludeState) { + ResumeThread(boolean isDownload, String sqlCondition) { this.isDownloadCmd = isDownload; - this.excludeState = excludeState; + this.sqlCondition = sqlCondition; } /** @@ -63,8 +63,8 @@ public class ResumeThread implements Runnable { if (type == 1) { List entities = DbEntity.findDatas(DownloadEntity.class, - "isGroupChild=? AND state!=? ORDER BY stopTime DESC", "false", - String.valueOf(excludeState)); + String.format("NOT(isGroupChild) AND NOT(isComplete) AND %s ORDER BY stopTime DESC", + sqlCondition)); if (entities != null && !entities.isEmpty()) { for (DownloadEntity entity : entities) { addResumeEntity(TaskWrapperManager.getInstance() @@ -73,8 +73,9 @@ public class ResumeThread implements Runnable { } } else if (type == 2) { List entities = - DbEntity.findDatas(DownloadGroupEntity.class, "state!=? ORDER BY stopTime DESC", - String.valueOf(excludeState)); + DbEntity.findDatas(DownloadGroupEntity.class, + String.format("NOT(isComplete) AND %s ORDER BY stopTime DESC", + sqlCondition)); if (entities != null && !entities.isEmpty()) { for (DownloadGroupEntity entity : entities) { addResumeEntity( @@ -84,8 +85,9 @@ public class ResumeThread implements Runnable { } } else if (type == 3) { List entities = - DbEntity.findDatas(UploadEntity.class, "state!=? ORDER BY stopTime DESC", - String.valueOf(excludeState)); + DbEntity.findDatas(UploadEntity.class, + String.format("NOT(isComplete) AND %s ORDER BY stopTime DESC", + sqlCondition)); if (entities != null && !entities.isEmpty()) { for (UploadEntity entity : entities) { addResumeEntity(TaskWrapperManager.getInstance() @@ -125,7 +127,7 @@ public class ResumeThread implements Runnable { queue = DGroupTaskQueue.getInstance(); } - if (queue == null){ + if (queue == null) { ALog.e(TAG, "任务类型错误"); continue; } diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java index 38b1367a..11983e11 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java @@ -91,6 +91,7 @@ final class StartCmd extends AbsNormalCmd { * 当缓冲队列为null时,查找数据库中所有等待中的任务 */ private void findAllWaitTask() { - new Thread(new ResumeThread(isDownloadCmd, IEntity.STATE_WAIT)).start(); + new Thread( + new ResumeThread(isDownloadCmd, String.format("state=%s", IEntity.STATE_WAIT))).start(); } } \ No newline at end of file diff --git a/README.md b/README.md index 9625c201..9f0fde97 100644 --- a/README.md +++ b/README.md @@ -137,7 +137,7 @@ protected void onCreate(Bundle savedInstanceState) { ### 版本日志 - + v_v_3.7.8-pre-1 (2019/11/20) + + v_3.7.8-pre-1 (2019/11/20) - fix bug https://github.com/AriaLyy/Aria/issues/526 [更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md) diff --git a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java index 48a9f3cb..e0a02e24 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java @@ -277,7 +277,7 @@ public class SingleTaskActivity extends BaseActivity { Aria.download(this).load(mTaskId).stop(); } else { Aria.download(this).load(mTaskId) - //.updateUrl("http://sdkdown.muzhiwan.com/openfile/2019/07/11/com.netease.syfz.mzw_5d26f8d9cee27.apk") + .updateUrl("http://sdkdown.muzhiwan.com/openfile/2019/07/11/com.netease.syfz.mzw_5d26f8d9cee27.apk") .resume(); } break; diff --git a/build.gradle b/build.gradle index b6cecc15..80a7004e 100644 --- a/build.gradle +++ b/build.gradle @@ -45,7 +45,7 @@ task clean(type: Delete) { ext { versionCode = 378 - versionName = '3.7.8-pre-1' + versionName = '3.7.8-pre-3' userOrg = 'arialyy' groupId = 'com.arialyy.aria' publishVersion = versionName