From 9951f04bf67a577b228d732a62e980832996d6f5 Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Mon, 29 Jul 2019 20:30:49 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=B8=8B=E8=BD=BD=E4=BB=BB?= =?UTF-8?q?=E5=8A=A1=E6=9B=B4=E6=96=B0url=E5=A4=B1=E8=B4=A5=E7=9A=84?= =?UTF-8?q?=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aria/core/download/DNormalConfigHandler.java | 12 ++++-------- .../aria/core/download/m3u8/M3U8Delegate.java | 9 +++++++++ .../aria/core/download/m3u8/M3U8TaskConfig.java | 13 +++++++++++++ .../simple/core/download/HttpDownloadModule.java | 3 ++- .../simple/core/download/SingleTaskActivity.java | 4 +++- 5 files changed, 31 insertions(+), 10 deletions(-) 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: