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