From fd5b4f02487177e09aa89cf02a87cfc3b8acd210 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Thu, 15 Jun 2017 23:39:09 +0800 Subject: [PATCH] test --- .../com/arialyy/aria/core/command/AddCmd.java | 3 +- app/src/main/AndroidManifest.xml | 1 + app/src/main/assets/aria_config.xml | 2 +- .../java/com/arialyy/simple/MainActivity.java | 5 ++ .../simple/test/TestMutilTaskSysDownload.java | 71 +++++++++++++++++++ app/src/main/res/layout/activity_main.xml | 9 +++ .../main/res/layout/test_activity_multi.xml | 22 ++++++ 7 files changed, 111 insertions(+), 2 deletions(-) create mode 100644 app/src/main/java/com/arialyy/simple/test/TestMutilTaskSysDownload.java create mode 100644 app/src/main/res/layout/test_activity_multi.xml diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java index 6bad005f..fe6d481b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java @@ -17,6 +17,7 @@ package com.arialyy.aria.core.command; import android.util.Log; +import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.ITask; import com.arialyy.aria.core.inf.AbsTaskEntity; @@ -34,10 +35,10 @@ class AddCmd extends AbsCmd { if (!canExeCmd) return; ITask task = mQueue.getTask(mEntity.getEntity()); if (task == null) { + mEntity.getEntity().setState(IEntity.STATE_WAIT); mQueue.createTask(mTargetName, mEntity); } else { Log.w(TAG, "添加命令执行失败,【该任务已经存在】"); } } - } \ No newline at end of file diff --git a/app/src/main/AndroidManifest.xml b/app/src/main/AndroidManifest.xml index c2b2e5e9..b91acce7 100644 --- a/app/src/main/AndroidManifest.xml +++ b/app/src/main/AndroidManifest.xml @@ -30,6 +30,7 @@ + diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 522cfa0c..022b9800 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -20,7 +20,7 @@ - + diff --git a/app/src/main/java/com/arialyy/simple/MainActivity.java b/app/src/main/java/com/arialyy/simple/MainActivity.java index 69cd6d6e..7b315dab 100644 --- a/app/src/main/java/com/arialyy/simple/MainActivity.java +++ b/app/src/main/java/com/arialyy/simple/MainActivity.java @@ -26,6 +26,7 @@ import com.arialyy.aria.core.Aria; import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.databinding.ActivityMainBinding; import com.arialyy.simple.download.DownloadActivity; +import com.arialyy.simple.test.TestMutilTaskSysDownload; import com.arialyy.simple.upload.UploadActivity; /** @@ -51,4 +52,8 @@ public class MainActivity extends BaseActivity { @OnClick(R.id.upload) public void uploadDemo() { startActivity(new Intent(this, UploadActivity.class)); } + + @OnClick(R.id.multi_test) public void mutliTest() { + startActivity(new Intent(this, TestMutilTaskSysDownload.class)); + } } diff --git a/app/src/main/java/com/arialyy/simple/test/TestMutilTaskSysDownload.java b/app/src/main/java/com/arialyy/simple/test/TestMutilTaskSysDownload.java new file mode 100644 index 00000000..383536be --- /dev/null +++ b/app/src/main/java/com/arialyy/simple/test/TestMutilTaskSysDownload.java @@ -0,0 +1,71 @@ +package com.arialyy.simple.test; + +import android.os.Environment; +import android.view.View; +import com.arialyy.aria.core.Aria; +import com.arialyy.simple.R; +import com.arialyy.simple.base.BaseActivity; +import com.arialyy.simple.databinding.TestActivityMultiBinding; + +/** + * Created by AriaL on 2017/6/15. + */ + +public class TestMutilTaskSysDownload extends BaseActivity { + + @Override protected int setLayoutId() { + return R.layout.test_activity_multi; + } + + public void onClick(View view) { + String baseUrl = "http://file.bmob.cn/"; + String[] urlArray = { + "M02/3B/A4/oYYBAFaOeUSAc1QiAAFTbmA7AHs052.jpg", + "M02/3B/A4/oYYBAFaOeUaAfYC-AAFD8zf9NXc879.jpg", + "M02/3B/A4/oYYBAFaOeUuAOxhnAACSdmbqSac702.jpg", + "M02/3B/A4/oYYBAFaOeU2AFAIGAAFICximvXc924.jpg", + "M02/3B/A4/oYYBAFaOeVCAPWMQAAFm2KWCq_E721.jpg", + "M02/3B/A4/oYYBAFaOeVOAbiv9AAFfCTTgr94948.jpg", + "M02/3B/A4/oYYBAFaOeVaAMR3tAAFf3yTuuCM577.jpg", + "M02/3B/A4/oYYBAFaOeVmACEWhAAEt72ecbpg468.jpg", + "M02/3B/A4/oYYBAFaOeVyAHHt4AAFg9e9bRio507.jpg", + "M02/3B/A4/oYYBAFaOeV-AClYXAAESLGY0gag424.jpg", + "M02/3B/A4/oYYBAFaOeWKAA7N0AAF3omYOJUI703.jpg", + "M02/3B/A4/oYYBAFaOeWWAD2lrAAFN7eRFxBs575.jpg", + "M02/3B/A4/oYYBAFaOeWiAdCVEAAFg4273Dus313.jpg", + "M02/3B/A4/oYYBAFaOeWyAJDm5AAF8JVoGVb0705.jpg", + "M02/3B/A4/oYYBAFaOeW-AUoA8AAGjKiHkXUo181.jpg", + "M02/3B/A4/oYYBAFaOeXKABIamAAFU7J7vraE265.jpg", + "M02/3B/A5/oYYBAFaOeXaAW09jAAFf37qdwDA457.jpg", + "M02/3B/A5/oYYBAFaOeXmAWmS7AAFtLNpWjgo967.jpg", + "M02/3B/A5/oYYBAFaOeX2AQf9cAAF2fhwS2UE145.jpg", + "M02/3B/A5/oYYBAFaOeYCAKGnLAAFVAzks-qU937.jpg", + "M02/3B/A5/oYYBAFaOeYOAMODNAAF6HjTTMq4819.jpg", + "M02/3B/A5/oYYBAFaOeYeAbn8uAAFLSQLw48Q042.jpg", + "M02/3B/A5/oYYBAFaOeYqAMJThAAFtrNe4UNM047.jpg", + "M02/3B/A5/oYYBAFaOeY2AbnQvAAFNSXWn0Dc026.jpg", + "M02/3B/A5/oYYBAFaOeZCAIsr0AAFHZFEVhPc682.jpg", + "M02/3B/A5/oYYBAFaOeZOAGvITAAFqPmfcc9c471.jpg", + "M02/3B/A5/oYYBAFaOeZaATvjbAAFHDmALnhE003.jpg", + "M02/3B/A5/oYYBAFaOeZmAJPuVAAFfPJC2wsE319.jpg", + "M02/3B/A5/oYYBAFaOeZyAXtAmAAFfArJNwtM371.jpg", + "M02/3B/A5/oYYBAFaOeZ-AGZN0AAFgqwYYCS8004.jpg", + "M02/3B/A5/oYYBAFaOeaOAbbrGAAFcq59JjUo205.jpg", + "M02/3B/A5/oYYBAFaOeaSAdFyoAACaxVxgUJA092.jpg" + }; + int maxNum = Aria.get(this).getDownloadConfig().getMaxTaskNum(); + for (int i = 0; i < urlArray.length; i++) { + if (i < maxNum) { + Aria.download(this) + .load(baseUrl + urlArray[i]) + .setDownloadPath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg") + .start(); + } else { + Aria.download(this) + .load(baseUrl + urlArray[i]) + .setDownloadPath(Environment.getExternalStorageDirectory() + "/test/" + i + ".jpg") + .add(); + } + } + } +} diff --git a/app/src/main/res/layout/activity_main.xml b/app/src/main/res/layout/activity_main.xml index 91885b05..84e60c71 100644 --- a/app/src/main/res/layout/activity_main.xml +++ b/app/src/main/res/layout/activity_main.xml @@ -24,5 +24,14 @@ android:text="上传 demo" style="?buttonBarButtonStyle" /> + +