diff --git a/Aria/build.gradle b/Aria/build.gradle index c0c5108c..af990516 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -23,8 +23,8 @@ dependencies { compile fileTree(include: ['*.jar'], dir: 'libs') testCompile 'junit:junit:4.12' compile 'com.android.support:appcompat-v7:23.1.1' -// compile project(':AriaCompiler') - compile project(':AriaAnnotations') + compile project(':AriaCompiler') +// compile project(':AriaAnnotations') } //apply from: 'jcenter.gradle' 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/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 91fe5a3f..558cdf24 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -183,12 +183,14 @@ public class SingleTaskActivity extends BaseActivity { @Download.onTaskStop void taskStop(DownloadTask task) { if (task.getKey().equals(DOWNLOAD_URL)) { mUpdateHandler.sendEmptyMessage(DOWNLOAD_STOP); + L.d(TAG, "task__stop"); } } @Download.onTaskCancel void taskCancel(DownloadTask task) { if (task.getKey().equals(DOWNLOAD_URL)) { mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL); + L.d(TAG, "task__cancel"); } }