diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DNormalConfigHandler.java b/Aria/src/main/java/com/arialyy/aria/core/download/DNormalConfigHandler.java index 240d6136..892b2796 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DNormalConfigHandler.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DNormalConfigHandler.java @@ -35,11 +35,6 @@ class DNormalConfigHandler implements IConfigHandler { private TARGET mTarget; private DTaskWrapper mWrapper; - /** - * 资源地址 - */ - private String mUrl; - /** * @param taskId 第一次下载,taskId为-1 */ @@ -67,12 +62,13 @@ class DNormalConfigHandler 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 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 implements IConfigHandler { } void setUrl(String url) { - this.mUrl = url; mEntity.setUrl(url); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Delegate.java b/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Delegate.java index e09b3436..567931d4 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Delegate.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8Delegate.java @@ -34,6 +34,15 @@ public class M3U8Delegate extends BaseDelegate mTaskWrapper.setRequestType(AbsTaskWrapper.M3U8_VOD); } + /** + * 生成m3u8索引文件,只有{@link #merge(boolean)}设置为false才会有效 + */ + @CheckResult(suggest = Suggest.TO_CONTROLLER) + public M3U8Delegate genetateIndexFile() { + mTaskWrapper.asM3U8().setGenerateIndexFile(true); + return this; + } + /** * 是否合并ts文件,默认合并ts * diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8TaskConfig.java b/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8TaskConfig.java index d4fd86e1..7699c923 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8TaskConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8TaskConfig.java @@ -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; } diff --git a/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java b/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java index 3c237ff0..66b46467 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java +++ b/app/src/main/java/com/arialyy/simple/core/download/HttpDownloadModule.java @@ -47,7 +47,8 @@ public class HttpDownloadModule extends BaseViewModule { * 单任务下载的信息 */ LiveData 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); diff --git a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java index 129ac520..03cb3488 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java @@ -274,7 +274,9 @@ public class SingleTaskActivity extends BaseActivity { 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: