修复没有断点回调的bug

v3.6.6
laoyuyu 6 years ago
parent 3786a91ae2
commit 605e9f9da4
  1. 5
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  2. 3
      Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  3. 6
      Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java
  4. 2
      Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java
  5. 4
      Aria/src/main/java/com/arialyy/aria/core/scheduler/ISchedulers.java
  6. 11
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  7. 2
      build.gradle

@ -18,6 +18,7 @@ package com.arialyy.aria.core.common;
import android.content.Context;
import android.util.SparseArray;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.BaseDListener;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsNormalEntity;
@ -196,6 +197,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
if (mConstance.isComplete()
|| mConstance.isStop()
|| mConstance.isCancel()
|| mConstance.isFail()
|| !mConstance.isRunning) {
closeTimer();
} else if (mConstance.CURRENT_LOCATION >= 0) {
@ -653,6 +655,9 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
* 处理不支持断点的任务
*/
private void handleNoSupportBP() {
if (mListener instanceof BaseDListener){
((BaseDListener) mListener).supportBreakpoint(false);
}
SubThreadConfig<TASK_ENTITY> config = new SubThreadConfig<>();
config.TOTAL_FILE_SIZE = mEntity.getFileSize();
config.URL = mEntity.isRedirect() ? mEntity.getRedirectUrl() : mEntity.getUrl();

@ -378,8 +378,8 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
retryThis(needRetry && STATE.START_THREAD_NUM != 1);
} else {
ALog.e(TAG, String.format("任务【%s】执行失败", mConfig.TEMP_FILE.getName()));
mListener.onFail(true, ex);
ErrorHelp.saveError(TAG, "", ALog.getExceptionString(ex));
handleFailState(!isBreak());
}
}
}
@ -478,7 +478,6 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
// 手动停止不进行fail回调
if (!STATE.isStop) {
String errorMsg = String.format("任务【%s】执行失败", mConfig.TEMP_FILE.getName());
//ALog.e(TAG, errorMsg);
mListener.onFail(taskNeedReTry, new TaskException(TAG, errorMsg));
}
}

@ -27,7 +27,7 @@ import com.arialyy.aria.util.CommonUtil;
/**
* 下载监听类
*/
class BaseDListener extends BaseListener<DownloadEntity, DownloadTaskEntity, DownloadTask>
public class BaseDListener extends BaseListener<DownloadEntity, DownloadTaskEntity, DownloadTask>
implements IDownloadListener {
private static final String TAG = "BaseDListener";
@ -45,7 +45,9 @@ class BaseDListener extends BaseListener<DownloadEntity, DownloadTaskEntity, Dow
}
@Override public void supportBreakpoint(boolean support) {
if (!support){
sendInState2Target(ISchedulers.NO_SUPPORT_BREAK_POINT);
}
}
@Override

@ -247,7 +247,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
case FAIL:
listener.onTaskFail(task, (Exception) task.getExpand(AbsTask.ERROR_INFO_KEY));
break;
case SUPPORT_BREAK_POINT:
case NO_SUPPORT_BREAK_POINT:
listener.onNoSupportBreakPoint(task);
break;
}

@ -30,9 +30,9 @@ public interface ISchedulers<Task extends AbsTask> extends Handler.Callback {
int IS_SUB_TASK = 0xd1;
/**
* 断点支持
* 不支持断点
*/
int SUPPORT_BREAK_POINT = 9;
int NO_SUPPORT_BREAK_POINT = 9;
/**
* 任务预加载
*/

@ -52,15 +52,16 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
//"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apks";
//"http://120.55.95.61:8811/ghcg/zg/武义总规纲要成果.zip";
//"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip";
//"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk";
//"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip";
//"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk";
//"http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载
"https://static.donguo.me//video/ip/course/pfys_1.mp4";
//"https://static.donguo.me//video/ip/course/pfys_1.mp4";
//"https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864";
//"https://d.pcs.baidu.com/file/a02c89a2d479d4fd2756f3313d42491d?fid=4232431903-250528-1114369760340736&dstime=1525491372&rt=sh&sign=FDtAERVY-DCb740ccc5511e5e8fedcff06b081203-3C13vkOkuk4TqXvVYW05zj1K0ao%3D&expires=8h&chkv=1&chkbd=0&chkpc=et&dp-logid=8651730921842106225&dp-callid=0&r=165533013";
//"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1";
//"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
//"http://9.9.9.59:5000/download/CentOS-7-x86_64-Minimal-1804.iso";
"https://firmwareapi.azurewebsites.net/firmware-overview?name=A19_Filament_W_IMG0038_00102411-encrypted.ota";
@Bind(R.id.start) Button mStart;
@Bind(R.id.stop) Button mStop;
@Bind(R.id.cancel) Button mCancel;
@ -205,6 +206,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
}
@Download.onNoSupportBreakPoint public void onNoSupportBreakPoint(DownloadTask task) {
Log.d(TAG, "该下载链接不支持断点");
if (task.getKey().equals(DOWNLOAD_URL)) {
T.showShort(SingleTaskActivity.this, "该下载链接不支持断点");
}
@ -251,7 +253,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
private void startD() {
//Aria.get(this).setLogLevel(ALog.LOG_CLOSE);
//Aria.download(this).load("aaaa.apk");
String path = Environment.getExternalStorageDirectory().getPath() + "/ggsg11.ota";
//String path = Environment.getExternalStorageDirectory().getPath() + "/ggsg11.ota";
String path = "/sdcard/ggsg11.ota";
//File file = new File(path);
//if (file.exists()){
// file.delete();

@ -39,7 +39,7 @@ task clean(type: Delete) {
ext {
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = '3.5.2_dev_3'
publishVersion = '3.5.2_dev_4'
// publishVersion = '1.0.4' //FTP插件
repoName='maven'
desc = 'android 下载框架'

Loading…
Cancel
Save