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