修复组合任务单线程下载过程中应用被杀,文件变大的问题

This commit is contained in:
laoyuyu
2018-07-05 10:12:20 +08:00
parent 671ae11e2b
commit 3c05d8cafc
14 changed files with 320 additions and 142 deletions

View File

@@ -14,10 +14,10 @@
android:supportsRtl="true"
android:theme="@style/AppTheme.NoActionBar">
<!--android:name=".test.TestActivity"-->
<!--android:name=".test.AnyRunActivity"-->
<!--android:name=".test.TestGroupActivity"-->
<!--android:name=".MainActivity"-->
<!--android:name="com.arialyy.simple.test.AnyRunActivity"-->
<!--android:name=".test.AnyRunActivity"-->
<activity
android:name=".download.group.DownloadGroupActivity"
android:label="@string/app_name">

View File

@@ -46,7 +46,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
super.init(savedInstanceState);
Aria.download(this).register();
setTitle("任务组");
mUrls = getModule(GroupModule.class).getUrls2();
mUrls = getModule(GroupModule.class).getUrls1();
DownloadGroupTaskEntity entity = Aria.download(this).getGroupTask(mUrls);
if (entity != null && entity.getEntity() != null) {
DownloadGroupEntity groupEntity = entity.getEntity();
@@ -83,9 +83,11 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
Aria.download(this)
.loadGroup(mUrls)
.setDirPath(
Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_5")
//Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_5")
Environment.getExternalStorageDirectory().getPath() + "/Download/group_test_1")
.setGroupAlias("任务组测试")
.setSubFileName(getModule(GroupModule.class).getSubName2())
//.setSubFileName(getModule(GroupModule.class).getSubName2())
.setSubFileName(getModule(GroupModule.class).getSubName())
//.setFileSize(32895492)
.start();
break;
@@ -134,12 +136,12 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
}
@DownloadGroup.onTaskRunning() protected void running(DownloadGroupTask task) {
//Log.d(TAG, "group running, p = "
// + task.getPercent()
// + ", speed = "
// + task.getConvertSpeed()
// + "current_p = "
// + task.getCurrentProgress());
Log.d(TAG, "group running, p = "
+ task.getPercent()
+ ", speed = "
+ task.getConvertSpeed()
+ "current_p = "
+ task.getCurrentProgress());
getBinding().setProgress(task.getPercent());
getBinding().setSpeed(task.getConvertSpeed());
//Log.d(TAG, "sub_len = " + task.getEntity().getSubEntities().size());
@@ -175,26 +177,25 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
@DownloadGroup.onSubTaskRunning void onSubTaskRunning(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
//ALog.d(TAG, "sub_percent = " + subEntity.getPercent());
Log.e(TAG, "gHash = "
+ groupTask.getEntity().getSubEntities().get(0).hashCode()
+ "; subHash = "
+ groupTask.getTaskEntity().getSubTaskEntities().get(0).getEntity().hashCode() +
"; subHash = " + subEntity.hashCode());
int percent = subEntity.getPercent();
//如果你打开了速度单位转换配置将可以通过以下方法获取带单位的下载速度1 mb/s
String convertSpeed = subEntity.getConvertSpeed();
//当前下载完成的进度长度bytes
long completedSize = subEntity.getCurrentProgress();
Log.d(TAG, "subTask名字"
+ subEntity.getFileName()
+ ", "
+ " speed:"
+ convertSpeed
+ ",percent: "
+ percent
+ "%, completedSize:"
+ completedSize);
//Log.e(TAG, "gHash = "
// + groupTask.getEntity().getSubEntities().get(0).hashCode()
// + "; subHash = "
// + groupTask.getTaskEntity().getSubTaskEntities().get(0).getEntity().hashCode() +
// "; subHash = " + subEntity.hashCode());
//int percent = subEntity.getPercent();
////如果你打开了速度单位转换配置将可以通过以下方法获取带单位的下载速度1 mb/s
//String convertSpeed = subEntity.getConvertSpeed();
////当前下载完成的进度长度bytes
//long completedSize = subEntity.getCurrentProgress();
//Log.d(TAG, "subTask名字"
// + subEntity.getFileName()
// + ", "
// + " speed:"
// + convertSpeed
// + ",percent: "
// + percent
// + "%, completedSize:"
// + completedSize);
}
@DownloadGroup.onSubTaskPre void onSubTaskPre(DownloadGroupTask groupTask,

View File

@@ -35,7 +35,7 @@ import java.util.WeakHashMap;
* Created by Aria.Lao on 2017/7/17.
*/
public class SubStateLinearLayout extends LinearLayout implements View.OnClickListener {
private final String TAG = "SubStateLinearLayout";
interface OnShowCallback {
void onShow(boolean visibility);
}
@@ -106,7 +106,6 @@ public class SubStateLinearLayout extends LinearLayout implements View.OnClickLi
if (position != -1) {
TextView child = ((TextView) getChildAt(position));
int p = getPercent(entity);
Log.d("TAG", "p = " + p);
child.setText(entity.getFileName() + ": " + p + "%" + " | " + entity.getConvertSpeed());
child.invalidate();
}

View File

@@ -60,7 +60,7 @@
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a52034c72752e8475414630ebc69318b84ef584115ebf5eaaab945ae07b7fe3596afc72a7940ff328d4a9553f6ae92d6c09ba4bfb533137f6.apk</item>-->
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a426f06bfc69034d69c44ae1a01da180cab8e59bd1a5e1a784bac46ba0c64579d14f0e80a4ce4f068af89b0369a393456f4f449a8829cad5c.apk</item>-->
<item>http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk</item>
<item>http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk</item>
<!--<item>http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk</item>-->
</string-array>
<string-array name="group_urls_1">
@@ -87,7 +87,7 @@
<string-array name="group_names">
<!--<item>王者荣耀.apk</item>-->
<item>战斗吧剑灵.apk</item>
<item>天魔幻想.apk</item>
<!--<item>天魔幻想.apk</item>-->
</string-array>
<string-array name="group_names_1">