任务组子任务控制
This commit is contained in:
@@ -17,6 +17,7 @@ package com.arialyy.aria.core.download;
|
|||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
import com.arialyy.aria.core.download.downloader.IDownloadGroupListener;
|
import com.arialyy.aria.core.download.downloader.IDownloadGroupListener;
|
||||||
|
import com.arialyy.aria.core.inf.GroupSendParams;
|
||||||
import com.arialyy.aria.core.scheduler.ISchedulers;
|
import com.arialyy.aria.core.scheduler.ISchedulers;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -26,13 +27,16 @@ import com.arialyy.aria.core.scheduler.ISchedulers;
|
|||||||
class DownloadGroupListener extends BaseDListener<DownloadGroupEntity, DownloadGroupTask>
|
class DownloadGroupListener extends BaseDListener<DownloadGroupEntity, DownloadGroupTask>
|
||||||
implements IDownloadGroupListener {
|
implements IDownloadGroupListener {
|
||||||
private final String TAG = "DownloadGroupListener";
|
private final String TAG = "DownloadGroupListener";
|
||||||
|
private GroupSendParams<DownloadGroupTask, DownloadEntity> mSeedEntity;
|
||||||
|
|
||||||
DownloadGroupListener(DownloadGroupTask task, Handler outHandler) {
|
DownloadGroupListener(DownloadGroupTask task, Handler outHandler) {
|
||||||
super(task, outHandler);
|
super(task, outHandler);
|
||||||
|
mSeedEntity = new GroupSendParams<>();
|
||||||
|
mSeedEntity.groupTask = task;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSubPre(DownloadEntity subEntity) {
|
@Override public void onSubPre(DownloadEntity subEntity) {
|
||||||
sendInState2Target(ISchedulers.SUB_PRE);
|
sendInState2Target(ISchedulers.SUB_PRE, subEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void supportBreakpoint(boolean support, DownloadEntity subEntity) {
|
@Override public void supportBreakpoint(boolean support, DownloadEntity subEntity) {
|
||||||
@@ -40,31 +44,31 @@ class DownloadGroupListener extends BaseDListener<DownloadGroupEntity, DownloadG
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSubStart(DownloadEntity subEntity) {
|
@Override public void onSubStart(DownloadEntity subEntity) {
|
||||||
sendInState2Target(ISchedulers.SUB_START);
|
sendInState2Target(ISchedulers.SUB_START, subEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSubStop(DownloadEntity subEntity) {
|
@Override public void onSubStop(DownloadEntity subEntity) {
|
||||||
saveCurrentLocation();
|
saveCurrentLocation();
|
||||||
sendInState2Target(ISchedulers.SUB_STOP);
|
sendInState2Target(ISchedulers.SUB_STOP, subEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSubComplete(DownloadEntity subEntity) {
|
@Override public void onSubComplete(DownloadEntity subEntity) {
|
||||||
saveCurrentLocation();
|
saveCurrentLocation();
|
||||||
sendInState2Target(ISchedulers.SUB_COMPLETE);
|
sendInState2Target(ISchedulers.SUB_COMPLETE, subEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSubFail(DownloadEntity subEntity) {
|
@Override public void onSubFail(DownloadEntity subEntity) {
|
||||||
saveCurrentLocation();
|
saveCurrentLocation();
|
||||||
sendInState2Target(ISchedulers.SUB_FAIL);
|
sendInState2Target(ISchedulers.SUB_FAIL, subEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSubCancel(DownloadEntity entity) {
|
@Override public void onSubCancel(DownloadEntity subEntity) {
|
||||||
saveCurrentLocation();
|
saveCurrentLocation();
|
||||||
sendInState2Target(ISchedulers.SUB_CANCEL);
|
sendInState2Target(ISchedulers.SUB_CANCEL, subEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onSubRunning(DownloadEntity subEntity) {
|
@Override public void onSubRunning(DownloadEntity subEntity) {
|
||||||
sendInState2Target(ISchedulers.SUB_RUNNING);
|
sendInState2Target(ISchedulers.SUB_RUNNING, subEntity);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -72,9 +76,10 @@ class DownloadGroupListener extends BaseDListener<DownloadGroupEntity, DownloadG
|
|||||||
*
|
*
|
||||||
* @param state {@link ISchedulers#START}
|
* @param state {@link ISchedulers#START}
|
||||||
*/
|
*/
|
||||||
private void sendInState2Target(int state) {
|
private void sendInState2Target(int state, DownloadEntity subEntity) {
|
||||||
if (outHandler.get() != null) {
|
if (outHandler.get() != null) {
|
||||||
outHandler.get().obtainMessage(state, ISchedulers.IS_SUB_TASK, 0, mTask).sendToTarget();
|
mSeedEntity.entity = subEntity;
|
||||||
|
outHandler.get().obtainMessage(state, ISchedulers.IS_SUB_TASK, 0, mSeedEntity).sendToTarget();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -0,0 +1,34 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.arialyy.aria.core.inf;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by lyy on 2017/9/8.
|
||||||
|
* 任务组参数传递
|
||||||
|
*/
|
||||||
|
public class GroupSendParams<GROUP_TASK extends AbsGroupTask, ENTITY extends AbsNormalEntity> {
|
||||||
|
|
||||||
|
public GROUP_TASK groupTask;
|
||||||
|
public ENTITY entity;
|
||||||
|
|
||||||
|
public GroupSendParams() {
|
||||||
|
}
|
||||||
|
|
||||||
|
public GroupSendParams(GROUP_TASK groupTask, ENTITY entity) {
|
||||||
|
this.groupTask = groupTask;
|
||||||
|
this.entity = entity;
|
||||||
|
}
|
||||||
|
}
|
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.core.scheduler;
|
package com.arialyy.aria.core.scheduler;
|
||||||
|
|
||||||
import com.arialyy.aria.core.inf.AbsNormalTask;
|
import com.arialyy.aria.core.inf.AbsNormalEntity;
|
||||||
import com.arialyy.aria.core.inf.ITask;
|
import com.arialyy.aria.core.inf.ITask;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Aria.Lao on 2017/6/7.
|
* Created by Aria.Lao on 2017/6/7.
|
||||||
*/
|
*/
|
||||||
public class AbsSchedulerListener<TASK extends ITask, SUB_TASK extends AbsNormalTask> implements ISchedulerListener<TASK> {
|
public class AbsSchedulerListener<TASK extends ITask, SUB_ENTITY extends AbsNormalEntity> implements ISchedulerListener<TASK> {
|
||||||
|
|
||||||
@Override public void onPre(TASK task) {
|
@Override public void onPre(TASK task) {
|
||||||
|
|
||||||
@@ -67,31 +67,31 @@ public class AbsSchedulerListener<TASK extends ITask, SUB_TASK extends AbsNormal
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSubTaskPre(TASK task, SUB_TASK subTask) {
|
public void onSubTaskPre(TASK task, SUB_ENTITY subTask) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSubTaskStart(TASK task, SUB_TASK subTask) {
|
public void onSubTaskStart(TASK task, SUB_ENTITY subTask) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSubTaskStop(TASK task, SUB_TASK subTask) {
|
public void onSubTaskStop(TASK task, SUB_ENTITY subTask) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSubTaskCancel(TASK task, SUB_TASK subTask) {
|
public void onSubTaskCancel(TASK task, SUB_ENTITY subTask) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSubTaskComplete(TASK task, SUB_TASK subTask) {
|
public void onSubTaskComplete(TASK task, SUB_ENTITY subTask) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSubTaskFail(TASK task, SUB_TASK subTask) {
|
public void onSubTaskFail(TASK task, SUB_ENTITY subTask) {
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onSubTaskRunning(TASK task, SUB_TASK subTask) {
|
public void onSubTaskRunning(TASK task, SUB_ENTITY subTask) {
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@@ -21,9 +21,10 @@ import android.util.Log;
|
|||||||
import com.arialyy.aria.core.AriaManager;
|
import com.arialyy.aria.core.AriaManager;
|
||||||
import com.arialyy.aria.core.download.DownloadTask;
|
import com.arialyy.aria.core.download.DownloadTask;
|
||||||
import com.arialyy.aria.core.inf.AbsEntity;
|
import com.arialyy.aria.core.inf.AbsEntity;
|
||||||
import com.arialyy.aria.core.inf.AbsNormalTask;
|
import com.arialyy.aria.core.inf.AbsNormalEntity;
|
||||||
import com.arialyy.aria.core.inf.AbsTask;
|
import com.arialyy.aria.core.inf.AbsTask;
|
||||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||||
|
import com.arialyy.aria.core.inf.GroupSendParams;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
import com.arialyy.aria.core.inf.IEntity;
|
||||||
import com.arialyy.aria.core.queue.ITaskQueue;
|
import com.arialyy.aria.core.queue.ITaskQueue;
|
||||||
import com.arialyy.aria.core.upload.UploadTask;
|
import com.arialyy.aria.core.upload.UploadTask;
|
||||||
@@ -46,7 +47,8 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY extends A
|
|||||||
|
|
||||||
protected QUEUE mQueue;
|
protected QUEUE mQueue;
|
||||||
|
|
||||||
private Map<String, AbsSchedulerListener<TASK, AbsNormalTask>> mObservers = new ConcurrentHashMap<>();
|
private Map<String, AbsSchedulerListener<TASK, AbsNormalEntity>> mObservers =
|
||||||
|
new ConcurrentHashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置调度器类型
|
* 设置调度器类型
|
||||||
@@ -60,7 +62,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY extends A
|
|||||||
|
|
||||||
@Override public void register(Object obj) {
|
@Override public void register(Object obj) {
|
||||||
String targetName = obj.getClass().getName();
|
String targetName = obj.getClass().getName();
|
||||||
AbsSchedulerListener<TASK, AbsNormalTask> listener = mObservers.get(targetName);
|
AbsSchedulerListener<TASK, AbsNormalEntity> listener = mObservers.get(targetName);
|
||||||
if (listener == null) {
|
if (listener == null) {
|
||||||
listener = createListener(targetName);
|
listener = createListener(targetName);
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
@@ -73,9 +75,9 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY extends A
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public void unRegister(Object obj) {
|
@Override public void unRegister(Object obj) {
|
||||||
for (Iterator<Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalTask>>> iter =
|
for (Iterator<Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalEntity>>> iter =
|
||||||
mObservers.entrySet().iterator(); iter.hasNext(); ) {
|
mObservers.entrySet().iterator(); iter.hasNext(); ) {
|
||||||
Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalTask>> entry = iter.next();
|
Map.Entry<String, AbsSchedulerListener<TASK, AbsNormalEntity>> entry = iter.next();
|
||||||
if (entry.getKey().equals(obj.getClass().getName())) iter.remove();
|
if (entry.getKey().equals(obj.getClass().getName())) iter.remove();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -85,11 +87,11 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY extends A
|
|||||||
*
|
*
|
||||||
* @param targetName 通过观察者创建对应的Aria事件代理
|
* @param targetName 通过观察者创建对应的Aria事件代理
|
||||||
*/
|
*/
|
||||||
private AbsSchedulerListener<TASK, AbsNormalTask> createListener(String targetName) {
|
private AbsSchedulerListener<TASK, AbsNormalEntity> createListener(String targetName) {
|
||||||
AbsSchedulerListener<TASK, AbsNormalTask> listener = null;
|
AbsSchedulerListener<TASK, AbsNormalEntity> listener = null;
|
||||||
try {
|
try {
|
||||||
Class clazz = Class.forName(targetName + getProxySuffix());
|
Class clazz = Class.forName(targetName + getProxySuffix());
|
||||||
listener = (AbsSchedulerListener<TASK, AbsNormalTask>) clazz.newInstance();
|
listener = (AbsSchedulerListener<TASK, AbsNormalEntity>) clazz.newInstance();
|
||||||
} catch (ClassNotFoundException e) {
|
} catch (ClassNotFoundException e) {
|
||||||
Log.e(TAG, targetName + ",没有Aria的Download或Upload注解方法");
|
Log.e(TAG, targetName + ",没有Aria的Download或Upload注解方法");
|
||||||
} catch (InstantiationException e) {
|
} catch (InstantiationException e) {
|
||||||
@@ -101,49 +103,54 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY extends A
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean handleMessage(Message msg) {
|
@Override public boolean handleMessage(Message msg) {
|
||||||
|
if (msg.arg1 == IS_SUB_TASK) {
|
||||||
|
return handleSubEvent(msg);
|
||||||
|
}
|
||||||
|
|
||||||
TASK task = (TASK) msg.obj;
|
TASK task = (TASK) msg.obj;
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
Log.e(TAG, "请传入下载任务");
|
Log.e(TAG, "请传入下载任务");
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (msg.arg1 == IS_SUB_TASK) {
|
|
||||||
handleSubEvent(task, msg.what);
|
|
||||||
} else {
|
|
||||||
handleNormalEvent(task, msg.what);
|
handleNormalEvent(task, msg.what);
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理任务组子任务事件
|
* 处理任务组子任务事件
|
||||||
*/
|
*/
|
||||||
private void handleSubEvent(TASK task, int what) {
|
private boolean handleSubEvent(Message msg) {
|
||||||
ENTITY entity = task.getEntity();
|
GroupSendParams params = (GroupSendParams) msg.obj;
|
||||||
if (mObservers.size() > 0) {
|
if (mObservers.size() > 0) {
|
||||||
Set<String> keys = mObservers.keySet();
|
Set<String> keys = mObservers.keySet();
|
||||||
for (String key : keys) {
|
for (String key : keys) {
|
||||||
AbsSchedulerListener<TASK, AbsNormalTask> listener = mObservers.get(key);
|
AbsSchedulerListener<TASK, AbsNormalEntity> listener = mObservers.get(key);
|
||||||
switch (what) {
|
switch (msg.what) {
|
||||||
case SUB_PRE:
|
case SUB_PRE:
|
||||||
//listener.onSubTaskPre(task, );
|
listener.onSubTaskPre((TASK) params.groupTask, params.entity);
|
||||||
break;
|
break;
|
||||||
case SUB_START:
|
case SUB_START:
|
||||||
|
listener.onSubTaskStart((TASK) params.groupTask, params.entity);
|
||||||
break;
|
break;
|
||||||
case SUB_STOP:
|
case SUB_STOP:
|
||||||
|
listener.onSubTaskStop((TASK) params.groupTask, params.entity);
|
||||||
break;
|
break;
|
||||||
case SUB_FAIL:
|
case SUB_FAIL:
|
||||||
|
listener.onSubTaskFail((TASK) params.groupTask, params.entity);
|
||||||
break;
|
break;
|
||||||
case SUB_RUNNING:
|
case SUB_RUNNING:
|
||||||
|
listener.onSubTaskRunning((TASK) params.groupTask, params.entity);
|
||||||
break;
|
break;
|
||||||
case SUB_CANCEL:
|
case SUB_CANCEL:
|
||||||
|
listener.onSubTaskCancel((TASK) params.groupTask, params.entity);
|
||||||
break;
|
break;
|
||||||
case SUB_COMPLETE:
|
case SUB_COMPLETE:
|
||||||
|
listener.onSubTaskComplete((TASK) params.groupTask, params.entity);
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -189,7 +196,8 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY extends A
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void callback(int state, TASK task, AbsSchedulerListener<TASK, AbsNormalTask> listener) {
|
private void callback(int state, TASK task,
|
||||||
|
AbsSchedulerListener<TASK, AbsNormalEntity> listener) {
|
||||||
if (listener != null) {
|
if (listener != null) {
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
Log.e(TAG, "TASK 为null,回调失败");
|
Log.e(TAG, "TASK 为null,回调失败");
|
||||||
|
@@ -138,7 +138,7 @@ class ElementHandler {
|
|||||||
void createProxyFile() {
|
void createProxyFile() {
|
||||||
try {
|
try {
|
||||||
new EventProxyFiler(mFiler, mPbUtil).createEventProxyFile();
|
new EventProxyFiler(mFiler, mPbUtil).createEventProxyFile();
|
||||||
//new CountFiler(mFiler, mPbUtil).createCountFile();
|
new CountFiler(mFiler, mPbUtil).createCountFile();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
@@ -112,7 +112,7 @@ final class EventProxyFiler {
|
|||||||
|
|
||||||
String callCode;
|
String callCode;
|
||||||
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
||||||
callCode = "task, subTask";
|
callCode = "task, subEntity";
|
||||||
} else {
|
} else {
|
||||||
callCode = "task";
|
callCode = "task";
|
||||||
}
|
}
|
||||||
@@ -143,9 +143,9 @@ final class EventProxyFiler {
|
|||||||
|
|
||||||
//任务组接口
|
//任务组接口
|
||||||
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
||||||
ClassName subTask = ClassName.get(TaskEnum.DOWNLOAD.pkg, TaskEnum.DOWNLOAD.className);
|
ClassName subTask = ClassName.get(TaskEnum.DOWNLOAD_ENTITY.pkg, TaskEnum.DOWNLOAD_ENTITY.className);
|
||||||
ParameterSpec subTaskParam =
|
ParameterSpec subTaskParam =
|
||||||
ParameterSpec.builder(subTask, "subTask").addModifiers(Modifier.FINAL).build();
|
ParameterSpec.builder(subTask, "subEntity").addModifiers(Modifier.FINAL).build();
|
||||||
|
|
||||||
builder.addParameter(subTaskParam);
|
builder.addParameter(subTaskParam);
|
||||||
}
|
}
|
||||||
|
@@ -84,7 +84,7 @@ class ParamObtainUtil {
|
|||||||
proxyEntity.proxyClassName = proxyEntity.className + taskEnum.proxySuffix;
|
proxyEntity.proxyClassName = proxyEntity.className + taskEnum.proxySuffix;
|
||||||
proxyEntity.mainTaskEnum = taskEnum;
|
proxyEntity.mainTaskEnum = taskEnum;
|
||||||
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB || taskEnum == TaskEnum.DOWNLOAD_GROUP) {
|
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB || taskEnum == TaskEnum.DOWNLOAD_GROUP) {
|
||||||
proxyEntity.subTaskEnum = TaskEnum.DOWNLOAD;
|
proxyEntity.subTaskEnum = TaskEnum.DOWNLOAD_ENTITY;
|
||||||
}
|
}
|
||||||
mMethodParams.put(key, proxyEntity);
|
mMethodParams.put(key, proxyEntity);
|
||||||
}
|
}
|
||||||
@@ -214,7 +214,7 @@ class ParamObtainUtil {
|
|||||||
*/
|
*/
|
||||||
private String getCheckSubParams(TaskEnum taskEnum) {
|
private String getCheckSubParams(TaskEnum taskEnum) {
|
||||||
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
if (taskEnum == TaskEnum.DOWNLOAD_GROUP_SUB) {
|
||||||
return TaskEnum.DOWNLOAD.pkg + "." + TaskEnum.DOWNLOAD.className;
|
return TaskEnum.DOWNLOAD_ENTITY.pkg + "." + TaskEnum.DOWNLOAD_ENTITY.className;
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
|
@@ -44,7 +44,7 @@ class ProxyClassParam {
|
|||||||
/**
|
/**
|
||||||
* 子任务泛型参数
|
* 子任务泛型参数
|
||||||
*/
|
*/
|
||||||
TaskEnum subTaskEnum = TaskEnum.NORMAL;
|
TaskEnum subTaskEnum = TaskEnum.NORMAL_ENTITY;
|
||||||
|
|
||||||
Set<TaskEnum> taskEnums;
|
Set<TaskEnum> taskEnums;
|
||||||
Map<String, Set<String>> keyMappings = new HashMap<>();
|
Map<String, Set<String>> keyMappings = new HashMap<>();
|
||||||
|
@@ -23,10 +23,11 @@ enum TaskEnum {
|
|||||||
DOWNLOAD("com.arialyy.aria.core.download", "DownloadTask",
|
DOWNLOAD("com.arialyy.aria.core.download", "DownloadTask",
|
||||||
"$$DownloadListenerProxy"), DOWNLOAD_GROUP("com.arialyy.aria.core.download",
|
"$$DownloadListenerProxy"), DOWNLOAD_GROUP("com.arialyy.aria.core.download",
|
||||||
"DownloadGroupTask", "$$DownloadGroupListenerProxy"), DOWNLOAD_GROUP_SUB(
|
"DownloadGroupTask", "$$DownloadGroupListenerProxy"), DOWNLOAD_GROUP_SUB(
|
||||||
"com.arialyy.aria.core.download", "DownloadGroupTask",
|
"com.arialyy.aria.core.download", "DownloadGroupTask", "$$DownloadGroupListenerProxy"), UPLOAD(
|
||||||
"$$DownloadGroupListenerProxy"), UPLOAD("com.arialyy.aria.core.upload", "UploadTask",
|
"com.arialyy.aria.core.upload", "UploadTask", "$$UploadListenerProxy"), UPLOAD_GROUP(
|
||||||
"$$UploadListenerProxy"), UPLOAD_GROUP("com.arialyy.aria.core.upload", "UploadGroupTask",
|
"com.arialyy.aria.core.upload", "UploadGroupTask",
|
||||||
"$$UploadGroupListenerProxy"), NORMAL("com.arialyy.aria.core.inf", "AbsNormalTask", "");
|
"$$UploadGroupListenerProxy"), NORMAL_ENTITY("com.arialyy.aria.core.inf", "AbsNormalEntity",
|
||||||
|
""), DOWNLOAD_ENTITY("com.arialyy.aria.core.download", "DownloadEntity", "");
|
||||||
|
|
||||||
String pkg, className, proxySuffix;
|
String pkg, className, proxySuffix;
|
||||||
|
|
||||||
|
@@ -18,7 +18,6 @@ package com.arialyy.simple.download;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.Menu;
|
import android.view.Menu;
|
||||||
import android.view.MenuItem;
|
import android.view.MenuItem;
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
@@ -29,10 +28,10 @@ import butterknife.Bind;
|
|||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
import com.arialyy.annotations.DownloadGroup;
|
import com.arialyy.annotations.DownloadGroup;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.download.DownloadGroupTask;
|
import com.arialyy.aria.core.download.DownloadGroupTask;
|
||||||
import com.arialyy.aria.core.download.DownloadTarget;
|
import com.arialyy.aria.core.download.DownloadTarget;
|
||||||
import com.arialyy.aria.core.download.DownloadTask;
|
import com.arialyy.aria.core.download.DownloadTask;
|
||||||
import com.arialyy.aria.core.download.DownloadTaskEntity;
|
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
import com.arialyy.aria.core.inf.IEntity;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.frame.util.show.L;
|
import com.arialyy.frame.util.show.L;
|
||||||
@@ -47,7 +46,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
private static final String DOWNLOAD_URL =
|
private static final String DOWNLOAD_URL =
|
||||||
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
||||||
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
||||||
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
//"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
||||||
|
"http://sitcac.daxincf.cn/wp-content/uploads/swift_vido/01/element.mp4";
|
||||||
//"http://120.25.196.56:8000/filereq?id=15692406294&ipncid=105635&client=android&filename=20170819185541.avi";
|
//"http://120.25.196.56:8000/filereq?id=15692406294&ipncid=105635&client=android&filename=20170819185541.avi";
|
||||||
//"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt";
|
//"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt";
|
||||||
//"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815";
|
//"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815";
|
||||||
@@ -116,14 +116,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onSubTaskFail void onSubTaskFail(DownloadGroupTask groupTask, DownloadTask subTask){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@DownloadGroup.onPre void onGroupPre(DownloadGroupTask groupTask){
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
@Download.onPre(DOWNLOAD_URL) protected void onPre(DownloadTask task) {
|
@Download.onPre(DOWNLOAD_URL) protected void onPre(DownloadTask task) {
|
||||||
setBtState(false);
|
setBtState(false);
|
||||||
}
|
}
|
||||||
|
@@ -17,15 +17,14 @@ package com.arialyy.simple.download.group;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.view.Gravity;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import butterknife.Bind;
|
import butterknife.Bind;
|
||||||
import com.arialyy.annotations.DownloadGroup;
|
import com.arialyy.annotations.DownloadGroup;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
||||||
import com.arialyy.aria.core.download.DownloadGroupTask;
|
import com.arialyy.aria.core.download.DownloadGroupTask;
|
||||||
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
|
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
|
||||||
import com.arialyy.frame.util.AndroidUtils;
|
|
||||||
import com.arialyy.frame.util.show.L;
|
import com.arialyy.frame.util.show.L;
|
||||||
import com.arialyy.frame.util.show.T;
|
import com.arialyy.frame.util.show.T;
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
@@ -99,6 +98,11 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@DownloadGroup.onSubTaskRunning void onSubTaskRunning(DownloadGroupTask groupTask,
|
||||||
|
DownloadEntity subEntity) {
|
||||||
|
L.d(TAG, subEntity.getPercent() + "");
|
||||||
|
}
|
||||||
|
|
||||||
@DownloadGroup.onPre() protected void onPre(DownloadGroupTask task) {
|
@DownloadGroup.onPre() protected void onPre(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group pre");
|
L.d(TAG, "group pre");
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user