This commit is contained in:
AriaLyy
2017-07-31 10:37:59 +08:00
parent d0ca28ffd9
commit 155d7f9f6a
4 changed files with 22 additions and 13 deletions

View File

@ -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<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
mQueue.removeAllTask();
if (mTaskEntity instanceof DownloadTaskEntity) {
handleDownloadRemove();
} else {
} else if (mTaskEntity instanceof UploadTaskEntity){
handleUploadRemove();
}
}
@ -50,6 +49,7 @@ final class CancelAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
*/
private void handleUploadRemove() {
List<UploadTaskEntity> 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<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
*/
private void handleDownloadRemove() {
List<DownloadTaskEntity> allEntity = DbEntity.findAllData(DownloadTaskEntity.class);
if (allEntity == null || allEntity.size() == 0) return;
for (DownloadTaskEntity entity : allEntity) {
CommonUtil.delDownloadTaskConfig(mTaskEntity.removeFile, entity);
}

View File

@ -242,9 +242,6 @@ public class DownloadReceiver extends AbsReceiver {
Set<String> keys = ariaManager.getReceiver().keySet();
for (String key : keys) {
IReceiver receiver = ariaManager.getReceiver().get(key);
receiver.removeSchedulerListener();
receiver.unRegister();
ariaManager.getReceiver().remove(key);
}
}

View File

@ -24,37 +24,37 @@ public interface IReceiver<ENTITY extends IEntity> {
/**
* 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<ENTITY> getSimpleTaskList();
List<ENTITY> getSimpleTaskList();
}