|
|
@ -107,19 +107,26 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onWait void onWait(DownloadTask task) { |
|
|
|
@Download.onWait void onWait(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
Log.d(TAG, "wait ==> " + task.getDownloadEntity().getFileName()); |
|
|
|
Log.d(TAG, "wait ==> " + task.getDownloadEntity().getFileName()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onPre protected void onPre(DownloadTask task) { |
|
|
|
@Download.onPre protected void onPre(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
setBtState(false); |
|
|
|
setBtState(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskStart void taskStart(DownloadTask task) { |
|
|
|
@Download.onTaskStart void taskStart(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
getBinding().setFileSize(task.getConvertFileSize()); |
|
|
|
getBinding().setFileSize(task.getConvertFileSize()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskRunning protected void running(DownloadTask task) { |
|
|
|
@Download.onTaskRunning protected void running(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
|
|
|
|
Log.d(TAG, task.getKey()); |
|
|
|
long len = task.getFileSize(); |
|
|
|
long len = task.getFileSize(); |
|
|
|
if (len == 0) { |
|
|
|
if (len == 0) { |
|
|
|
getBinding().setProgress(0); |
|
|
|
getBinding().setProgress(0); |
|
|
@ -128,19 +135,25 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
} |
|
|
|
} |
|
|
|
getBinding().setSpeed(task.getConvertSpeed()); |
|
|
|
getBinding().setSpeed(task.getConvertSpeed()); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskResume void taskResume(DownloadTask task) { |
|
|
|
@Download.onTaskResume void taskResume(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
mStart.setText("暂停"); |
|
|
|
mStart.setText("暂停"); |
|
|
|
setBtState(false); |
|
|
|
setBtState(false); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskStop void taskStop(DownloadTask task) { |
|
|
|
@Download.onTaskStop void taskStop(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
mStart.setText("恢复"); |
|
|
|
mStart.setText("恢复"); |
|
|
|
setBtState(true); |
|
|
|
setBtState(true); |
|
|
|
getBinding().setSpeed(""); |
|
|
|
getBinding().setSpeed(""); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskCancel void taskCancel(DownloadTask task) { |
|
|
|
@Download.onTaskCancel void taskCancel(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
getBinding().setProgress(0); |
|
|
|
getBinding().setProgress(0); |
|
|
|
Toast.makeText(SingleTaskActivity.this, "取消下载", Toast.LENGTH_SHORT).show(); |
|
|
|
Toast.makeText(SingleTaskActivity.this, "取消下载", Toast.LENGTH_SHORT).show(); |
|
|
|
mStart.setText("开始"); |
|
|
|
mStart.setText("开始"); |
|
|
@ -148,13 +161,17 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
getBinding().setSpeed(""); |
|
|
|
getBinding().setSpeed(""); |
|
|
|
Log.d(TAG, "cancel"); |
|
|
|
Log.d(TAG, "cancel"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskFail void taskFail(DownloadTask task) { |
|
|
|
@Download.onTaskFail void taskFail(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
Toast.makeText(SingleTaskActivity.this, "下载失败", Toast.LENGTH_SHORT).show(); |
|
|
|
Toast.makeText(SingleTaskActivity.this, "下载失败", Toast.LENGTH_SHORT).show(); |
|
|
|
setBtState(true); |
|
|
|
setBtState(true); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onTaskComplete void taskComplete(DownloadTask task) { |
|
|
|
@Download.onTaskComplete void taskComplete(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
getBinding().setProgress(100); |
|
|
|
getBinding().setProgress(100); |
|
|
|
Toast.makeText(SingleTaskActivity.this, "下载完成", Toast.LENGTH_SHORT).show(); |
|
|
|
Toast.makeText(SingleTaskActivity.this, "下载完成", Toast.LENGTH_SHORT).show(); |
|
|
|
mStart.setText("重新开始?"); |
|
|
|
mStart.setText("重新开始?"); |
|
|
@ -165,10 +182,13 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { |
|
|
|
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath()))); |
|
|
|
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath()))); |
|
|
|
L.d(TAG, "data ==> " + Aria.download(this).getDownloadEntity(DOWNLOAD_URL)); |
|
|
|
L.d(TAG, "data ==> " + Aria.download(this).getDownloadEntity(DOWNLOAD_URL)); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Download.onNoSupportBreakPoint public void onNoSupportBreakPoint(DownloadTask task) { |
|
|
|
@Download.onNoSupportBreakPoint public void onNoSupportBreakPoint(DownloadTask task) { |
|
|
|
|
|
|
|
if (task.getKey().equals(DOWNLOAD_URL)) { |
|
|
|
T.showShort(SingleTaskActivity.this, "该下载链接不支持断点"); |
|
|
|
T.showShort(SingleTaskActivity.this, "该下载链接不支持断点"); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
@Override protected int setLayoutId() { |
|
|
|
@Override protected int setLayoutId() { |
|
|
|
return R.layout.activity_single; |
|
|
|
return R.layout.activity_single; |
|
|
|