bug fix
This commit is contained in:
2
.idea/modules.xml
generated
2
.idea/modules.xml
generated
@ -2,7 +2,9 @@
|
||||
<project version="4">
|
||||
<component name="ProjectModuleManager">
|
||||
<modules>
|
||||
<module fileurl="file://$PROJECT_DIR$/Aria.iml" filepath="$PROJECT_DIR$/Aria.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Aria/Aria.iml" filepath="$PROJECT_DIR$/Aria/Aria.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/Aria/Aria-Aria.iml" filepath="$PROJECT_DIR$/Aria/Aria-Aria.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/AriaPrj.iml" filepath="$PROJECT_DIR$/AriaPrj.iml" />
|
||||
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
|
||||
</modules>
|
||||
|
@ -97,7 +97,6 @@ public class ExecutePool<TASK extends ITask> implements IPool<TASK> {
|
||||
boolean s = mExecuteQueue.offer(newTask);
|
||||
Log.w(TAG, "任务添加" + (s ? "成功" : "失败,【" + url + "】"));
|
||||
if (s) {
|
||||
newTask.start();
|
||||
mExecuteArray.put(CommonUtil.keyToHashKey(url), newTask);
|
||||
}
|
||||
return s;
|
||||
@ -114,7 +113,6 @@ public class ExecutePool<TASK extends ITask> implements IPool<TASK> {
|
||||
return false;
|
||||
}
|
||||
oldTask.stop();
|
||||
// wait(200);
|
||||
String key = CommonUtil.keyToHashKey(oldTask.getKey());
|
||||
mExecuteArray.remove(key);
|
||||
} catch (InterruptedException e) {
|
||||
|
@ -94,8 +94,8 @@ public class DownloadSchedulers implements ISchedulers<DownloadTask> {
|
||||
startNextTask();
|
||||
break;
|
||||
case FAIL:
|
||||
mQueue.removeTask(entity);
|
||||
handleFailTask(entity);
|
||||
//mQueue.removeTask(entity);
|
||||
handleFailTask(task);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
@ -156,9 +156,9 @@ public class DownloadSchedulers implements ISchedulers<DownloadTask> {
|
||||
/**
|
||||
* 处理下载任务下载失败的情形
|
||||
*
|
||||
* @param entity 失败实体
|
||||
* @param task 下载任务
|
||||
*/
|
||||
private void handleFailTask(final DownloadEntity entity) {
|
||||
private void handleFailTask(final DownloadTask task) {
|
||||
final Configuration config = Configuration.getInstance();
|
||||
CountDownTimer timer = new CountDownTimer(config.getReTryInterval(), 1000) {
|
||||
@Override public void onTick(long millisUntilFinished) {
|
||||
@ -166,7 +166,8 @@ public class DownloadSchedulers implements ISchedulers<DownloadTask> {
|
||||
}
|
||||
|
||||
@Override public void onFinish() {
|
||||
if (entity.getFailNum() <= config.getReTryNum()) {
|
||||
DownloadEntity entity = task.getDownloadEntity();
|
||||
if (entity.getFailNum() < config.getReTryNum()) {
|
||||
DownloadTask task = mQueue.getTask(entity);
|
||||
mQueue.reTryStart(task);
|
||||
try {
|
||||
@ -175,6 +176,7 @@ public class DownloadSchedulers implements ISchedulers<DownloadTask> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
mQueue.removeTask(entity);
|
||||
startNextTask();
|
||||
}
|
||||
}
|
||||
|
@ -33,8 +33,10 @@ import java.util.concurrent.ConcurrentHashMap;
|
||||
* 上传任务调度器
|
||||
*/
|
||||
public class UploadSchedulers implements ISchedulers<UploadTask> {
|
||||
private static final String TAG = "UploadSchedulers";
|
||||
private static final Object LOCK = new Object();
|
||||
private static final String TAG =
|
||||
"UploadSchedulers";
|
||||
private static final Object LOCK =
|
||||
new Object();
|
||||
private static volatile UploadSchedulers INSTANCE = null;
|
||||
private Map<String, OnSchedulerListener<UploadTask>> mSchedulerListeners =
|
||||
new ConcurrentHashMap<>();
|
||||
@ -68,7 +70,7 @@ public class UploadSchedulers implements ISchedulers<UploadTask> {
|
||||
}
|
||||
}
|
||||
|
||||
private void handleFailTask(final UploadEntity entity) {
|
||||
private void handleFailTask(final UploadTask task) {
|
||||
final Configuration config = Configuration.getInstance();
|
||||
CountDownTimer timer = new CountDownTimer(config.getReTryInterval(), 1000) {
|
||||
@Override public void onTick(long millisUntilFinished) {
|
||||
@ -76,6 +78,7 @@ public class UploadSchedulers implements ISchedulers<UploadTask> {
|
||||
}
|
||||
|
||||
@Override public void onFinish() {
|
||||
UploadEntity entity = task.getUploadEntity();
|
||||
if (entity.getFailNum() <= config.getReTryNum()) {
|
||||
UploadTask task = mQueue.getTask(entity);
|
||||
mQueue.reTryStart(task);
|
||||
@ -85,6 +88,7 @@ public class UploadSchedulers implements ISchedulers<UploadTask> {
|
||||
e.printStackTrace();
|
||||
}
|
||||
} else {
|
||||
mQueue.removeTask(entity);
|
||||
startNextTask();
|
||||
}
|
||||
}
|
||||
@ -176,8 +180,7 @@ public class UploadSchedulers implements ISchedulers<UploadTask> {
|
||||
startNextTask();
|
||||
break;
|
||||
case FAIL:
|
||||
mQueue.removeTask(entity);
|
||||
handleFailTask(entity);
|
||||
handleFailTask(task);
|
||||
break;
|
||||
}
|
||||
return true;
|
||||
|
@ -23,6 +23,7 @@
|
||||
</intent-filter>
|
||||
</activity>
|
||||
|
||||
<activity android:name=".download.DownloadActivity"/>
|
||||
<activity android:name=".upload.UploadActivity"/>
|
||||
<activity android:name=".download.SingleTaskActivity"/>
|
||||
<activity android:name=".download.multi_download.MultiTaskActivity"/>
|
||||
|
@ -52,7 +52,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
|
||||
private static final String DOWNLOAD_URL =
|
||||
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
||||
"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
||||
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
||||
"http://1_static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
||||
@Bind(R.id.progressBar) HorizontalProgressBarWithNumber mPb;
|
||||
@Bind(R.id.start) Button mStart;
|
||||
@Bind(R.id.stop) Button mStop;
|
||||
|
@ -152,6 +152,7 @@ public class UploadActivity extends BaseActivity<ActivityUploadMeanBinding> {
|
||||
// test();
|
||||
// }
|
||||
//}).start();
|
||||
//test();
|
||||
}
|
||||
|
||||
@OnClick(R.id.stop) void stop() {
|
||||
|
Reference in New Issue
Block a user