From 1ee36e0bc1ec9cf3dfe318abbc1c32390dd4a08a Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Wed, 20 Nov 2019 21:33:48 +0800 Subject: [PATCH] fix bug https://github.com/AriaLyy/Aria/issues/526 --- DEV_LOG.md | 2 ++ .../aria/ftp/download/FtpDirDLoaderUtil.java | 2 ++ .../aria/http/download/DGroupLoaderUtil.java | 1 + .../arialyy/aria/m3u8/vod/M3U8VodLoader.java | 8 +++--- .../arialyy/aria/core/group/AbsGroupUtil.java | 3 +-- .../aria/core/group/AbsSubDLoadUtil.java | 26 ------------------- .../aria/core/group/GroupRunState.java | 8 +++--- README.md | 21 +++++++-------- SFtpComponent/build.gradle | 2 +- app/src/main/AndroidManifest.xml | 1 + .../core/download/HttpDownloadModule.java | 5 ++-- .../core/download/group/GroupModule.java | 8 +++--- .../download/m3u8/M3U8VodDLoadActivity.java | 7 +++-- .../core/download/m3u8/M3U8VodModule.java | 5 ++-- build.gradle | 4 +-- 15 files changed, 44 insertions(+), 59 deletions(-) diff --git a/DEV_LOG.md b/DEV_LOG.md index cc6b7ec2..6d99e34d 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,6 @@ ## 开发日志 + + v_3.7.8-pre-1(2019/11/20) + - fix bug https://github.com/AriaLyy/Aria/issues/526 + v_3.7.7 (2019/11/20) - 修复ftp无法完成下载的问题 - 修复一个http下载崩溃的问题 diff --git a/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDirDLoaderUtil.java b/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDirDLoaderUtil.java index 57c2675f..9344f982 100644 --- a/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDirDLoaderUtil.java +++ b/FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDirDLoaderUtil.java @@ -85,6 +85,8 @@ public class FtpDirDLoaderUtil extends AbsGroupUtil { * @param needCloneInfo 第一次下载,信息已经在{@link FtpDirInfoThread}中clone了 */ private void startDownload(boolean needCloneInfo) { + // ftp需要获取完成只任务信息才更新只任务数量 + getState().setSubSize(getWrapper().getSubTaskWrapper().size()); try { LOCK.lock(); condition.signalAll(); diff --git a/HttpComponent/src/main/java/com/arialyy/aria/http/download/DGroupLoaderUtil.java b/HttpComponent/src/main/java/com/arialyy/aria/http/download/DGroupLoaderUtil.java index b4dc143e..fc66b55a 100644 --- a/HttpComponent/src/main/java/com/arialyy/aria/http/download/DGroupLoaderUtil.java +++ b/HttpComponent/src/main/java/com/arialyy/aria/http/download/DGroupLoaderUtil.java @@ -73,6 +73,7 @@ public class DGroupLoaderUtil extends AbsGroupUtil { @Override protected boolean onStart() { super.onStart(); + getState().setSubSize(getWrapper().getSubTaskWrapper().size()); if (getState().getCompleteNum() == getState().getSubSize()) { mListener.onComplete(); } else { diff --git a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java index dba71cc0..86a2ceb5 100644 --- a/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java +++ b/M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java @@ -463,7 +463,8 @@ public class M3U8VodLoader extends BaseM3U8Loader { private int cancelNum = 0; // 已经取消的线程的数 private int stopNum = 0; // 已经停止的线程数 private int failNum = 0; // 失败的线程数 - private long progress; //当前总进度,百分比进度 + private long percent; //当前总进度,百分比进度 + private long progress; private TaskRecord taskRecord; // 任务记录 private Looper looper; @@ -480,6 +481,7 @@ public class M3U8VodLoader extends BaseM3U8Loader { } } this.listener = listener; + progress = getEntity().getCurrentProgress(); } private void updateStateCount() { @@ -586,7 +588,7 @@ public class M3U8VodLoader extends BaseM3U8Loader { } break; case STATE_RUNNING: - //progress += (long) msg.obj; + progress += (long) msg.obj; break; } return true; @@ -610,7 +612,7 @@ public class M3U8VodLoader extends BaseM3U8Loader { int percent = completeNum * 100 / taskRecord.threadRecords.size(); getEntity().setPercent(percent); getEntity().update(); - progress = percent; + this.percent = percent; } @Override public boolean isFail() { diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupUtil.java index 0b1999a8..12e8bdce 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupUtil.java @@ -81,8 +81,7 @@ public abstract class AbsGroupUtil implements IUtil, Runnable { * 初始化组合任务状态 */ private void initState() { - mState = new GroupRunState(getWrapper().getKey(), mListener, - mGTWrapper.getSubTaskWrapper().size(), mSubQueue); + mState = new GroupRunState(getWrapper().getKey(), mListener, mSubQueue); for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) { if (wrapper.getEntity().getState() == IEntity.STATE_COMPLETE) { mState.updateCompleteNum(); diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsSubDLoadUtil.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsSubDLoadUtil.java index 2de7fad6..359c554a 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsSubDLoadUtil.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsSubDLoadUtil.java @@ -112,30 +112,4 @@ public abstract class AbsSubDLoadUtil implements IUtil { mSchedulers.obtainMessage(ISchedulers.STOP, this).sendToTarget(); } } - - //@Override public void start() { - // if (mWrapper.getRequestType() == ITaskWrapper.D_HTTP) { - // if (needGetInfo) { - // new Thread(new HttpFileInfoThread(mWrapper, new OnFileInfoCallback() { - // - // @Override public void onComplete(String url, CompleteInfo info) { - // mDLoader = new Downloader(mListener, mWrapper); - // mDLoader.start(); - // } - // - // @Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) { - // mSchedulers.obtainMessage(ISchedulers.FAIL, SubDLoadUtil.this).sendToTarget(); - // } - // })).start(); - // } else { - // mDLoader = new Downloader(mListener, mWrapper); - // mDLoader.start(); - // } - // } else if (mWrapper.getRequestType() == ITaskWrapper.D_FTP) { - // mDLoader = new Downloader(mListener, mWrapper); - // mDLoader.start(); - // } else { - // ALog.w(TAG, String.format("不识别的类型,requestType:%s", mWrapper.getRequestType())); - // } - //} } diff --git a/PublicComponent/src/main/java/com/arialyy/aria/core/group/GroupRunState.java b/PublicComponent/src/main/java/com/arialyy/aria/core/group/GroupRunState.java index 8d68a9a8..dee9834f 100644 --- a/PublicComponent/src/main/java/com/arialyy/aria/core/group/GroupRunState.java +++ b/PublicComponent/src/main/java/com/arialyy/aria/core/group/GroupRunState.java @@ -72,14 +72,16 @@ public class GroupRunState { private String mGroupHash; - GroupRunState(String groupHash, IDGroupListener listener, int subSize, - SimpleSubQueue queue) { + GroupRunState(String groupHash, IDGroupListener listener, SimpleSubQueue queue) { this.listener = listener; this.queue = queue; - mSubSize = subSize; mGroupHash = groupHash; } + public void setSubSize(int subSize){ + mSubSize = subSize; + } + /** * 组合任务是否正在自行 * diff --git a/README.md b/README.md index ee2e70ce..9625c201 100644 --- a/README.md +++ b/README.md @@ -44,16 +44,16 @@ Aria有以下特点: ## 引入库 [![license](http://img.shields.io/badge/license-Apache2.0-brightgreen.svg?style=flat)](https://github.com/AriaLyy/Aria/blob/master/LICENSE) -[![Core](https://img.shields.io/badge/Core-3.7.7-blue)](https://github.com/AriaLyy/Aria) -[![Compiler](https://img.shields.io/badge/Compiler-3.7.7-blue)](https://github.com/AriaLyy/Aria) -[![FtpComponent](https://img.shields.io/badge/FtpComponent-3.7.7-orange)](https://github.com/AriaLyy/Aria) -[![M3U8Component](https://img.shields.io/badge/M3U8Component-3.7.7-orange)](https://github.com/AriaLyy/Aria) +[![Core](https://img.shields.io/badge/Core-v_3.7.8-pre-1-blue)](https://github.com/AriaLyy/Aria) +[![Compiler](https://img.shields.io/badge/Compiler-v_3.7.8-pre-1-blue)](https://github.com/AriaLyy/Aria) +[![FtpComponent](https://img.shields.io/badge/FtpComponent-v_3.7.8-pre-1-orange)](https://github.com/AriaLyy/Aria) +[![M3U8Component](https://img.shields.io/badge/M3U8Component-v_3.7.8-pre-1-orange)](https://github.com/AriaLyy/Aria) ```java -implementation 'com.arialyy.aria:core:3.7.7' -annotationProcessor 'com.arialyy.aria:compiler:3.7.7' -implementation 'com.arialyy.aria:ftpComponent:3.7.7' # 如果需要使用ftp,请增加该组件 -implementation 'com.arialyy.aria:m3u8Component:3.7.7' # 如果需要使用m3u8下载功能,请增加该组件 +implementation 'com.arialyy.aria:core:v_3.7.8-pre-1' +annotationProcessor 'com.arialyy.aria:compiler:v_3.7.8-pre-1' +implementation 'com.arialyy.aria:ftpComponent:v_3.7.8-pre-1' # 如果需要使用ftp,请增加该组件 +implementation 'com.arialyy.aria:m3u8Component:v_3.7.8-pre-1' # 如果需要使用m3u8下载功能,请增加该组件 ``` 如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:'`替换为 ``` @@ -137,9 +137,8 @@ protected void onCreate(Bundle savedInstanceState) { ### 版本日志 - + v_3.7.7 (2019/11/20) - - 修复ftp无法完成下载的问题 - - 修复一个http下载崩溃的问题 + + v_v_3.7.8-pre-1 (2019/11/20) + - fix bug https://github.com/AriaLyy/Aria/issues/526 [更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md) diff --git a/SFtpComponent/build.gradle b/SFtpComponent/build.gradle index 193b7be6..9aa5c8cd 100644 --- a/SFtpComponent/build.gradle +++ b/SFtpComponent/build.gradle @@ -29,5 +29,5 @@ dependencies { implementation "com.jcraft:jsch:0.1.55" implementation "com.jcraft:jzlib:1.1.3" implementation project(path: ':FtpComponent') - compile project(path: ':PublicComponent') + implementation project(path: ':PublicComponent') } diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index b577538a..058ff739 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -1,6 +1,7 @@ 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 3bf0637a..ba978f03 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 @@ -39,7 +39,7 @@ public class HttpDownloadModule extends BaseViewModule { //"http://202.98.201.103:7000/vrs/TPK/ZTC440402001Z.tpk"; private final String defFilePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() - + "/TOTWOO-v3.5.6.apk"; + + "/tttt.apk"; private MutableLiveData liveData = new MutableLiveData<>(); private DownloadEntity singDownloadInfo; @@ -51,7 +51,8 @@ public class HttpDownloadModule extends BaseViewModule { //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 url = "http://image.totwoo.com/totwoo-TOTWOO-v3.5.6.apk"; + String url = "https://imtt.dd.qq.com/16891/apk/70BFFDB05AB8686F2A4CF3E07588A377.apk?fsname=com.tencent.tmgp.speedmobile_1.16.0.33877_1160033877.apk&csr=1bbd"; //String url = "https://ss1.baidu.com/-4o3dSag_xI4khGko9WTAnF6hhy/image/h%3D300/sign=a9e671b9a551f3dedcb2bf64a4eff0ec/4610b912c8fcc3cef70d70409845d688d53f20f7.jpg"; String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath); diff --git a/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java b/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java index ae01bf21..d35708f4 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java +++ b/app/src/main/java/com/arialyy/simple/core/download/group/GroupModule.java @@ -32,10 +32,10 @@ public class GroupModule extends BaseModule { public List getUrls() { List urls = new ArrayList<>(); - urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924275&di=a7ea1497a4a2528a45ce7103bf61adf4&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fc2cec3fdfc03924590b2a9b58d94a4c27d1e2500.jpg"); - urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924272&di=7861479e7cb3cea98d585eaf108f056f&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F562c11dfa9ec8a13c0741f5afd03918fa0ecc01a.jpg"); - //String[] str = getContext().getResources().getStringArray(R.array.group_urls_1); - //Collections.addAll(urls, str); + //urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924275&di=a7ea1497a4a2528a45ce7103bf61adf4&imgtype=0&src=http%3A%2F%2Fg.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2Fc2cec3fdfc03924590b2a9b58d94a4c27d1e2500.jpg"); + //urls.add("https://timgsa.baidu.com/timg?image&quality=80&size=b9999_10000&sec=1574141924272&di=7861479e7cb3cea98d585eaf108f056f&imgtype=0&src=http%3A%2F%2Fd.hiphotos.baidu.com%2Fimage%2Fpic%2Fitem%2F562c11dfa9ec8a13c0741f5afd03918fa0ecc01a.jpg"); + String[] str = getContext().getResources().getStringArray(R.array.group_urls_1); + Collections.addAll(urls, str); return urls; } diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java index 3f27fcfd..9a3eaf09 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java +++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java @@ -308,7 +308,7 @@ public class M3U8VodDLoadActivity extends BaseActivity { //.merge(true) .setVodTsUrlConvert(new VodTsUrlConverter()); //.setMergeHandler(new TsMergeHandler()); - //.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl)); + option.setBandWidthUrlConverter(new BandWidthUrlConverter(mUrl)); return option; } @@ -324,7 +324,10 @@ public class M3U8VodDLoadActivity extends BaseActivity { static class VodTsUrlConverter implements IVodTsUrlConverter { @Override public List convert(String m3u8Url, List tsUrls) { Uri uri = Uri.parse(m3u8Url); - String parentUrl = "http://" + uri.getHost(); + //String parentUrl = "http://" + uri.getHost() + "/gear1/"; + int index = m3u8Url.lastIndexOf("/"); + String parentUrl = m3u8Url.substring(0, index + 1); + //String parentUrl = "http://" + uri.getHost() + "/"; List newUrls = new ArrayList<>(); for (String url : tsUrls) { newUrls.add(parentUrl + url); diff --git a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java index 0a9c37cf..979ea085 100644 --- a/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java +++ b/app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodModule.java @@ -34,9 +34,8 @@ public class M3U8VodModule extends BaseViewModule { // m3u8测试集合:http://www.voidcn.com/article/p-snaliarm-ct.html //private final String defUrl = "https://www.gaoya123.cn/2019/1557993797897.m3u8"; // 多码率地址: - //private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"; - //private final String defUrl = "http://cn1.fa1244.cn/hls/20190516/6d271eaa73b2e4cb51d13831b0c1ab4c/1557976262/index.m3u8"; - private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8"; + private final String defUrl = "http://devimages.apple.com/iphone/samples/bipbop/bipbopall.m3u8"; + //private final String defUrl = "http://qn.shytong.cn/b83137769ff6b555/11b0c9970f9a3fa0.mp4.m3u8"; private final String filePath = Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath() //+ "/道士下山.ts"; diff --git a/build.gradle b/build.gradle index 59427992..b6cecc15 100644 --- a/build.gradle +++ b/build.gradle @@ -44,8 +44,8 @@ task clean(type: Delete) { } ext { - versionCode = 377 - versionName = '3.7.7' + versionCode = 378 + versionName = '3.7.8-pre-1' userOrg = 'arialyy' groupId = 'com.arialyy.aria' publishVersion = versionName