From 7cea89786561b48607436e2fa3bde1e09e2a2959 Mon Sep 17 00:00:00 2001
From: AriaLyy <511455842@qq.com>
Date: Mon, 16 Jan 2017 19:18:31 +0800
Subject: [PATCH] ..
---
.idea/misc.xml | 2 +-
.../arialyy/aria/core/queue/DownloadTaskQueue.java | 11 ++++-------
.../aria/core/scheduler/DownloadSchedulers.java | 6 +++---
3 files changed, 8 insertions(+), 11 deletions(-)
diff --git a/.idea/misc.xml b/.idea/misc.xml
index fbb68289..5d199810 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
index d4a8f86a..de033a65 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
@@ -33,9 +33,9 @@ import com.arialyy.aria.util.Configuration;
* 下载任务队列
*/
public class DownloadTaskQueue implements ITaskQueue {
- private static final String TAG = "DownloadTaskQueue";
- private CachePool mCachePool = CachePool.getInstance();
- private ExecutePool mExecutePool = ExecutePool.getInstance();
+ private static final String TAG = "DownloadTaskQueue";
+ private CachePool mCachePool = CachePool.getInstance();
+ private ExecutePool mExecutePool = ExecutePool.getInstance();
private Context mContext;
//private IDownloadSchedulers mSchedulers;
@@ -171,13 +171,10 @@ public class DownloadTaskQueue implements ITaskQueue {
Task task = mExecutePool.getTask(entity.getDownloadUrl());
if (task != null) {
Log.d(TAG, "从执行池删除任务,删除" + (mExecutePool.removeTask(task) ? "成功" : "失败"));
- } else {
- task = mCachePool.getTask(entity.getDownloadUrl());
}
+ task = mCachePool.getTask(entity.getDownloadUrl());
if (task != null) {
Log.d(TAG, "从缓存池删除任务,删除" + (mCachePool.removeTask(task) ? "成功" : "失败"));
- } else {
- Log.w(TAG, "没有找到下载链接为【" + entity.getDownloadUrl() + "】的任务");
}
}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
index 22a7d283..25e9385c 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
@@ -121,15 +121,16 @@ public class DownloadSchedulers implements IDownloadSchedulers {
case STOP:
case CANCEL:
mQueue.removeTask(entity);
- mQueue.removeTask(entity);
- if (mQueue.size() != Configuration.getInstance().getDownloadNum()) {
+ if (mQueue.size() < Configuration.getInstance().getDownloadNum()) {
startNextTask(entity);
}
break;
case COMPLETE:
+ mQueue.removeTask(entity);
startNextTask(entity);
break;
case FAIL:
+ mQueue.removeTask(entity);
handleFailTask(entity);
break;
}
@@ -223,7 +224,6 @@ public class DownloadSchedulers implements IDownloadSchedulers {
* @param entity 通过Handler传递的下载实体
*/
@Override public void startNextTask(DownloadEntity entity) {
- mQueue.removeTask(entity);
Task newTask = mQueue.getNextTask();
if (newTask == null) {
Log.w(TAG, "没有下一任务");