diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java index 20c7a514..44954e89 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java @@ -217,14 +217,18 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader { @Override public void cancel() { isCancel = true; - mInfoTask.cancel(); + if (mInfoTask != null){ + mInfoTask.cancel(); + } closeTimer(); mSubQueue.removeAllTask(); mListener.onCancel(); } @Override public void stop() { - mInfoTask.stop(); + if (mInfoTask != null){ + mInfoTask.stop(); + } isStop = true; if (mSubQueue.getExecSize() == 0) { mListener.onStop(mGTWrapper.getEntity().getCurrentProgress()); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoader.java index 4282ef58..94f8d3d5 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoader.java @@ -229,7 +229,9 @@ public abstract class AbsNormalLoader implements ILoad ALog.d(TAG, String.format("任务【%s】正在删除,删除任务失败", mTaskWrapper.getKey())); return; } - mInfoTask.cancel(); + if (mInfoTask != null){ + mInfoTask.cancel(); + } closeTimer(); isCancel = true; onCancel(); @@ -263,7 +265,9 @@ public abstract class AbsNormalLoader implements ILoad if (isStop) { return; } - mInfoTask.stop(); + if (mInfoTask != null){ + mInfoTask.stop(); + } closeTimer(); isStop = true; onStop(); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java index 2d6a2825..f46d57d5 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java @@ -182,6 +182,9 @@ public final class SubLoader implements ILoader, ILoaderVisitor { return; } isStop = true; + if (infoTask != null){ + infoTask.stop(); + } for (IThreadTask iThreadTask : mTask) { iThreadTask.stop(); } @@ -203,6 +206,9 @@ public final class SubLoader implements ILoader, ILoaderVisitor { return; } isCancel = true; + if (infoTask != null){ + infoTask.cancel(); + } for (IThreadTask iThreadTask : mTask) { iThreadTask.cancel(); } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java index 5b953e18..8a67263b 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java @@ -225,7 +225,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { File blockFile = mConfig.tempFile; if (!blockFile.exists() || blockFile.length() != mRecord.blockLen) { 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, mRecord.endLocation)); if (blockFile.exists()) { @@ -310,7 +310,8 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { } @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); // 进度发送不是实时的,发送完成任务前,需要更新一次进度 sendRunningState(); @@ -420,7 +421,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { * 重试ts分片 */ private void retryM3U8Peer(boolean needRetry) { - if (mConfig.ignoreFailure){ + if (mConfig.ignoreFailure) { ALog.d(TAG, "忽略失败的切片"); sendFailMsg(null, false); return; @@ -431,9 +432,10 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { sendFailMsg(null, false); return; } - if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected( - AriaConfig.getInstance().getAPP()) - || isNotNetRetry) && !isBreak()) { + if (mFailTimes < RETRY_NUM + && needRetry + && (NetUtils.isConnected(AriaConfig.getInstance().getAPP()) || isNotNetRetry) + && !isBreak()) { ALog.w(TAG, String.format("ts切片【%s】第%s重试", getFileName(), String.valueOf(mFailTimes))); mFailTimes++; FileUtil.deleteFile(mConfig.tempFile); @@ -455,15 +457,19 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver { sendFailMsg(null, false); return; } - if (mFailTimes < RETRY_NUM && needRetry && (NetUtils.isConnected( - AriaConfig.getInstance().getAPP()) || isNotNetRetry) && !isBreak()) { + if (mFailTimes < RETRY_NUM + && needRetry + && (NetUtils.isConnected(AriaConfig.getInstance().getAPP()) || isNotNetRetry) + && !isBreak()) { ALog.w(TAG, String.format("分块【%s】第%s次重试", getFileName(), String.valueOf(mFailTimes))); mFailTimes++; handleBlockRecord(); ThreadTaskManager.getInstance().retryThread(this); 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); } diff --git a/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java b/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java index ec1ad778..29389dc3 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java +++ b/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java @@ -34,7 +34,7 @@ public class GroupModule extends BaseModule { List urls = new ArrayList<>(); 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("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; } List getUrls1() { @@ -52,7 +52,7 @@ public class GroupModule extends BaseModule { //Collections.addAll(names, str); names.add("京东到家.apk"); names.add("菜鸟.apk"); - names.add("酷安.apk"); + names.add("网易严选.apk"); //names.add("4.png"); //names.add("5.png"); return names;