diff --git a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java index 84e0e80b..8adb564d 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java +++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java @@ -130,7 +130,7 @@ import org.xml.sax.SAXException; DownloadEntity.class, UploadEntity.class, DownloadGroupEntity.class, DownloadTaskEntity.class, UploadTaskEntity.class, DownloadGroupTaskEntity.class }; - String sql = "UPDATE %s SET state=2 WHERE state=4"; + String sql = "UPDATE %s SET state=2 WHERE state in (3,4,5,6)"; for (Class clazz : clazzs) { String temp = String.format(sql, clazz.getSimpleName()); DbEntity.exeSql(temp); diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java index 3ef585b1..256fb3d3 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java @@ -23,6 +23,7 @@ import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.inf.AbsEntity; import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTaskEntity; +import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.manager.TEManager; import com.arialyy.aria.core.queue.DownloadGroupTaskQueue; import com.arialyy.aria.core.queue.DownloadTaskQueue; @@ -83,7 +84,7 @@ public abstract class AbsNormalCmd extends AbsCmd { */ void sendWaitState() { if (tempTask != null) { - tempTask.getOutHandler().obtainMessage(ISchedulers.WAIT, tempTask).sendToTarget(); + sendWaitState(tempTask); } } @@ -92,6 +93,9 @@ public abstract class AbsNormalCmd extends AbsCmd { */ void sendWaitState(AbsTask task) { if (task != null) { + task.getTaskEntity().getEntity().setState(IEntity.STATE_WAIT); + task.getTaskEntity().setState(IEntity.STATE_WAIT); + task.getTaskEntity().update(); task.getOutHandler().obtainMessage(ISchedulers.WAIT, task).sendToTarget(); } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java index 511c8d10..1e6b0484 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java @@ -38,9 +38,7 @@ import java.util.ArrayList; import java.util.List; /** - * Created by lyy on 2016/8/22. - * 开始命令 - * 队列模型{@link QueueMod#NOW}、{@link QueueMod#WAIT} + * Created by lyy on 2016/8/22. 开始命令 队列模型{@link QueueMod#NOW}、{@link QueueMod#WAIT} */ class StartCmd extends AbsNormalCmd { @@ -70,13 +68,18 @@ class StartCmd extends AbsNormalCmd { if (mod.equals(QueueMod.NOW.getTag())) { startTask(); } else if (mod.equals(QueueMod.WAIT.getTag())) { - if (mQueue.getCurrentExePoolNum() < maxTaskNum - || task.getState() == IEntity.STATE_STOP - || task.getState() == IEntity.STATE_FAIL - || task.getState() == IEntity.STATE_OTHER - || task.getState() == IEntity.STATE_POST_PRE - || task.getState() == IEntity.STATE_COMPLETE) { - resumeTask(); + int state = task.getState(); + if (mQueue.getCurrentExePoolNum() < maxTaskNum){ + if (state == IEntity.STATE_STOP + || task.getState() == IEntity.STATE_FAIL + || task.getState() == IEntity.STATE_OTHER + || task.getState() == IEntity.STATE_PRE + || task.getState() == IEntity.STATE_POST_PRE + || task.getState() == IEntity.STATE_COMPLETE) { + resumeTask(); + }else { + startTask(); + } } else { sendWaitState(task); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java b/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java index 5726af54..ef997792 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java @@ -45,7 +45,7 @@ public class BaseDListener extends BaseListener { */ void stop(int type); + /** + * 删除任务 + */ void cancel(); /** diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java index feb8582e..509eaf8f 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java @@ -29,14 +29,13 @@ import java.util.Map; import java.util.Set; /** - * Created by lyy on 2017/2/23. - * 任务队列 + * Created by lyy on 2017/2/23. 任务队列 */ abstract class AbsTaskQueue implements ITaskQueue { - protected final int TYPE_D_QUEUE = 1; - protected final int TYPE_DG_QUEUE = 2; - protected final int TYPE_U_QUEUE = 3; + final int TYPE_D_QUEUE = 1; + final int TYPE_DG_QUEUE = 2; + final int TYPE_U_QUEUE = 3; private final String TAG = "AbsTaskQueue"; BaseCachePool mCachePool; @@ -63,9 +62,7 @@ abstract class AbsTaskQueue reTryNum) { - callback(FAIL, task); mQueue.removeTaskFormQueue(task.getKey()); startNextTask(task); TEManager.getInstance().removeTEntity(task.getKey()); + callback(FAIL, task); return; } diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java index 6de1f136..eb374223 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java @@ -46,6 +46,8 @@ class BaseUListener extends BaseListener + diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 4e1b7d40..f4dad30c 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -51,17 +51,17 @@ public class SingleTaskActivity extends BaseActivity { //"http://kotlinlang.org/docs/kotlin-docs.pdf"; //"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe"; //"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apks"; - //"http://120.55.95.61:8811/ghcg/zg/武义总规纲要成果.zip"; + "http://120.55.95.61:8811/ghcg/zg/武义总规纲要成果.zip"; //"https://yizi-kejian.oss-cn-beijing.aliyuncs.com/qimeng/package1/qmtable11.zip"; //"http://rs.0.gaoshouyou.com/d/04/1e/400423a7551e1f3f0eb1812afa1f9b44.apk"; //"http://58.210.9.131/tpk/sipgt//TDLYZTGH.tpk"; //chunked 下载 - "https://static.donguo.me//video/ip/course/pfys_1.mp4"; - //"https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864"; - //"https://d.pcs.baidu.com/file/a02c89a2d479d4fd2756f3313d42491d?fid=4232431903-250528-1114369760340736&dstime=1525491372&rt=sh&sign=FDtAERVY-DCb740ccc5511e5e8fedcff06b081203-3C13vkOkuk4TqXvVYW05zj1K0ao%3D&expires=8h&chkv=1&chkbd=0&chkpc=et&dp-logid=8651730921842106225&dp-callid=0&r=165533013"; - //"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1"; - //"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe"; - //"http://9.9.9.59:5000/download/CentOS-7-x86_64-Minimal-1804.iso"; - //"https://firmwareapi.azurewebsites.net/firmware-overview?name=A19_Filament_W_IMG0038_00102411-encrypted.ota"; + //"https://static.donguo.me/video/ip/course/pfys_1.mp4"; + //"https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864"; + //"https://d.pcs.baidu.com/file/a02c89a2d479d4fd2756f3313d42491d?fid=4232431903-250528-1114369760340736&dstime=1525491372&rt=sh&sign=FDtAERVY-DCb740ccc5511e5e8fedcff06b081203-3C13vkOkuk4TqXvVYW05zj1K0ao%3D&expires=8h&chkv=1&chkbd=0&chkpc=et&dp-logid=8651730921842106225&dp-callid=0&r=165533013"; + //"http://apk500.bce.baidu-mgame.com/game/67000/67734/20170622040827_oem_5502845.apk?r=1"; + //"https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe"; + //"http://9.9.9.59:5000/download/CentOS-7-x86_64-Minimal-1804.iso"; + //"https://firmwareapi.azurewebsites.net/firmware-overview?name=A19_Filament_W_IMG0038_00102411-encrypted.ota"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; @@ -183,6 +183,10 @@ public class SingleTaskActivity extends BaseActivity { if (task.getKey().equals(DOWNLOAD_URL)) { Toast.makeText(SingleTaskActivity.this, "下载失败", Toast.LENGTH_SHORT).show(); setBtState(true); + Aria.download(this) + .load(DOWNLOAD_URL) + .updateUrl("http://120.55.95.61:8811/ghcg/zg/武义总规纲要成果.zip") + .start(); //ALog.d(TAG, ALog.getExceptionString(e)); } } @@ -255,7 +259,7 @@ public class SingleTaskActivity extends BaseActivity { //Aria.get(this).setLogLevel(ALog.LOG_CLOSE); //Aria.download(this).load("aaaa.apk"); //String path = Environment.getExternalStorageDirectory().getPath() + "/ggsg11.ota"; - String path = "/sdcard/ggsg11.ota"; + String path = "/sdcard/ggsg11.mp4"; //File file = new File(path); //if (file.exists()){ // file.delete(); diff --git a/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java b/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java index 6d2a96d0..5319b423 100644 --- a/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java +++ b/app/src/main/java/com/arialyy/simple/download/multi_download/DownloadAdapter.java @@ -205,9 +205,10 @@ public class DownloadAdapter extends AbsRVAdapter