From b95ab29466895d966da5e62dcbec08d296dbf8d3 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Fri, 9 Jun 2017 20:45:29 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=20https://github.com/AriaLyy?= =?UTF-8?q?/Aria/issues/33?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arialyy/aria/core/download/DownloadTask.java | 16 +++++++++------- README.md | 3 ++- .../simple/download/SingleTaskActivity.java | 1 + 3 files changed, 12 insertions(+), 8 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java index 97bd7917..0ac71387 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java @@ -133,17 +133,19 @@ public class DownloadTask extends AbsTask { */ @Override public void cancel() { if (!mEntity.isDownloadComplete()) { + if (!mUtil.isDownloading()) { + if (mOutHandler != null) { + mOutHandler.obtainMessage(DownloadSchedulers.CANCEL, this).sendToTarget(); + } + //发送取消下载的广播 + Intent intent = CommonUtil.createIntent(mContext.getPackageName(), Aria.ACTION_CANCEL); + intent.putExtra(Aria.DOWNLOAD_ENTITY, mEntity); + mContext.sendBroadcast(intent); + } mUtil.cancelDownload(); mUtil.delConfigFile(); mUtil.delTempFile(); mEntity.deleteData(); - if (mOutHandler != null) { - mOutHandler.obtainMessage(DownloadSchedulers.CANCEL, this).sendToTarget(); - } - //发送取消下载的广播 - Intent intent = CommonUtil.createIntent(mContext.getPackageName(), Aria.ACTION_CANCEL); - intent.putExtra(Aria.DOWNLOAD_ENTITY, mEntity); - mContext.sendBroadcast(intent); } } diff --git a/README.md b/README.md index 6421c676..4556cf1b 100644 --- a/README.md +++ b/README.md @@ -25,7 +25,7 @@ Aria怎样使用? ## 下载 [![Download](https://api.bintray.com/packages/arialyy/maven/Aria/images/download.svg)](https://bintray.com/arialyy/maven/Aria/_latestVersion)
```java -compile 'com.arialyy.aria:Aria:3.1.5' +compile 'com.arialyy.aria:Aria:3.1.6' ``` ## 示例 @@ -277,6 +277,7 @@ Aria.download(this).load(DOWNLOAD_URL).setDownloadPath(PATH).setHighestPriority( ## 开发日志 + + v_3.1.6 [取消任务时onTaskCancel回调两次的bug](https://github.com/AriaLyy/Aria/issues/33) + v_3.1.5 优化代码结构,增加优先下载任务功能。 + v_3.1.4 修复快速切换,暂停、恢复功能时,概率性出现的重新下载问题,添加onPre()回调,onPre()用于请求地址之前执行界面UI更新操作。 + v_3.1.0 添加Aria配置文件,优化代码 diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index dfe71692..7f8849e7 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -241,6 +241,7 @@ public class SingleTaskActivity extends BaseActivity { @Override public void onTaskCancel(DownloadTask task) { if (task.getKey().equals(DOWNLOAD_URL)) { mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL); + L.d(TAG, "task__cancel"); } }