pull/330/head
AriaLyy 8 years ago
parent 11a02020dd
commit fd5b4f0248
  1. 3
      Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java
  2. 1
      app/src/main/AndroidManifest.xml
  3. 2
      app/src/main/assets/aria_config.xml
  4. 5
      app/src/main/java/com/arialyy/simple/MainActivity.java
  5. 71
      app/src/main/java/com/arialyy/simple/test/TestMutilTaskSysDownload.java
  6. 9
      app/src/main/res/layout/activity_main.xml
  7. 22
      app/src/main/res/layout/test_activity_multi.xml

@ -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<T extends AbsTaskEntity> extends AbsCmd<T> {
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, "添加命令执行失败,【该任务已经存在】");
}
}
}

@ -30,6 +30,7 @@
<activity android:name=".download.fragment_download.FragmentActivity"/>
<activity android:name=".download.multi_download.MultiDownloadActivity"/>
<activity android:name=".download.HighestPriorityActivity"/>
<activity android:name=".test.TestMutilTaskSysDownload"/>
<service android:name=".download.service_download.DownloadService"/>
</application>

@ -20,7 +20,7 @@
<reTryInterval value="5000"/>
<!--设置url连接超时时间,单位为毫秒,默认5000毫秒-->
<connectTimeOut value="5000"/>
<connectTimeOut value="10000"/>
<!--设置IO流读取时间,单位为毫秒,默认20000毫秒,该时间不能少于10000毫秒-->
<iOTimeOut value="20000"/>

@ -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<ActivityMainBinding> {
@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));
}
}

@ -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<TestActivityMultiBinding> {
@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();
}
}
}
}

@ -24,5 +24,14 @@
android:text="上传 demo"
style="?buttonBarButtonStyle"
/>
<Button
android:id="@+id/multi_test"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="多任务测试"
style="?buttonBarButtonStyle"
/>
</LinearLayout>
</layout>

@ -0,0 +1,22 @@
<?xml version="1.0" encoding="utf-8"?>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:orientation="vertical"
>
<include layout="@layout/layout_bar"/>
<Button
android:onClick="onClick"
android:id="@+id/download"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:text="多任务同时下载"
style="?buttonBarButtonStyle"
/>
</LinearLayout>
</layout>
Loading…
Cancel
Save