重构设置部分代码
This commit is contained in:
@ -3,11 +3,15 @@
|
||||
|
||||
|
||||
<download>
|
||||
|
||||
<!--设置下载线程-->
|
||||
<threadNum value="3"/>
|
||||
|
||||
<!--是否打开下载广播,默认为false-->
|
||||
<openBroadcast value="false"/>
|
||||
|
||||
<!--设置下载队列最大任务数, 默认为2-->
|
||||
<maxQueueNum value="2"/>
|
||||
<maxTaskNum value="2"/>
|
||||
|
||||
<!--设置下载失败,重试次数,默认为10-->
|
||||
<reTryNum value="10"/>
|
||||
@ -15,8 +19,11 @@
|
||||
<!--设置重试间隔,单位为毫秒,默认2000毫秒-->
|
||||
<reTryInterval value="2000"/>
|
||||
|
||||
<!--设置url连接超时时间,单位为毫秒,默认5000毫秒-->
|
||||
<connectTimeOut value="5000"/>
|
||||
|
||||
<!--设置IO流读取时间,单位为毫秒,默认20000毫秒,该时间不能少于10000毫秒-->
|
||||
<readTimeout value="20000"/>
|
||||
<iOTimeOut value="20000"/>
|
||||
|
||||
<!--设置写文件buff大小,该数值大小不能小于2048,数值变小,下载速度会变慢-->
|
||||
<buffSize value="8192"/>
|
||||
@ -31,7 +38,7 @@
|
||||
<openBroadcast value="false"/>
|
||||
|
||||
<!--设置上传队列最大任务数, 默认为2-->
|
||||
<maxQueueNum value="2"/>
|
||||
<maxTaskNum value="2"/>
|
||||
|
||||
<!--设置上传失败,重试次数,默认为10-->
|
||||
<reTryNum value="10"/>
|
||||
|
@ -22,6 +22,7 @@ import android.support.v7.widget.Toolbar;
|
||||
import android.view.View;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityMainBinding;
|
||||
import com.arialyy.simple.download.DownloadActivity;
|
||||
|
@ -56,7 +56,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
//"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.apk";
|
||||
//"http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk";
|
||||
//"http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk";
|
||||
//不支持断点的链接
|
||||
//"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-";
|
||||
//"http://172.18.104.50:8080/download/_302turn";
|
||||
@ -164,7 +164,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
setSupportActionBar(toolbar);
|
||||
toolbar.setTitle("单任务下载");
|
||||
init();
|
||||
Aria.get(this).openBroadcast(true);
|
||||
Aria.get(this).getDownloadConfig().setOpenBreadCast(true);
|
||||
}
|
||||
|
||||
private void init() {
|
||||
@ -173,33 +173,33 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
|
||||
mPb.setProgress(p);
|
||||
}
|
||||
mRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
@Override public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
switch (checkedId) {
|
||||
case 1:
|
||||
Aria.get(this).setMaxSpeed(Speed.KB_256);
|
||||
break;
|
||||
case 2:
|
||||
Aria.get(this).setMaxSpeed(Speed.KB_512);
|
||||
break;
|
||||
case 3:
|
||||
Aria.get(this).setMaxSpeed(Speed.MB_1);
|
||||
break;
|
||||
case 4:
|
||||
Aria.get(this).setMaxSpeed(Speed.MB_2);
|
||||
break;
|
||||
case 5:
|
||||
Aria.get(this).setMaxSpeed(Speed.MAX);
|
||||
break;
|
||||
}
|
||||
stop();
|
||||
new Handler().postDelayed(new Runnable() {
|
||||
@Override public void run() {
|
||||
start();
|
||||
}
|
||||
}, 2000);
|
||||
}
|
||||
});
|
||||
//mRg.setOnCheckedChangeListener(new RadioGroup.OnCheckedChangeListener() {
|
||||
// @Override public void onCheckedChanged(RadioGroup group, int checkedId) {
|
||||
// switch (checkedId) {
|
||||
// case 1:
|
||||
// Aria.get(this).setMaxSpeed(Speed.KB_256);
|
||||
// break;
|
||||
// case 2:
|
||||
// Aria.get(this).setMaxSpeed(Speed.KB_512);
|
||||
// break;
|
||||
// case 3:
|
||||
// Aria.get(this).setMaxSpeed(Speed.MB_1);
|
||||
// break;
|
||||
// case 4:
|
||||
// Aria.get(this).setMaxSpeed(Speed.MB_2);
|
||||
// break;
|
||||
// case 5:
|
||||
// Aria.get(this).setMaxSpeed(Speed.MAX);
|
||||
// break;
|
||||
// }
|
||||
// stop();
|
||||
// new Handler().postDelayed(new Runnable() {
|
||||
// @Override public void run() {
|
||||
// start();
|
||||
// }
|
||||
// }, 2000);
|
||||
// }
|
||||
//});
|
||||
}
|
||||
|
||||
public void onClick(View view) {
|
||||
|
@ -147,10 +147,6 @@ final class DownloadAdapter extends AbsRVAdapter<DownloadEntity, DownloadAdapter
|
||||
});
|
||||
}
|
||||
|
||||
public void setDownloadNum(int num) {
|
||||
Aria.get(getContext()).setMaxDownloadNum(num);
|
||||
}
|
||||
|
||||
private String covertCurrentSize(long currentSize) {
|
||||
String size = CommonUtil.formatFileSize(currentSize);
|
||||
return size.substring(0, size.length() - 1);
|
||||
|
@ -83,7 +83,7 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
|
||||
@Override protected void dataCallback(int result, Object data) {
|
||||
super.dataCallback(result, data);
|
||||
if (result == DownloadNumDialog.RESULT_CODE) {
|
||||
Aria.get(this).setMaxDownloadNum(Integer.parseInt(data + ""));
|
||||
Aria.get(this).getDownloadConfig().setMaxTaskNum(Integer.parseInt(data + ""));
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user