AriaLyy 7 years ago
parent d0ca28ffd9
commit 155d7f9f6a
  1. 5
      Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java
  2. 3
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  3. 14
      Aria/src/main/java/com/arialyy/aria/core/inf/IReceiver.java
  4. 13
      app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.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<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);
}

@ -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);
}
}

@ -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();
}

@ -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<ActivityDownloadGroupBin
Aria.download(this).load(mUrls).stop();
break;
case R.id.cancel:
Aria.download(this).load(mUrls).cancel();
//Aria.download(this).load(mUrls).cancel();
Aria.download(this).removeAllTask(true);
new Handler().postDelayed(new Runnable() {
@Override public void run() {
L.d(TAG,
"size ==> " + Aria.download(DownloadGroupActivity.this).getTotleTaskList().size());
}
}, 1000);
break;
}
}
@ -116,6 +126,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
}
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
L.d(TAG, "group task cancel");
getBinding().setSpeed("");
getBinding().setProgress(0);
}

Loading…
Cancel
Save