This commit is contained in:
@ -16,7 +16,6 @@
|
|||||||
|
|
||||||
package com.arialyy.aria.core.command.normal;
|
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.download.DownloadTaskEntity;
|
||||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||||
import com.arialyy.aria.core.upload.UploadTaskEntity;
|
import com.arialyy.aria.core.upload.UploadTaskEntity;
|
||||||
@ -40,7 +39,7 @@ final class CancelAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
|
|||||||
mQueue.removeAllTask();
|
mQueue.removeAllTask();
|
||||||
if (mTaskEntity instanceof DownloadTaskEntity) {
|
if (mTaskEntity instanceof DownloadTaskEntity) {
|
||||||
handleDownloadRemove();
|
handleDownloadRemove();
|
||||||
} else {
|
} else if (mTaskEntity instanceof UploadTaskEntity){
|
||||||
handleUploadRemove();
|
handleUploadRemove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -50,6 +49,7 @@ final class CancelAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
|
|||||||
*/
|
*/
|
||||||
private void handleUploadRemove() {
|
private void handleUploadRemove() {
|
||||||
List<UploadTaskEntity> allEntity = DbEntity.findAllData(UploadTaskEntity.class);
|
List<UploadTaskEntity> allEntity = DbEntity.findAllData(UploadTaskEntity.class);
|
||||||
|
if (allEntity == null || allEntity.size() == 0) return;
|
||||||
for (UploadTaskEntity entity : allEntity) {
|
for (UploadTaskEntity entity : allEntity) {
|
||||||
CommonUtil.delUploadTaskConfig(mTaskEntity.removeFile, entity);
|
CommonUtil.delUploadTaskConfig(mTaskEntity.removeFile, entity);
|
||||||
}
|
}
|
||||||
@ -60,6 +60,7 @@ final class CancelAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
|
|||||||
*/
|
*/
|
||||||
private void handleDownloadRemove() {
|
private void handleDownloadRemove() {
|
||||||
List<DownloadTaskEntity> allEntity = DbEntity.findAllData(DownloadTaskEntity.class);
|
List<DownloadTaskEntity> allEntity = DbEntity.findAllData(DownloadTaskEntity.class);
|
||||||
|
if (allEntity == null || allEntity.size() == 0) return;
|
||||||
for (DownloadTaskEntity entity : allEntity) {
|
for (DownloadTaskEntity entity : allEntity) {
|
||||||
CommonUtil.delDownloadTaskConfig(mTaskEntity.removeFile, entity);
|
CommonUtil.delDownloadTaskConfig(mTaskEntity.removeFile, entity);
|
||||||
}
|
}
|
||||||
|
@ -242,9 +242,6 @@ public class DownloadReceiver extends AbsReceiver {
|
|||||||
|
|
||||||
Set<String> keys = ariaManager.getReceiver().keySet();
|
Set<String> keys = ariaManager.getReceiver().keySet();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
IReceiver receiver = ariaManager.getReceiver().get(key);
|
|
||||||
receiver.removeSchedulerListener();
|
|
||||||
receiver.unRegister();
|
|
||||||
ariaManager.getReceiver().remove(key);
|
ariaManager.getReceiver().remove(key);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -24,37 +24,37 @@ public interface IReceiver<ENTITY extends IEntity> {
|
|||||||
/**
|
/**
|
||||||
* Receiver 销毁
|
* 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 下载时为下载路径,上传时为文件路径
|
* @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.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import android.widget.Button;
|
import android.widget.Button;
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
@ -82,7 +84,15 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
|||||||
Aria.download(this).load(mUrls).stop();
|
Aria.download(this).load(mUrls).stop();
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
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;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -116,6 +126,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
|
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
|
||||||
|
L.d(TAG, "group task cancel");
|
||||||
getBinding().setSpeed("");
|
getBinding().setSpeed("");
|
||||||
getBinding().setProgress(0);
|
getBinding().setProgress(0);
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user