任务组子任务控制bug修复,apt注解修复

This commit is contained in:
AriaLyy
2017-09-12 22:52:53 +08:00
parent a6434dc2f1
commit 9c39a95d85
16 changed files with 123 additions and 99 deletions

View File

@@ -18,7 +18,6 @@ package com.arialyy.simple.download.group;
import android.annotation.SuppressLint;
import android.content.Context;
import android.os.Bundle;
import android.util.Log;
import android.view.Gravity;
import android.view.View;
import android.view.ViewGroup;
@@ -31,6 +30,7 @@ import com.arialyy.annotations.DownloadGroup;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseDialog;
import com.arialyy.simple.databinding.DialogSubTaskHandlerBinding;
@@ -47,13 +47,15 @@ import java.util.List;
@Bind(R.id.pb) HorizontalProgressBarWithNumber mPb;
private String mGroupName;
private String mChildName;
private List<String> mUrls;
private DownloadEntity mChildEntity;
public ChildHandleDialog(Context context, String groupAliaName, DownloadEntity childEntity) {
public ChildHandleDialog(Context context, List<String> urls, DownloadEntity childEntity) {
super(context);
setStyle(STYLE_NO_TITLE, R.style.Theme_Light_Dialog);
mChildEntity = childEntity;
mGroupName = groupAliaName;
mGroupName = "任务组测试";
mUrls = urls;
mChildName = childEntity.getFileName();
}
@@ -81,39 +83,64 @@ import java.util.List;
window.setWindowAnimations(R.style.dialogStyle);
}
@DownloadGroup.onTaskResume void onTaskResume(DownloadGroupTask task) {
mSub.setText("子任务:" + mChildName + ",状态:下载中");
@DownloadGroup.onSubTaskRunning void onSubTaskRunning(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
if (!subEntity.getUrl().equals(mChildEntity.getUrl())) return;
L.d(TAG, "p ==> " + subEntity.getPercent());
mPb.setProgress(subEntity.getPercent());
}
@DownloadGroup.onTaskCancel void onTaskCancel(DownloadGroupTask task) {
mSub.setText("子任务:" + mChildName + ",状态:取消下载");
@DownloadGroup.onSubTaskPre void onSubTaskPre(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
if (!subEntity.getUrl().equals(mChildEntity.getUrl())) return;
L.d(TAG, subEntity.getPercent() + "");
}
@DownloadGroup.onTaskRunning void onTaskRunning(DownloadGroupTask task) {
mPb.setProgress((int) (mChildEntity.getCurrentProgress() * 100 / mChildEntity.getFileSize()));
}
@DownloadGroup.onTaskStop void onTaskStop(DownloadGroupTask task) {
@DownloadGroup.onSubTaskStop void onSubTaskStop(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
if (!subEntity.getUrl().equals(mChildEntity.getUrl())) return;
mSub.setText("子任务:" + mChildName + ",状态:任务停止");
}
@DownloadGroup.onTaskComplete void onTaskComplete(DownloadGroupTask task) {
@DownloadGroup.onSubTaskStart void onSubTaskStart(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
if (!subEntity.getUrl().equals(mChildEntity.getUrl())) return;
mSub.setText("子任务:" + mChildName + ",状态:下载中");
}
//@DownloadGroup.onSubTaskCancel void onSubTaskCancel(DownloadGroupTask groupTask,
// DownloadEntity subEntity) {
// mSub.setText("子任务:" + mChildName + ",状态:取消下载");
//}
@DownloadGroup.onSubTaskComplete void onSubTaskComplete(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
if (!subEntity.getUrl().equals(mChildEntity.getUrl())) return;
mSub.setText("子任务:" + mChildName + ",状态:任务完成");
mPb.setProgress(100);
}
@DownloadGroup.onSubTaskFail void onSubTaskFail(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
if (!subEntity.getUrl().equals(mChildEntity.getUrl())) return;
L.d(TAG, subEntity.getPercent() + "");
}
@Override protected int setLayoutId() {
return R.layout.dialog_sub_task_handler;
}
@OnClick({ R.id.start, R.id.stop, R.id.cancel }) void onClick(View view) {
@OnClick({ R.id.start, R.id.stop }) void onClick(View view) {
switch (view.getId()) {
case R.id.start:
Aria.download(this).load(mUrls).getSubTaskManager().startSubTask(mChildEntity.getUrl());
break;
case R.id.stop:
Aria.download(this).load(mUrls).getSubTaskManager().stopSubTask(mChildEntity.getUrl());
break;
case R.id.cancel:
break;
//case R.id.cancel:
// Aria.download(this).load(mUrls).getSubTaskManager().cancelSubTask(mChildEntity.getUrl());
// break;
}
}

View File

@@ -17,6 +17,7 @@ package com.arialyy.simple.download.group;
import android.os.Bundle;
import android.os.Environment;
import android.support.design.widget.FloatingActionButton;
import android.view.View;
import butterknife.Bind;
import com.arialyy.annotations.DownloadGroup;
@@ -64,11 +65,12 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
showPopupWindow(position);
}
});
}
private void showPopupWindow(int position) {
ChildHandleDialog dialog =
new ChildHandleDialog(this, "任务组测试", mChildList.getSubData().get(position));
new ChildHandleDialog(this, mUrls, mChildList.getSubData().get(position));
dialog.show(getSupportFragmentManager(), "sub_dialog");
}
@@ -149,41 +151,4 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
L.d(TAG, "任务组下载完成");
}
///////////////////////////////////任务组子任务///////////////////////////////////
@DownloadGroup.onSubTaskRunning void onSubTaskRunning(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
L.d(TAG, subEntity.getFileName() + "__________" + subEntity.getPercent() + "");
}
@DownloadGroup.onSubTaskPre void onSubTaskPre(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
L.d(TAG, subEntity.getPercent() + "");
}
@DownloadGroup.onSubTaskStop void onSubTaskStop(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
L.d(TAG, subEntity.getPercent() + "");
}
@DownloadGroup.onSubTaskStart void onSubTaskStart(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
L.d(TAG, subEntity.getPercent() + "");
}
@DownloadGroup.onSubTaskCancel void onSubTaskCancel(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
L.d(TAG, subEntity.getPercent() + "");
}
@DownloadGroup.onSubTaskComplete void onSubTaskComplete(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
L.d(TAG, subEntity.getPercent() + "");
}
@DownloadGroup.onSubTaskFail void onSubTaskFail(DownloadGroupTask groupTask,
DownloadEntity subEntity) {
L.d(TAG, subEntity.getPercent() + "");
}
}

View File

@@ -40,11 +40,11 @@
android:id="@+id/child_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_above="@+id/temp"
android:layout_below="@+id/content"
android:paddingLeft="16dp"
android:paddingRight="16dp"
/>
</RelativeLayout>
</layout>

View File

@@ -61,14 +61,14 @@
style="?buttonBarButtonStyle"
/>
<Button
android:id="@+id/cancel"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_weight="1"
android:text="删除"
style="?buttonBarButtonStyle"
/>
<!--<Button-->
<!--android:id="@+id/cancel"-->
<!--android:layout_width="wrap_content"-->
<!--android:layout_height="wrap_content"-->
<!--android:layout_weight="1"-->
<!--android:text="删除"-->
<!--style="?buttonBarButtonStyle"-->
<!--/>-->
</LinearLayout>
</RelativeLayout>