pull/907/head
laoyuyu 4 years ago
parent 5853fe9e3e
commit 1c0765be02
  1. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java
  2. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoader.java
  3. 6
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java
  4. 24
      PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java
  5. 4
      app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java

@ -217,14 +217,18 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
@Override public void cancel() { @Override public void cancel() {
isCancel = true; isCancel = true;
if (mInfoTask != null){
mInfoTask.cancel(); mInfoTask.cancel();
}
closeTimer(); closeTimer();
mSubQueue.removeAllTask(); mSubQueue.removeAllTask();
mListener.onCancel(); mListener.onCancel();
} }
@Override public void stop() { @Override public void stop() {
if (mInfoTask != null){
mInfoTask.stop(); mInfoTask.stop();
}
isStop = true; isStop = true;
if (mSubQueue.getExecSize() == 0) { if (mSubQueue.getExecSize() == 0) {
mListener.onStop(mGTWrapper.getEntity().getCurrentProgress()); mListener.onStop(mGTWrapper.getEntity().getCurrentProgress());

@ -229,7 +229,9 @@ public abstract class AbsNormalLoader<T extends AbsTaskWrapper> implements ILoad
ALog.d(TAG, String.format("任务【%s】正在删除,删除任务失败", mTaskWrapper.getKey())); ALog.d(TAG, String.format("任务【%s】正在删除,删除任务失败", mTaskWrapper.getKey()));
return; return;
} }
if (mInfoTask != null){
mInfoTask.cancel(); mInfoTask.cancel();
}
closeTimer(); closeTimer();
isCancel = true; isCancel = true;
onCancel(); onCancel();
@ -263,7 +265,9 @@ public abstract class AbsNormalLoader<T extends AbsTaskWrapper> implements ILoad
if (isStop) { if (isStop) {
return; return;
} }
if (mInfoTask != null){
mInfoTask.stop(); mInfoTask.stop();
}
closeTimer(); closeTimer();
isStop = true; isStop = true;
onStop(); onStop();

@ -182,6 +182,9 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
return; return;
} }
isStop = true; isStop = true;
if (infoTask != null){
infoTask.stop();
}
for (IThreadTask iThreadTask : mTask) { for (IThreadTask iThreadTask : mTask) {
iThreadTask.stop(); iThreadTask.stop();
} }
@ -203,6 +206,9 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
return; return;
} }
isCancel = true; isCancel = true;
if (infoTask != null){
infoTask.cancel();
}
for (IThreadTask iThreadTask : mTask) { for (IThreadTask iThreadTask : mTask) {
iThreadTask.cancel(); iThreadTask.cancel();
} }

