pull/10/head
AriaLyy 8 years ago
parent 212d635f85
commit 7cea897865
  1. 2
      .idea/misc.xml
  2. 5
      Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
  3. 6
      Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java

@ -37,7 +37,7 @@
<ConfirmationsSetting value="0" id="Add" /> <ConfirmationsSetting value="0" id="Add" />
<ConfirmationsSetting value="0" id="Remove" /> <ConfirmationsSetting value="0" id="Remove" />
</component> </component>
<component name="ProjectRootManager" version="2" languageLevel="JDK_1_8" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK"> <component name="ProjectRootManager" version="2" languageLevel="JDK_1_7" default="true" assert-keyword="true" jdk-15="true" project-jdk-name="1.8" project-jdk-type="JavaSDK">
<output url="file://$PROJECT_DIR$/build/classes" /> <output url="file://$PROJECT_DIR$/build/classes" />
</component> </component>
<component name="ProjectType"> <component name="ProjectType">

@ -171,13 +171,10 @@ public class DownloadTaskQueue implements ITaskQueue {
Task task = mExecutePool.getTask(entity.getDownloadUrl()); Task task = mExecutePool.getTask(entity.getDownloadUrl());
if (task != null) { if (task != null) {
Log.d(TAG, "从执行池删除任务,删除" + (mExecutePool.removeTask(task) ? "成功" : "失败")); Log.d(TAG, "从执行池删除任务,删除" + (mExecutePool.removeTask(task) ? "成功" : "失败"));
} else {
task = mCachePool.getTask(entity.getDownloadUrl());
} }
task = mCachePool.getTask(entity.getDownloadUrl());
if (task != null) { if (task != null) {
Log.d(TAG, "从缓存池删除任务,删除" + (mCachePool.removeTask(task) ? "成功" : "失败")); Log.d(TAG, "从缓存池删除任务,删除" + (mCachePool.removeTask(task) ? "成功" : "失败"));
} else {
Log.w(TAG, "没有找到下载链接为【" + entity.getDownloadUrl() + "】的任务");
} }
} }

@ -121,15 +121,16 @@ public class DownloadSchedulers implements IDownloadSchedulers {
case STOP: case STOP:
case CANCEL: case CANCEL:
mQueue.removeTask(entity); mQueue.removeTask(entity);
mQueue.removeTask(entity); if (mQueue.size() < Configuration.getInstance().getDownloadNum()) {
if (mQueue.size() != Configuration.getInstance().getDownloadNum()) {
startNextTask(entity); startNextTask(entity);
} }
break; break;
case COMPLETE: case COMPLETE:
mQueue.removeTask(entity);
startNextTask(entity); startNextTask(entity);
break; break;
case FAIL: case FAIL:
mQueue.removeTask(entity);
handleFailTask(entity); handleFailTask(entity);
break; break;
} }
@ -223,7 +224,6 @@ public class DownloadSchedulers implements IDownloadSchedulers {
* @param entity 通过Handler传递的下载实体 * @param entity 通过Handler传递的下载实体
*/ */
@Override public void startNextTask(DownloadEntity entity) { @Override public void startNextTask(DownloadEntity entity) {
mQueue.removeTask(entity);
Task newTask = mQueue.getNextTask(); Task newTask = mQueue.getNextTask();
if (newTask == null) { if (newTask == null) {
Log.w(TAG, "没有下一任务"); Log.w(TAG, "没有下一任务");

Loading…
Cancel
Save