修复删除下载中的游戏连续两次调用onCancelTask回掉的bug https://github.com/AriaLyy/Aria/issues/33

pull/330/head
AriaLyy 8 years ago
parent 431fc35deb
commit 04354a81d0
  1. 4
      Aria/build.gradle
  2. 10
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
  3. 2
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java

@ -23,8 +23,8 @@ dependencies {
compile fileTree(include: ['*.jar'], dir: 'libs') compile fileTree(include: ['*.jar'], dir: 'libs')
testCompile 'junit:junit:4.12' testCompile 'junit:junit:4.12'
compile 'com.android.support:appcompat-v7:23.1.1' compile 'com.android.support:appcompat-v7:23.1.1'
// compile project(':AriaCompiler') compile project(':AriaCompiler')
compile project(':AriaAnnotations') // compile project(':AriaAnnotations')
} }
//apply from: 'jcenter.gradle' //apply from: 'jcenter.gradle'

@ -133,10 +133,7 @@ public class DownloadTask extends AbsTask<DownloadTaskEntity, DownloadEntity> {
*/ */
@Override public void cancel() { @Override public void cancel() {
if (!mEntity.isDownloadComplete()) { if (!mEntity.isDownloadComplete()) {
mUtil.cancelDownload(); if (!mUtil.isDownloading()) {
mUtil.delConfigFile();
mUtil.delTempFile();
mEntity.deleteData();
if (mOutHandler != null) { if (mOutHandler != null) {
mOutHandler.obtainMessage(DownloadSchedulers.CANCEL, this).sendToTarget(); mOutHandler.obtainMessage(DownloadSchedulers.CANCEL, this).sendToTarget();
} }
@ -145,6 +142,11 @@ public class DownloadTask extends AbsTask<DownloadTaskEntity, DownloadEntity> {
intent.putExtra(Aria.DOWNLOAD_ENTITY, mEntity); intent.putExtra(Aria.DOWNLOAD_ENTITY, mEntity);
mContext.sendBroadcast(intent); mContext.sendBroadcast(intent);
} }
mUtil.cancelDownload();
mUtil.delConfigFile();
mUtil.delTempFile();
mEntity.deleteData();
}
} }
public static class Builder { public static class Builder {

@ -183,12 +183,14 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
@Download.onTaskStop void taskStop(DownloadTask task) { @Download.onTaskStop void taskStop(DownloadTask task) {
if (task.getKey().equals(DOWNLOAD_URL)) { if (task.getKey().equals(DOWNLOAD_URL)) {
mUpdateHandler.sendEmptyMessage(DOWNLOAD_STOP); mUpdateHandler.sendEmptyMessage(DOWNLOAD_STOP);
L.d(TAG, "task__stop");
} }
} }
@Download.onTaskCancel void taskCancel(DownloadTask task) { @Download.onTaskCancel void taskCancel(DownloadTask task) {
if (task.getKey().equals(DOWNLOAD_URL)) { if (task.getKey().equals(DOWNLOAD_URL)) {
mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL); mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL);
L.d(TAG, "task__cancel");
} }
} }

Loading…
Cancel
Save