@ -225,7 +225,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
File blockFile = mConfig.tempFile; File blockFile = mConfig.tempFile;
if (!blockFile.exists() || blockFile.length() != mRecord.blockLen) { if (!blockFile.exists() || blockFile.length() != mRecord.blockLen) {
ALog.i(TAG, ALog.i(TAG,
String.format("分块【%s】错误,blockFileLen: %s, threadRect: %s; 即将重新下载该分块开始位置:%s,结束位置:%s", String.format("分块【%s】错误,blockFileLen: %s, threadRect: %s; 即将重新下载该分块, 开始位置:%s,结束位置:%s",
blockFile.getName(), blockFile.length(), mRecord.blockLen, mRecord.startLocation, blockFile.getName(), blockFile.length(), mRecord.blockLen, mRecord.startLocation,
mRecord.endLocation)); mRecord.endLocation));
if (blockFile.exists()) { if (blockFile.exists()) {
@ -310,7 +310,8 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
} }
@Override public synchronized void updateCompleteState() { @Override public synchronized void updateCompleteState() {
ALog.i(TAG, String.format("任务【%s】线程__%s__完成, blockSize = %s", getTaskWrapper().getKey(), mRecord.threadId, mConfig.tempFile.length())); ALog.i(TAG, String.format("任务【%s】线程__%s__完成, blockSize = %s", getTaskWrapper().getKey(),
mRecord.threadId, mConfig.tempFile.length()));
writeConfig(true, mRecord.endLocation); writeConfig(true, mRecord.endLocation);
// 进度发送不是实时的,发送完成任务前,需要更新一次进度 // 进度发送不是实时的,发送完成任务前,需要更新一次进度
sendRunningState(); sendRunningState();
@ -420,7 +421,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
* 重试ts分片 * 重试ts分片
*/ */
private void retryM3U8Peer(boolean needRetry) { private void retryM3U8Peer(boolean needRetry) {
if (mConfig.ignoreFailure){ if (mConfig.ignoreFailure) {
ALog.d(TAG, "忽略失败的切片"); ALog.d(TAG, "忽略失败的切片");
sendFailMsg(null, false); sendFailMsg(null, false);
return; return;
@ -431,9 +432,10 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
sendFailMsg(null, false); sendFailMsg(null, false);
return; return;
} }
if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected( if (mFailTimes < RETRY_NUM
AriaConfig.getInstance().getAPP()) && needRetry
|| isNotNetRetry) && !isBreak()) { && (NetUtils.isConnected(AriaConfig.getInstance().getAPP()) || isNotNetRetry)
&& !isBreak()) {
ALog.w(TAG, String.format("ts切片【%s】第%s重试", getFileName(), String.valueOf(mFailTimes))); ALog.w(TAG, String.format("ts切片【%s】第%s重试", getFileName(), String.valueOf(mFailTimes)));
mFailTimes++; mFailTimes++;
FileUtil.deleteFile(mConfig.tempFile); FileUtil.deleteFile(mConfig.tempFile);
@ -455,15 +457,19 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
sendFailMsg(null, false); sendFailMsg(null, false);
return; return;
} }
if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected( if (mFailTimes < RETRY_NUM
AriaConfig.getInstance().getAPP()) || isNotNetRetry) && !isBreak()) { && needRetry
&& (NetUtils.isConnected(AriaConfig.getInstance().getAPP()) || isNotNetRetry)
&& !isBreak()) {
ALog.w(TAG, String.format("分块【%s】第%s次重试", getFileName(), String.valueOf(mFailTimes))); ALog.w(TAG, String.format("分块【%s】第%s次重试", getFileName(), String.valueOf(mFailTimes)));
mFailTimes++; mFailTimes++;
handleBlockRecord(); handleBlockRecord();
ThreadTaskManager.getInstance().retryThread(this); ThreadTaskManager.getInstance().retryThread(this);
return; return;
} }
ALog.e(TAG, String.format("任务【%s】执行失败", getFileName())); ALog.e(TAG,
String.format("重试分开【%s】失败,failTimes = %s, needRetry = %s, isBreak = %s",
getFileName(), mFailTimes, needRetry, isBreak()));
sendFailMsg(null, needRetry); sendFailMsg(null, needRetry);
} }

@ -34,7 +34,7 @@ public class GroupModule extends BaseModule {
List<String> urls = new ArrayList<>(); List<String> urls = new ArrayList<>();
urls.add("http://storage.jd.com/apk/newchannel/jingdongdaojia-lechuang30.apk"); urls.add("http://storage.jd.com/apk/newchannel/jingdongdaojia-lechuang30.apk");
urls.add("https://appdownload.alicdn.com/publish/cainiao4android/latest/cainiao4android_1598322688221.apk"); urls.add("https://appdownload.alicdn.com/publish/cainiao4android/latest/cainiao4android_1598322688221.apk");
urls.add("http://dl-tc.coolapkmarket.com/down/apk_file/2020/0927/Coolapk-10.5.3-2009271_sign.apk"); urls.add("https://yanxuan-dl.nosdn.127.net/yan/android/yanxuan-aos_out_3547.apk");
return urls; return urls;
} }
List<String> getUrls1() { List<String> getUrls1() {
@ -52,7 +52,7 @@ public class GroupModule extends BaseModule {
//Collections.addAll(names, str); //Collections.addAll(names, str);
names.add("京东到家.apk"); names.add("京东到家.apk");
names.add("菜鸟.apk"); names.add("菜鸟.apk");
names.add("酷安.apk"); names.add("网易严选.apk");
//names.add("4.png"); //names.add("4.png");
//names.add("5.png"); //names.add("5.png");
return names; return names;

Loading…
Cancel
Save