laoyuyu 6 years ago
parent 703078e750
commit 2e4ad16f3e
  1. 1
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/AbsGroupUtil.java
  2. 28
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java
  3. 5
      Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java
  4. 5
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  5. 1
      DEV_LOG.md
  6. 4
      app/src/main/AndroidManifest.xml
  7. 3
      app/src/main/java/com/arialyy/simple/test/AnyRunActivity.java
  8. 4
      app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java
  9. 4
      app/src/main/res/values/strings.xml

@ -284,7 +284,6 @@ public abstract class AbsGroupUtil implements IUtil {
}
mTasksMap.put(te.getUrl(), te);
}
updateFileSize();
}
@Override public void start() {

@ -35,6 +35,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
private final String TAG = "DownloadGroupUtil";
private ExecutorService mInfoPool;
private int mInitCompleteNum, mInitFailNum;
private boolean isStop = false;
/**
* 文件信息回调组
@ -53,6 +54,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
@Override public void onCancel() {
super.onCancel();
isStop = true;
if (!mInfoPool.isShutdown()) {
mInfoPool.shutdown();
}
@ -60,6 +62,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
@Override protected void onStop() {
super.onStop();
isStop = true;
if (!mInfoPool.isShutdown()) {
mInfoPool.shutdown();
}
@ -67,6 +70,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
@Override protected void onStart() {
super.onStart();
isStop = false;
if (mCompleteNum == mGroupSize) {
mListener.onComplete();
return;
@ -83,7 +87,9 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
if (taskEntity != null) {
if (taskEntity.getState() != IEntity.STATE_FAIL
&& taskEntity.getState() != IEntity.STATE_WAIT) {
mInitCompleteNum++;
createChildDownload(taskEntity);
checkStartFlow();
} else {
mInfoPool.execute(createFileInfoThread(taskEntity));
}
@ -105,6 +111,7 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
int failNum = 0;
@Override public void onComplete(String url, CompleteInfo info) {
if (isStop) return;
DownloadTaskEntity te = mExeMap.get(url);
if (te != null) {
if (isNeedLoadFileSize) {
@ -114,13 +121,11 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
}
mInitCompleteNum++;
if (mInitCompleteNum + mInitFailNum >= mGroupSize || !isNeedLoadFileSize) {
startRunningFlow();
updateFileSize();
}
checkStartFlow();
}
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
if (isStop) return;
ALog.e(TAG, "任务【" + url + "】初始化失败。");
DownloadTaskEntity te = mExeMap.get(url);
if (te != null) {
@ -137,13 +142,22 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil {
//}
//failNum++;
mInitFailNum++;
checkStartFlow();
}
};
}
return new HttpFileInfoThread(taskEntity, callback);
}
/**
* 检查能否启动下载流程
*/
private void checkStartFlow() {
synchronized (DownloadGroupUtil.class) {
if (mInitCompleteNum + mInitFailNum >= mGroupSize || !isNeedLoadFileSize) {
startRunningFlow();
updateFileSize();
}
}
};
}
return new HttpFileInfoThread(taskEntity, callback);
}
}

@ -30,6 +30,7 @@ import java.lang.reflect.Field;
import java.net.URLDecoder;
import java.util.ArrayList;
import java.util.Date;
import java.util.LinkedHashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -217,8 +218,8 @@ class DelegateFind extends AbsDelegate {
}
List<T> wrappers = new ArrayList<>();
Map<Object, P> tempParent = new WeakHashMap<>(); // 所有父表元素,key为父表主键的值
Map<Object, List<C>> tempChild = new WeakHashMap<>(); // 所有的字表元素,key为父表主键的值
Map<Object, P> tempParent = new LinkedHashMap<>(); // 所有父表元素,key为父表主键的值
Map<Object, List<C>> tempChild = new LinkedHashMap<>(); // 所有的字表元素,key为父表主键的值
Object old = null;
while (cursor.moveToNext()) {

@ -888,11 +888,6 @@ public class CommonUtil {
ALog.w(TAG, "修改任务记录失败,新文件路径和旧文件路径一致");
return;
}
File oldFile = new File(oldPath);
if (!oldFile.exists()) {
ALog.w(TAG, "修改任务记录失败,文件【" + oldPath + "】不存在");
return;
}
TaskRecord record = DbHelper.getTaskRecord(oldPath);
if (record == null) {
ALog.w(TAG, "修改任务记录失败,文件【" + oldPath + "】对应的任务记录不存在");

@ -2,6 +2,7 @@
+ v_3.4.2
- 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/250
+ v_3.4.1
- 移除记录配置文件,改用数据库记录任务记录
- 上传配置添加io超时时间、缓存大小配置

@ -16,9 +16,9 @@
android:theme="@style/AppTheme.NoActionBar">
<!--android:name=".test.TestGroupActivity"-->
<!--android:name=".test.TestActivity"-->
<!--android:name=".MainActivity"-->
<!--android:name=".test.AnyRunActivity"-->
<activity
android:name=".test.AnyRunActivity"
android:name=".MainActivity"
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -19,7 +19,8 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
String[] urls;
int index = 0;
//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";
//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";

@ -38,7 +38,7 @@ public class AnyRunnModule {
}
@Download.onTaskRunning protected void running(DownloadTask task) {
Log.d(TAG, "running");
Log.d(TAG, "running;Percent = " + task.getPercent());
}
@Download.onTaskResume void taskResume(DownloadTask task) {
@ -68,7 +68,7 @@ public class AnyRunnModule {
.load(url)
//.addHeader("Accept-Encoding", "gzip")
.setRequestMode(RequestEnum.GET)
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg12345678.apk")
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/abcd.mp4")
//.resetState()
.start();
//String[] urls = new String[] {

@ -64,7 +64,7 @@
</string-array>
<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>http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk</item>
</string-array>
@ -81,7 +81,7 @@
<string-array name="group_names">
<!--<item>王者荣耀.apk</item>-->
<!--<item>战斗吧剑灵.apk</item>-->
<item>战斗吧剑灵.apk</item>
<item>天魔幻想.apk</item>
</string-array>

Loading…
Cancel
Save