修复重试无效的bug

pull/330/head
AriaLyy 8 years ago
parent aeb4e5dd40
commit 3b1d024b11
  1. 9
      Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
  2. 5
      Aria/src/main/java/com/arialyy/aria/core/scheduler/IDownloadSchedulers.java
  3. 2
      Aria/src/main/java/com/arialyy/aria/util/Configuration.java

@ -130,8 +130,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
startNextTask(entity); startNextTask(entity);
break; break;
case FAIL: case FAIL:
mQueue.removeTask(entity); handleFailTask(task);
handleFailTask(entity);
break; break;
} }
return true; return true;
@ -192,9 +191,9 @@ public class DownloadSchedulers implements IDownloadSchedulers {
/** /**
* 处理下载任务下载失败的情形 * 处理下载任务下载失败的情形
* *
* @param entity 失败实体 * @param task 下载任务
*/ */
@Override public void handleFailTask(final DownloadEntity entity) { @Override public void handleFailTask(final Task task) {
final Configuration config = Configuration.getInstance(); final Configuration config = Configuration.getInstance();
CountDownTimer timer = new CountDownTimer(config.getReTryInterval(), 1000) { CountDownTimer timer = new CountDownTimer(config.getReTryInterval(), 1000) {
@Override public void onTick(long millisUntilFinished) { @Override public void onTick(long millisUntilFinished) {
@ -202,6 +201,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
} }
@Override public void onFinish() { @Override public void onFinish() {
DownloadEntity entity = task.getDownloadEntity();
if (entity.getFailNum() <= config.getReTryNum()) { if (entity.getFailNum() <= config.getReTryNum()) {
Task task = mQueue.getTask(entity); Task task = mQueue.getTask(entity);
mQueue.reTryStart(task); mQueue.reTryStart(task);
@ -211,6 +211,7 @@ public class DownloadSchedulers implements IDownloadSchedulers {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {
mQueue.removeTask(entity);
startNextTask(entity); startNextTask(entity);
} }
} }

@ -18,6 +18,7 @@ package com.arialyy.aria.core.scheduler;
import android.os.Handler; import android.os.Handler;
import com.arialyy.aria.core.DownloadEntity; import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
/** /**
* Created by AriaLyy@outlook.com on 2016/11/2. * Created by AriaLyy@outlook.com on 2016/11/2.
@ -42,9 +43,9 @@ public interface IDownloadSchedulers extends Handler.Callback {
/** /**
* 处理下载任务下载失败的情形 * 处理下载任务下载失败的情形
* *
* @param entity 下载实体 * @param task 下载任务
*/ */
public void handleFailTask(DownloadEntity entity); public void handleFailTask(Task task);
/** /**
* 启动下一个任务条件任务停止取消下载任务完成 * 启动下一个任务条件任务停止取消下载任务完成

@ -84,7 +84,7 @@ public class Configuration {
private void init() { private void init() {
Map<String, String> config = new WeakHashMap<>(); Map<String, String> config = new WeakHashMap<>();
config.put(DOWNLOAD_NUM, 2 + ""); config.put(DOWNLOAD_NUM, 2 + "");
config.put(RE_TRY_NUM, 10 + ""); config.put(RE_TRY_NUM, 3 + "");
config.put(OPEN_BROADCAST, false + ""); config.put(OPEN_BROADCAST, false + "");
config.put(RE_TRY_INTERVAL, 4000 + ""); config.put(RE_TRY_INTERVAL, 4000 + "");
config.put(DOWNLOAD_TIME_OUT, 10000 + ""); config.put(DOWNLOAD_TIME_OUT, 10000 + "");

Loading…
Cancel
Save