From 155d7f9f6a1bde0c783434742e9d66492f16852f Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Mon, 31 Jul 2017 10:37:59 +0800 Subject: [PATCH] fix bug https://github.com/AriaLyy/Aria/issues/84 --- .../aria/core/command/normal/CancelAllCmd.java | 5 +++-- .../aria/core/download/DownloadReceiver.java | 3 --- .../java/com/arialyy/aria/core/inf/IReceiver.java | 14 +++++++------- .../download/group/DownloadGroupActivity.java | 13 ++++++++++++- 4 files changed, 22 insertions(+), 13 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java index 375b2ffd..9d37a0d5 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java +++ b/Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java @@ -16,7 +16,6 @@ package com.arialyy.aria.core.command.normal; -import com.arialyy.aria.core.download.DownloadGroupEntity; import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity; @@ -40,7 +39,7 @@ final class CancelAllCmd extends AbsNormalCmd { mQueue.removeAllTask(); if (mTaskEntity instanceof DownloadTaskEntity) { handleDownloadRemove(); - } else { + } else if (mTaskEntity instanceof UploadTaskEntity){ handleUploadRemove(); } } @@ -50,6 +49,7 @@ final class CancelAllCmd extends AbsNormalCmd { */ private void handleUploadRemove() { List allEntity = DbEntity.findAllData(UploadTaskEntity.class); + if (allEntity == null || allEntity.size() == 0) return; for (UploadTaskEntity entity : allEntity) { CommonUtil.delUploadTaskConfig(mTaskEntity.removeFile, entity); } @@ -60,6 +60,7 @@ final class CancelAllCmd extends AbsNormalCmd { */ private void handleDownloadRemove() { List allEntity = DbEntity.findAllData(DownloadTaskEntity.class); + if (allEntity == null || allEntity.size() == 0) return; for (DownloadTaskEntity entity : allEntity) { CommonUtil.delDownloadTaskConfig(mTaskEntity.removeFile, entity); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java index 94bc57d9..ce518da8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java @@ -242,9 +242,6 @@ public class DownloadReceiver extends AbsReceiver { Set keys = ariaManager.getReceiver().keySet(); for (String key : keys) { - IReceiver receiver = ariaManager.getReceiver().get(key); - receiver.removeSchedulerListener(); - receiver.unRegister(); ariaManager.getReceiver().remove(key); } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java index dc347eee..0242daf3 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java @@ -24,37 +24,37 @@ public interface IReceiver { /** * Receiver 销毁 */ - public void destroy(); + void destroy(); /** * 移除事件回调 */ - public void removeSchedulerListener(); + void removeSchedulerListener(); /** * 移除观察者 */ - public void unRegister(); + void unRegister(); /** * 停止所有任务 */ - public void stopAllTask(); + void stopAllTask(); /** * 删除所有任务 */ - public void removeAllTask(boolean removeFile); + void removeAllTask(boolean removeFile); /** * 任务是否存在 * * @param key 下载时为下载路径,上传时为文件路径 */ - public boolean taskExists(String key); + boolean taskExists(String key); /** * 获取任务列表 */ - public List getSimpleTaskList(); + List getSimpleTaskList(); } diff --git a/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java b/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java index b5471182..999ec03b 100644 --- a/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java @@ -17,6 +17,8 @@ package com.arialyy.simple.download.group; import android.os.Bundle; import android.os.Environment; +import android.os.Handler; +import android.util.Log; import android.view.View; import android.widget.Button; import butterknife.Bind; @@ -82,7 +84,15 @@ public class DownloadGroupActivity extends BaseActivity " + Aria.download(DownloadGroupActivity.this).getTotleTaskList().size()); + } + }, 1000); break; } } @@ -116,6 +126,7 @@ public class DownloadGroupActivity extends BaseActivity