laoyuyu
2019-11-01 21:20:07 +08:00
parent 39c485b157
commit d6993eb159
13 changed files with 69 additions and 35 deletions

View File

@@ -47,9 +47,10 @@ public class HttpDownloadModule extends BaseViewModule {
* 单任务下载的信息
*/
LiveData<DownloadEntity> getHttpDownloadInfo(Context context) {
String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl);
//String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl);
//String url =
// "http://sdkdown.muzhiwan.com/openfile/2019/05/21/com.netease.tom.mzw_5ce3ef8754d05.apk";
String url = "http://image.totwoo.com/totwoo-TOTWOO-v3.5.6.apk";
String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);
singDownloadInfo = Aria.download(context).getFirstDownloadEntity(url);

View File

@@ -289,8 +289,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
private void startD() {
HttpOption option = new HttpOption();
option.addHeader("1", "@")
.setFileLenAdapter(new FileLenAdapter())
.useServerFileName(true);
.useServerFileName(true)
.setFileLenAdapter(new FileLenAdapter());
mTaskId = Aria.download(SingleTaskActivity.this)
.load(mUrl)
.setFilePath(mFilePath, true)

View File

@@ -257,7 +257,11 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
case IEntity.STATE_STOP:
case IEntity.STATE_PRE:
case IEntity.STATE_POST_PRE:
start(entity);
if (entity.getId() < 0){
start(entity);
}else {
resume(entity);
}
break;
case IEntity.STATE_RUNNING:
stop(entity);
@@ -291,6 +295,24 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
}
}
private void resume(AbsEntity entity){
switch (entity.getTaskType()) {
case AbsTaskWrapper.D_FTP:
//Aria.download(getContext()).loadFtp((DownloadEntity) entity).login("lao", "123456").create();
Aria.download(getContext()).loadFtp(entity.getId()).resume();
break;
case AbsTaskWrapper.D_FTP_DIR:
Aria.download(getContext()).loadFtpDir(entity.getId()).resume();
break;
case AbsTaskWrapper.D_HTTP:
Aria.download(getContext()).load(entity.getId()).resume();
break;
case AbsTaskWrapper.DG_HTTP:
Aria.download(getContext()).loadGroup(entity.getId()).resume();
break;
}
}
private void start(AbsEntity entity) {
switch (entity.getTaskType()) {
case AbsTaskWrapper.D_FTP:

View File

@@ -103,6 +103,9 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
}
@Download.onTaskFail void taskFail(DownloadTask task) {
if (task == null || task.getEntity() == null){
return;
}
mAdapter.updateState(task.getEntity());
}

View File

@@ -101,6 +101,9 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
}
@Download.onTaskFail void taskFail(DownloadTask task) {
if (task == null || task.getEntity() == null){
return;
}
mAdapter.updateBtState(task.getKey(), true);
}