Skip to content
Permalink
Browse files

组合任务新增`unknownSize()`,用于处理组合任务大小未知的情况,#380

  • Loading branch information...
AriaLyy committed May 8, 2019
1 parent 8c0ef0f commit 0c3e16cad7746ad7947a8668e97d73f2ee743952
Showing with 350 additions and 228 deletions.
  1. +17 −15 Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  2. +6 −1 Aria/src/main/java/com/arialyy/aria/core/common/CompleteInfo.java
  3. +4 −4 Aria/src/main/java/com/arialyy/aria/core/common/StateConstance.java
  4. +15 −0 Aria/src/main/java/com/arialyy/aria/core/common/SubThreadConfig.java
  5. +10 −0 Aria/src/main/java/com/arialyy/aria/core/download/DGTaskWrapper.java
  6. +196 −183 Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java
  7. +2 −2 Aria/src/main/java/com/arialyy/aria/core/download/HttpGroupDelegate.java
  8. +1 −1 Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpFileInfoThread.java
  9. +1 −1 Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java
  10. +0 −2 Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpThreadTask.java
  11. +1 −0 Aria/src/main/java/com/arialyy/aria/core/download/downloader/SimpleDownloadUtil.java
  12. +9 −1 Aria/src/main/java/com/arialyy/aria/core/download/group/AbsGroupUtil.java
  13. +70 −3 Aria/src/main/java/com/arialyy/aria/core/download/group/DownloadGroupUtil.java
  14. +1 −1 Aria/src/main/java/com/arialyy/aria/core/download/group/FtpDirInfoThread.java
  15. +6 −1 Aria/src/main/java/com/arialyy/aria/core/download/group/SubDownloadLoader.java
  16. +2 −1 Aria/src/main/java/com/arialyy/aria/core/upload/uploader/FtpFileInfoThread.java
  17. +1 −1 Aria/src/main/java/com/arialyy/aria/util/DbDataHelper.java
  18. +1 −0 DEV_LOG.md
  19. +4 −4 app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
  20. +2 −6 app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java
  21. +1 −1 build.gradle
@@ -115,8 +115,7 @@ public void setInterrupted(boolean isInterrupted) {
* @return {@code true}存活
*/
protected boolean isLive() {
Thread t = Thread.currentThread();
return !t.isInterrupted() && !isInterrupted;
return !Thread.currentThread().isInterrupted() && !isInterrupted;
}

/**
@@ -399,19 +398,22 @@ protected void fail(final long subCurrentLocation, BaseException ex, boolean nee
* @param needRetry 是否可以重试
*/
private void retryThis(boolean needRetry) {
if (!NetUtils.isConnected(AriaManager.APP) && !isNotNetRetry) {
ALog.w(TAG, String.format("任务【%s】thread__%s__重试失败,网络未连接", mConfig.TEMP_FILE.getName(),
mConfig.THREAD_ID));
}
if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected(AriaManager.APP)
|| isNotNetRetry) && !isBreak()) {
ALog.w(TAG,
String.format("任务【%s】thread__%s__正在重试", mConfig.TEMP_FILE.getName(), mConfig.THREAD_ID));
mFailTimes++;
handleRetryRecord();
ThreadTaskManager.getInstance().retryThread(AbsThreadTask.this);
} else {
handleFailState(!isBreak());
synchronized (AriaManager.LOCK) {
if (!NetUtils.isConnected(AriaManager.APP) && !isNotNetRetry) {
ALog.w(TAG, String.format("任务【%s】thread__%s__重试失败,网络未连接", mConfig.TEMP_FILE.getName(),
mConfig.THREAD_ID));
}
if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected(AriaManager.APP)
|| isNotNetRetry) && !isBreak()) {
ALog.w(TAG,
String.format("任务【%s】thread__%s__正在重试", mConfig.TEMP_FILE.getName(),
mConfig.THREAD_ID));
mFailTimes++;
handleRetryRecord();
ThreadTaskManager.getInstance().retryThread(AbsThreadTask.this);
} else {
handleFailState(!isBreak());
}
}
}

@@ -15,6 +15,8 @@
*/
package com.arialyy.aria.core.common;

import com.arialyy.aria.core.inf.AbsTaskWrapper;

/**
* Created by AriaL on 2018/3/3.
* 获取文件信息完成后 回调给下载线程的信息
@@ -25,7 +27,10 @@
*/
public int code;

public CompleteInfo(int code) {
public AbsTaskWrapper wrapper;

public CompleteInfo(int code, AbsTaskWrapper wrapper) {
this.code = code;
this.wrapper = wrapper;
}
}
@@ -53,17 +53,17 @@ public void resetState() {
* 所有子线程是否都已经停止
*/
public boolean isStop() {
//ALog.d(TAG, String.format("stop_num=%s; start_thread_num=%s; complete_num=%s", STOP_NUM,
// START_THREAD_NUM, COMPLETE_THREAD_NUM));
//ALog.d(TAG, String.format("stop_thread_num=%s; start_thread_num=%s; complete_thread_num=%s",
// STOP_NUM, START_THREAD_NUM, COMPLETE_THREAD_NUM));
return STOP_NUM == START_THREAD_NUM || STOP_NUM + COMPLETE_THREAD_NUM == START_THREAD_NUM;
}

/**
* 所有子线程是否都已经失败
*/
public boolean isFail() {
//ALog.d(TAG, String.format("fail_num=%s; start_thread_num=%s; complete_num=%s", FAIL_NUM,
// START_THREAD_NUM, COMPLETE_THREAD_NUM));
//ALog.d(TAG, String.format("fail_thread_num=%s; start_thread_num=%s; complete_thread_num=%s",
// FAIL_NUM, START_THREAD_NUM, COMPLETE_THREAD_NUM));
return COMPLETE_THREAD_NUM != START_THREAD_NUM
&& (FAIL_NUM == START_THREAD_NUM || FAIL_NUM + COMPLETE_THREAD_NUM == START_THREAD_NUM);
}
@@ -1,3 +1,18 @@
/*
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core.common;

import com.arialyy.aria.core.inf.AbsTaskWrapper;
@@ -27,6 +27,8 @@

private List<DTaskWrapper> subTaskEntities;

private boolean unknownSize = false;

public DGTaskWrapper(DownloadGroupEntity entity) {
super(entity);
}
@@ -36,6 +38,14 @@ public void setSubTaskWrapper(List<DTaskWrapper> subTaskEntities) {
this.subTaskEntities = subTaskEntities;
}

public boolean isUnknownSize() {
return unknownSize;
}

public void setUnknownSize(boolean unknownSize) {
this.unknownSize = unknownSize;
}

/**
* 组名
*/
Oops, something went wrong.

0 comments on commit 0c3e16c

Please sign in to comment.
You can’t perform that action at this time.