This commit is contained in:
@@ -284,7 +284,6 @@ public abstract class AbsGroupUtil implements IUtil {
|
|||||||
}
|
}
|
||||||
mTasksMap.put(te.getUrl(), te);
|
mTasksMap.put(te.getUrl(), te);
|
||||||
}
|
}
|
||||||
updateFileSize();
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void start() {
|
@Override public void start() {
|
||||||
|
|||||||
@@ -35,6 +35,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
private final String TAG = "DownloadGroupUtil";
|
private final String TAG = "DownloadGroupUtil";
|
||||||
private ExecutorService mInfoPool;
|
private ExecutorService mInfoPool;
|
||||||
private int mInitCompleteNum, mInitFailNum;
|
private int mInitCompleteNum, mInitFailNum;
|
||||||
|
private boolean isStop = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 文件信息回调组
|
* 文件信息回调组
|
||||||
@@ -53,6 +54,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
|
|
||||||
@Override public void onCancel() {
|
@Override public void onCancel() {
|
||||||
super.onCancel();
|
super.onCancel();
|
||||||
|
isStop = true;
|
||||||
if (!mInfoPool.isShutdown()) {
|
if (!mInfoPool.isShutdown()) {
|
||||||
mInfoPool.shutdown();
|
mInfoPool.shutdown();
|
||||||
}
|
}
|
||||||
@@ -60,6 +62,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
|
|
||||||
@Override protected void onStop() {
|
@Override protected void onStop() {
|
||||||
super.onStop();
|
super.onStop();
|
||||||
|
isStop = true;
|
||||||
if (!mInfoPool.isShutdown()) {
|
if (!mInfoPool.isShutdown()) {
|
||||||
mInfoPool.shutdown();
|
mInfoPool.shutdown();
|
||||||
}
|
}
|
||||||
@@ -67,6 +70,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
|
|
||||||
@Override protected void onStart() {
|
@Override protected void onStart() {
|
||||||
super.onStart();
|
super.onStart();
|
||||||
|
isStop = false;
|
||||||
if (mCompleteNum == mGroupSize) {
|
if (mCompleteNum == mGroupSize) {
|
||||||
mListener.onComplete();
|
mListener.onComplete();
|
||||||
return;
|
return;
|
||||||
@@ -83,7 +87,9 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
if (taskEntity != null) {
|
if (taskEntity != null) {
|
||||||
if (taskEntity.getState() != IEntity.STATE_FAIL
|
if (taskEntity.getState() != IEntity.STATE_FAIL
|
||||||
&& taskEntity.getState() != IEntity.STATE_WAIT) {
|
&& taskEntity.getState() != IEntity.STATE_WAIT) {
|
||||||
|
mInitCompleteNum++;
|
||||||
createChildDownload(taskEntity);
|
createChildDownload(taskEntity);
|
||||||
|
checkStartFlow();
|
||||||
} else {
|
} else {
|
||||||
mInfoPool.execute(createFileInfoThread(taskEntity));
|
mInfoPool.execute(createFileInfoThread(taskEntity));
|
||||||
}
|
}
|
||||||
@@ -105,6 +111,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
int failNum = 0;
|
int failNum = 0;
|
||||||
|
|
||||||
@Override public void onComplete(String url, CompleteInfo info) {
|
@Override public void onComplete(String url, CompleteInfo info) {
|
||||||
|
if (isStop) return;
|
||||||
DownloadTaskEntity te = mExeMap.get(url);
|
DownloadTaskEntity te = mExeMap.get(url);
|
||||||
if (te != null) {
|
if (te != null) {
|
||||||
if (isNeedLoadFileSize) {
|
if (isNeedLoadFileSize) {
|
||||||
@@ -112,15 +119,13 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
}
|
}
|
||||||
createChildDownload(te);
|
createChildDownload(te);
|
||||||
}
|
}
|
||||||
mInitCompleteNum ++;
|
mInitCompleteNum++;
|
||||||
|
|
||||||
if (mInitCompleteNum + mInitFailNum >= mGroupSize || !isNeedLoadFileSize) {
|
checkStartFlow();
|
||||||
startRunningFlow();
|
|
||||||
updateFileSize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||||
|
if (isStop) return;
|
||||||
ALog.e(TAG, "任务【" + url + "】初始化失败。");
|
ALog.e(TAG, "任务【" + url + "】初始化失败。");
|
||||||
DownloadTaskEntity te = mExeMap.get(url);
|
DownloadTaskEntity te = mExeMap.get(url);
|
||||||
if (te != null) {
|
if (te != null) {
|
||||||
@@ -136,14 +141,23 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
// mInitFailNum++;
|
// mInitFailNum++;
|
||||||
//}
|
//}
|
||||||
//failNum++;
|
//failNum++;
|
||||||
mInitFailNum ++;
|
mInitFailNum++;
|
||||||
if (mInitCompleteNum + mInitFailNum >= mGroupSize || !isNeedLoadFileSize) {
|
checkStartFlow();
|
||||||
startRunningFlow();
|
|
||||||
updateFileSize();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
return new HttpFileInfoThread(taskEntity, callback);
|
return new HttpFileInfoThread(taskEntity, callback);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 检查能否启动下载流程
|
||||||
|
*/
|
||||||
|
private void checkStartFlow() {
|
||||||
|
synchronized (DownloadGroupUtil.class) {
|
||||||
|
if (mInitCompleteNum + mInitFailNum >= mGroupSize || !isNeedLoadFileSize) {
|
||||||
|
startRunningFlow();
|
||||||
|
updateFileSize();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -30,6 +30,7 @@ import java.lang.reflect.Field;
|
|||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
@@ -217,8 +218,8 @@ class DelegateFind extends AbsDelegate {
|
|||||||
}
|
}
|
||||||
|
|
||||||
List<T> wrappers = new ArrayList<>();
|
List<T> wrappers = new ArrayList<>();
|
||||||
Map<Object, P> tempParent = new WeakHashMap<>(); // 所有父表元素,key为父表主键的值
|
Map<Object, P> tempParent = new LinkedHashMap<>(); // 所有父表元素,key为父表主键的值
|
||||||
Map<Object, List<C>> tempChild = new WeakHashMap<>(); // 所有的字表元素,key为父表主键的值
|
Map<Object, List<C>> tempChild = new LinkedHashMap<>(); // 所有的字表元素,key为父表主键的值
|
||||||
|
|
||||||
Object old = null;
|
Object old = null;
|
||||||
while (cursor.moveToNext()) {
|
while (cursor.moveToNext()) {
|
||||||
|
|||||||
@@ -888,11 +888,6 @@ public class CommonUtil {
|
|||||||
ALog.w(TAG, "修改任务记录失败,新文件路径和旧文件路径一致");
|
ALog.w(TAG, "修改任务记录失败,新文件路径和旧文件路径一致");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
File oldFile = new File(oldPath);
|
|
||||||
if (!oldFile.exists()) {
|
|
||||||
ALog.w(TAG, "修改任务记录失败,文件【" + oldPath + "】不存在");
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
TaskRecord record = DbHelper.getTaskRecord(oldPath);
|
TaskRecord record = DbHelper.getTaskRecord(oldPath);
|
||||||
if (record == null) {
|
if (record == null) {
|
||||||
ALog.w(TAG, "修改任务记录失败,文件【" + oldPath + "】对应的任务记录不存在");
|
ALog.w(TAG, "修改任务记录失败,文件【" + oldPath + "】对应的任务记录不存在");
|
||||||
|
|||||||
@@ -2,6 +2,7 @@
|
|||||||
+ v_3.4.2
|
+ v_3.4.2
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/248
|
- fix bug https://github.com/AriaLyy/Aria/issues/248
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/247
|
- fix bug https://github.com/AriaLyy/Aria/issues/247
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/250
|
||||||
+ v_3.4.1
|
+ v_3.4.1
|
||||||
- 移除记录配置文件,改用数据库记录任务记录
|
- 移除记录配置文件,改用数据库记录任务记录
|
||||||
- 上传配置添加io超时时间、缓存大小配置
|
- 上传配置添加io超时时间、缓存大小配置
|
||||||
|
|||||||
@@ -16,9 +16,9 @@
|
|||||||
android:theme="@style/AppTheme.NoActionBar">
|
android:theme="@style/AppTheme.NoActionBar">
|
||||||
<!--android:name=".test.TestGroupActivity"-->
|
<!--android:name=".test.TestGroupActivity"-->
|
||||||
<!--android:name=".test.TestActivity"-->
|
<!--android:name=".test.TestActivity"-->
|
||||||
<!--android:name=".MainActivity"-->
|
<!--android:name=".test.AnyRunActivity"-->
|
||||||
<activity
|
<activity
|
||||||
android:name=".test.AnyRunActivity"
|
android:name=".MainActivity"
|
||||||
android:label="@string/app_name">
|
android:label="@string/app_name">
|
||||||
<intent-filter>
|
<intent-filter>
|
||||||
<action android:name="android.intent.action.MAIN"/>
|
<action android:name="android.intent.action.MAIN"/>
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
|
|||||||
String[] urls;
|
String[] urls;
|
||||||
int index = 0;
|
int index = 0;
|
||||||
//String URL = "http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk";
|
//String URL = "http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk";
|
||||||
String URL = "http://d1.showself.com/download/showself_android-s236279_release.apk";
|
String URL = "http://58.213.157.242:8081/sims_file/rest/v1/file/mshd_touchscreen_ms/guideFile/41c33556-dc4a-4d78-bb76-b9f627f94448.mp4/%E5%85%AB%E5%8D%A6%E6%B4%B2%E5%8D%97%E4%BA%AC%E5%86%9C%E4%B8%9A%E5%98%89%E5%B9%B4%E5%8D%8E0511.mp4";
|
||||||
|
//String URL = "http://d1.showself.com/download/showself_android-s236279_release.apk";
|
||||||
//String URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
//String URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
||||||
//private final String URL = "ftp://192.168.29.140:21/download/AriaPrj.rar";
|
//private final String URL = "ftp://192.168.29.140:21/download/AriaPrj.rar";
|
||||||
//String URL = "https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
|
//String URL = "https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class AnyRunnModule {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskRunning protected void running(DownloadTask task) {
|
@Download.onTaskRunning protected void running(DownloadTask task) {
|
||||||
Log.d(TAG, "running");
|
Log.d(TAG, "running;Percent = " + task.getPercent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskResume void taskResume(DownloadTask task) {
|
@Download.onTaskResume void taskResume(DownloadTask task) {
|
||||||
@@ -68,7 +68,7 @@ public class AnyRunnModule {
|
|||||||
.load(url)
|
.load(url)
|
||||||
//.addHeader("Accept-Encoding", "gzip")
|
//.addHeader("Accept-Encoding", "gzip")
|
||||||
.setRequestMode(RequestEnum.GET)
|
.setRequestMode(RequestEnum.GET)
|
||||||
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg12345678.apk")
|
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/abcd.mp4")
|
||||||
//.resetState()
|
//.resetState()
|
||||||
.start();
|
.start();
|
||||||
//String[] urls = new String[] {
|
//String[] urls = new String[] {
|
||||||
|
|||||||
@@ -64,7 +64,7 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="group_urls_1">
|
<string-array name="group_urls_1">
|
||||||
<!--<item>http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk</item>-->
|
<item>http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk</item>
|
||||||
<!--<item>https://atom-installer.github.com/v1.13.0/AtomSetup.exe</item>-->
|
<!--<item>https://atom-installer.github.com/v1.13.0/AtomSetup.exe</item>-->
|
||||||
<item>http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk</item>
|
<item>http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
@@ -81,7 +81,7 @@
|
|||||||
|
|
||||||
<string-array name="group_names">
|
<string-array name="group_names">
|
||||||
<!--<item>王者荣耀.apk</item>-->
|
<!--<item>王者荣耀.apk</item>-->
|
||||||
<!--<item>战斗吧剑灵.apk</item>-->
|
<item>战斗吧剑灵.apk</item>
|
||||||
<item>天魔幻想.apk</item>
|
<item>天魔幻想.apk</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user