修复下载任务更新url失败的问题

v3.7
laoyuyu 5 years ago
parent 651db90b99
commit 9951f04bf6
  1. 12
      Aria/src/main/java/com/arialyy/aria/core/download/DNormalConfigHandler.java
  2. 9
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Delegate.java
  3. 13
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8TaskConfig.java
  4. 3
      app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java
  5. 4
      app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java

@ -35,11 +35,6 @@ class DNormalConfigHandler<TARGET extends AbsTarget> implements IConfigHandler {
private TARGET mTarget;
private DTaskWrapper mWrapper;
/**
* 资源地址
*/
private String mUrl;
/**
* @param taskId 第一次下载taskId为-1
*/
@ -67,12 +62,13 @@ class DNormalConfigHandler<TARGET extends AbsTarget> implements IConfigHandler {
ALog.e(TAG, "url更新失败,newUrl为null");
return mTarget;
}
if (mUrl.equals(newUrl)) {
if (mEntity.getUrl().equals(newUrl)) {
ALog.e(TAG, "url更新失败,新的下载url和旧的url一致");
return mTarget;
}
getWrapper().setRefreshInfo(true);
getWrapper().setTempUrl(newUrl);
ALog.d(TAG, "更新url成功");
return mTarget;
}
@ -81,7 +77,8 @@ class DNormalConfigHandler<TARGET extends AbsTarget> implements IConfigHandler {
}
@Override public boolean taskExists() {
return DbEntity.checkDataExist(DownloadEntity.class, "url=?", mUrl);
return DbEntity.checkDataExist(DownloadEntity.class, "rowid=?",
String.valueOf(mEntity.getId()));
}
@Override public boolean isRunning() {
@ -93,7 +90,6 @@ class DNormalConfigHandler<TARGET extends AbsTarget> implements IConfigHandler {
}
void setUrl(String url) {
this.mUrl = url;
mEntity.setUrl(url);
}

@ -34,6 +34,15 @@ public class M3U8Delegate<TARGET extends AbsTarget> extends BaseDelegate<TARGET>
mTaskWrapper.setRequestType(AbsTaskWrapper.M3U8_VOD);
}
/**
* 生成m3u8索引文件只有{@link #merge(boolean)}设置为false才会有效
*/
@CheckResult(suggest = Suggest.TO_CONTROLLER)
public M3U8Delegate<TARGET> genetateIndexFile() {
mTaskWrapper.asM3U8().setGenerateIndexFile(true);
return this;
}
/**
* 是否合并ts文件默认合并ts
*

@ -98,6 +98,19 @@ public class M3U8TaskConfig {
*/
private int jumpIndex;
/**
* 生成索引
*/
private boolean generateIndexFile;
public boolean isGenerateIndexFile() {
return generateIndexFile;
}
public void setGenerateIndexFile(boolean generateIndexFile) {
this.generateIndexFile = generateIndexFile;
}
public int getJumpIndex() {
return jumpIndex;
}

@ -47,7 +47,8 @@ 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 filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);
singDownloadInfo = Aria.download(context).getFirstDownloadEntity(url);

@ -274,7 +274,9 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
if (Aria.download(this).load(mTaskId).isRunning()) {
Aria.download(this).load(mTaskId).stop();
} else {
Aria.download(this).load(mTaskId).resume();
Aria.download(this).load(mTaskId)
//.updateUrl("http://sdkdown.muzhiwan.com/openfile/2019/07/11/com.netease.syfz.mzw_5d26f8d9cee27.apk")
.resume();
}
break;
case R.id.cancel:

Loading…
Cancel
Save