laoyuyu 5 years ago
parent 1ee36e0bc1
commit 846235a826
  1. 25
      Aria/src/main/java/com/arialyy/aria/core/command/ResumeAllCmd.java
  2. 22
      Aria/src/main/java/com/arialyy/aria/core/command/ResumeThread.java
  3. 3
      Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java
  4. 2
      README.md
  5. 2
      app/src/main/java/com/arialyy/simple/core/download/SingleTaskActivity.java
  6. 2
      build.gradle

@ -16,29 +16,10 @@
package com.arialyy.aria.core.command;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.inf.IOptionConstant;
import com.arialyy.aria.core.manager.TaskWrapperManager;
import com.arialyy.aria.core.queue.DGroupTaskQueue;
import com.arialyy.aria.core.queue.DTaskQueue;
import com.arialyy.aria.core.queue.UTaskQueue;
import com.arialyy.aria.core.task.AbsTask;
import com.arialyy.aria.core.upload.UTaskWrapper;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.NetUtils;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.Executors;
/**
* Created by AriaL on 2017/6/13.
@ -50,7 +31,6 @@ import java.util.concurrent.Executors;
*/
final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
ResumeAllCmd(T entity, int taskType) {
super(entity, taskType);
}
@ -60,8 +40,7 @@ final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
ALog.w(TAG, "恢复任务失败,网络未连接");
return;
}
new Thread(new ResumeThread(isDownloadCmd, IEntity.STATE_COMPLETE)).start();
new Thread(new ResumeThread(isDownloadCmd,
String.format("state!=%s", IEntity.STATE_COMPLETE))).start();
}
}

@ -47,11 +47,11 @@ public class ResumeThread implements Runnable {
private String TAG = CommonUtil.getClassName(getClass());
private List<AbsTaskWrapper> mWaitList = new ArrayList<>();
private boolean isDownloadCmd;
private int excludeState;
private String sqlCondition;
ResumeThread(boolean isDownload, int excludeState) {
ResumeThread(boolean isDownload, String sqlCondition) {
this.isDownloadCmd = isDownload;
this.excludeState = excludeState;
this.sqlCondition = sqlCondition;
}
/**
@ -63,8 +63,8 @@ public class ResumeThread implements Runnable {
if (type == 1) {
List<DownloadEntity> entities =
DbEntity.findDatas(DownloadEntity.class,
"isGroupChild=? AND state!=? ORDER BY stopTime DESC", "false",
String.valueOf(excludeState));
String.format("NOT(isGroupChild) AND NOT(isComplete) AND %s ORDER BY stopTime DESC",
sqlCondition));
if (entities != null && !entities.isEmpty()) {
for (DownloadEntity entity : entities) {
addResumeEntity(TaskWrapperManager.getInstance()
@ -73,8 +73,9 @@ public class ResumeThread implements Runnable {
}
} else if (type == 2) {
List<DownloadGroupEntity> entities =
DbEntity.findDatas(DownloadGroupEntity.class, "state!=? ORDER BY stopTime DESC",
String.valueOf(excludeState));
DbEntity.findDatas(DownloadGroupEntity.class,
String.format("NOT(isComplete) AND %s ORDER BY stopTime DESC",
sqlCondition));
if (entities != null && !entities.isEmpty()) {
for (DownloadGroupEntity entity : entities) {
addResumeEntity(
@ -84,8 +85,9 @@ public class ResumeThread implements Runnable {
}
} else if (type == 3) {
List<UploadEntity> entities =
DbEntity.findDatas(UploadEntity.class, "state!=? ORDER BY stopTime DESC",
String.valueOf(excludeState));
DbEntity.findDatas(UploadEntity.class,
String.format("NOT(isComplete) AND %s ORDER BY stopTime DESC",
sqlCondition));
if (entities != null && !entities.isEmpty()) {
for (UploadEntity entity : entities) {
addResumeEntity(TaskWrapperManager.getInstance()
@ -125,7 +127,7 @@ public class ResumeThread implements Runnable {
queue = DGroupTaskQueue.getInstance();
}
if (queue == null){
if (queue == null) {
ALog.e(TAG, "任务类型错误");
continue;
}

@ -91,6 +91,7 @@ final class StartCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
* 当缓冲队列为null时查找数据库中所有等待中的任务
*/
private void findAllWaitTask() {
new Thread(new ResumeThread(isDownloadCmd, IEntity.STATE_WAIT)).start();
new Thread(
new ResumeThread(isDownloadCmd, String.format("state=%s", IEntity.STATE_WAIT))).start();
}
}

@ -137,7 +137,7 @@ protected void onCreate(Bundle savedInstanceState) {
### 版本日志
+ v_v_3.7.8-pre-1 (2019/11/20)
+ 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)

@ -277,7 +277,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
Aria.download(this).load(mTaskId).stop();
} else {
Aria.download(this).load(mTaskId)
//.updateUrl("http://sdkdown.muzhiwan.com/openfile/2019/07/11/com.netease.syfz.mzw_5d26f8d9cee27.apk")
.updateUrl("http://sdkdown.muzhiwan.com/openfile/2019/07/11/com.netease.syfz.mzw_5d26f8d9cee27.apk")
.resume();
}
break;

@ -45,7 +45,7 @@ task clean(type: Delete) {
ext {
versionCode = 378
versionName = '3.7.8-pre-1'
versionName = '3.7.8-pre-3'
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = versionName

Loading…
Cancel
Save