laoyuyu
2019-07-16 22:52:30 +08:00
parent b1bc4529c0
commit a2604a9431
30 changed files with 176 additions and 119 deletions

View File

@@ -22,7 +22,7 @@
<download>
<!--设置任务最大下载速度0表示不限速单位为kb-->
<maxSpeed value="128"/>
<maxSpeed value="0"/>
<!--
多线程下载是否使用块下载模式,{@code true}使用,{@code false}不使用

View File

@@ -34,7 +34,8 @@ public class HttpDownloadModule extends BaseViewModule {
private final String defUrl =
"http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk";
//"http://202.98.201.103:7000/vrs/TPK/ZTC440402001Z.tpk";
//"http://9.9.9.205:5000/download/Cyberduck-6.9.4.30164.zip";
//"http://202.98.201.103:7000/vrs/TPK/ZTC440402001Z.tpk";
private final String defFilePath =
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
+ "/ZTC440402001Z.tpk";

View File

@@ -97,8 +97,8 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_2")
.setGroupAlias("任务组测试")
//.setSubFileName(getModule(GroupModule.class).getSubName2())
.setSubFileName(getModule(GroupModule.class).getSubName())
.unknownSize()
//.setSubFileName(getModule(GroupModule.class).getSubName())
//.unknownSize()
.setFileLenAdapter(new IHttpFileLenAdapter() {
@Override public long handleFileLen(Map<String, List<String>> headers) {
@@ -111,7 +111,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
return Long.parseLong(temp);
}
})
//.setFileSize(114981416)
.setFileSize(114981416)
//.updateUrls(temp)
.start();
getBinding().setStateStr(getString(R.string.stop));
@@ -170,6 +170,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
@DownloadGroup.onTaskStop() void taskStop(DownloadGroupTask task) {
L.d(TAG, "group task stop");
getBinding().setSpeed("");
getBinding().setStateStr(getString(R.string.start));
}
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
@@ -182,6 +183,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
@DownloadGroup.onTaskFail() void taskFail(DownloadGroupTask task) {
L.d(TAG, "group task fail");
getBinding().setStateStr(getString(R.string.resume));
getBinding().setSpeed("");
}
@DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) {
@@ -236,6 +238,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
@DownloadGroup.onSubTaskComplete void onSubTaskComplete(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
mChildList.updateChildState(subEntity);
}
@DownloadGroup.onSubTaskFail void onSubTaskFail(DownloadGroupTask groupTask,

View File

@@ -18,7 +18,6 @@ package com.arialyy.simple.widget;
import android.content.Context;
import android.support.annotation.Nullable;
import android.util.AttributeSet;
import android.util.Log;
import android.util.SparseArray;
import android.view.LayoutInflater;
import android.view.View;
@@ -36,6 +35,7 @@ import java.util.WeakHashMap;
*/
public class SubStateLinearLayout extends LinearLayout implements View.OnClickListener {
private final String TAG = "SubStateLinearLayout";
interface OnShowCallback {
void onShow(boolean visibility);
}
@@ -100,7 +100,7 @@ public class SubStateLinearLayout extends LinearLayout implements View.OnClickLi
public void updateChildProgress(List<DownloadEntity> entities) {
for (DownloadEntity entity : entities) {
Integer i = mPosition.get(entity.getDownloadPath());
Integer i = mPosition.get(entity.getFilePath());
if (i == null) return;
int position = i;
if (position != -1) {
@@ -112,6 +112,22 @@ public class SubStateLinearLayout extends LinearLayout implements View.OnClickLi
}
}
public void updateChildState(DownloadEntity entity) {
Integer i = mPosition.get(entity.getFilePath());
if (i == null) return;
int position = i;
if (position != -1) {
TextView child = ((TextView) getChildAt(position));
if (entity.isComplete()) {
child.setText(entity.getFileName() + " | " + getResources().getText(R.string.complete));
} else {
int p = getPercent(entity);
child.setText(entity.getFileName() + ": " + p + "%" + " | " + entity.getConvertSpeed());
}
child.invalidate();
}
}
private TextView createView(int position, DownloadEntity entity) {
TextView view =
(TextView) LayoutInflater.from(getContext()).inflate(R.layout.layout_child_state, null);

View File

@@ -12,6 +12,7 @@
<string name="start">开始</string>
<string name="resume">恢复</string>
<string name="delete">删除</string>
<string name="complete">完成</string>
<string name="code_simple">代码示例:</string>
<string name="download_success">下载完成</string>
<string name="download_fail">下载失败</string>
@@ -125,7 +126,7 @@
<string-array name="group_urls_1">
<item>http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk</item>
<!--<item>https://atom-installer.github.com/v1.13.0/AtomSetup.exe</item>-->
<item>https://atom-installer.github.com/v1.13.0/AtomSetup.exe1</item>
<item>http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk</item>
</string-array>