diff --git a/.idea/misc.xml b/.idea/misc.xml
index fbb68289..5d199810 100644
--- a/.idea/misc.xml
+++ b/.idea/misc.xml
@@ -37,7 +37,7 @@
-
+
diff --git a/Aria/src/main/java/com/arialyy/aria/core/Aria.java b/Aria/src/main/java/com/arialyy/aria/core/Aria.java
index 62fd6880..aff2fc08 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/Aria.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/Aria.java
@@ -27,8 +27,8 @@ import android.content.Context;
import android.os.Build;
import android.widget.PopupWindow;
import com.arialyy.aria.core.download.DownloadReceiver;
-import com.arialyy.aria.core.download.scheduler.OnSchedulerListener;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.scheduler.OnSchedulerListener;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Created by lyy on 2016/12/1.
diff --git a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
index cf474214..e2bd417b 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
@@ -27,13 +27,12 @@ import android.support.v4.app.Fragment;
import android.text.TextUtils;
import android.util.Log;
import android.widget.PopupWindow;
-import com.arialyy.aria.core.download.command.IDownloadCmd;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadReceiver;
import com.arialyy.aria.core.inf.ICmd;
import com.arialyy.aria.core.inf.IReceiver;
-import com.arialyy.aria.core.download.queue.DownloadTaskQueue;
-import com.arialyy.aria.core.download.queue.ITaskQueue;
+import com.arialyy.aria.core.queue.DownloadTaskQueue;
+import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.upload.UploadReceiver;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.orm.DbUtil;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/command/AddCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java
similarity index 55%
rename from Aria/src/main/java/com/arialyy/aria/core/download/command/AddCmd.java
rename to Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java
index 45698636..fdfec982 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/command/AddCmd.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java
@@ -14,32 +14,41 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.command;
+package com.arialyy.aria.core.command;
import android.util.Log;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.inf.ITaskEntity;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Created by lyy on 2016/8/22.
* 添加任务的命令
*/
-class AddCmd extends IDownloadCmd {
+class AddCmd extends IDownloadCmd {
- AddCmd(DownloadTaskEntity entity) {
- super(entity);
- }
-
- AddCmd(String targetName, DownloadTaskEntity entity) {
+ AddCmd(String targetName, T entity) {
super(targetName, entity);
}
@Override public void executeCmd() {
- DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
- if (task == null) {
- mQueue.createTask(mTargetName, mEntity);
- } else {
- Log.w(TAG, "添加命令执行失败,【该任务已经存在】");
- }
+
}
+
+ //AddCmd(DownloadTaskEntity entity) {
+ // super(entity);
+ //}
+ //
+ //AddCmd(String targetName, DownloadTaskEntity entity) {
+ // super(targetName, entity);
+ //}
+ //
+ //@Override public void executeCmd() {
+ // DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
+ // if (task == null) {
+ // mQueue.createTask(mTargetName, mEntity);
+ // } else {
+ // Log.w(TAG, "添加命令执行失败,【该任务已经存在】");
+ // }
+ //}
}
\ No newline at end of file
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/command/CancelCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/CancelCmd.java
similarity index 51%
rename from Aria/src/main/java/com/arialyy/aria/core/download/command/CancelCmd.java
rename to Aria/src/main/java/com/arialyy/aria/core/command/CancelCmd.java
index a16437da..de97c87b 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/command/CancelCmd.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/command/CancelCmd.java
@@ -14,35 +14,43 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.command;
+package com.arialyy.aria.core.command;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.inf.ITaskEntity;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Created by lyy on 2016/9/20.
* 取消命令
*/
-class CancelCmd extends IDownloadCmd {
-
- CancelCmd(DownloadTaskEntity entity) {
- super(entity);
- }
-
- CancelCmd(String targetName, DownloadTaskEntity entity) {
+class CancelCmd extends IDownloadCmd {
+ CancelCmd(String targetName, T entity) {
super(targetName, entity);
}
@Override public void executeCmd() {
- DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
- if (task == null) {
- task = mQueue.createTask(mTargetName, mEntity);
- }
- if (task != null) {
- if (mTargetName != null) {
- task.setTargetName(mTargetName);
- }
- mQueue.cancelTask(task);
- }
+
}
+
+ //CancelCmd(DownloadTaskEntity entity) {
+ // super(entity);
+ //}
+ //
+ //CancelCmd(String targetName, DownloadTaskEntity entity) {
+ // super(targetName, entity);
+ //}
+ //
+ //@Override public void executeCmd() {
+ // DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
+ // if (task == null) {
+ // task = mQueue.createTask(mTargetName, mEntity);
+ // }
+ // if (task != null) {
+ // if (mTargetName != null) {
+ // task.setTargetName(mTargetName);
+ // }
+ // mQueue.cancelTask(task);
+ // }
+ //}
}
\ No newline at end of file
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/command/CmdFactory.java b/Aria/src/main/java/com/arialyy/aria/core/command/CmdFactory.java
similarity index 54%
rename from Aria/src/main/java/com/arialyy/aria/core/download/command/CmdFactory.java
rename to Aria/src/main/java/com/arialyy/aria/core/command/CmdFactory.java
index e248b1bb..4c2a2526 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/command/CmdFactory.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/command/CmdFactory.java
@@ -14,9 +14,9 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.command;
+package com.arialyy.aria.core.command;
-import com.arialyy.aria.core.download.DownloadTaskEntity;
+import com.arialyy.aria.core.inf.ITaskEntity;
/**
* Created by Lyy on 2016/9/23.
@@ -30,7 +30,7 @@ public class CmdFactory {
/**
* 启动任务
*/
- public static final int TASK_START = 0x123;
+ public static final int TASK_START = 0x123;
/**
* 恢复任务
*/
@@ -42,10 +42,10 @@ public class CmdFactory {
/**
* 停止任务
*/
- public static final int TASK_STOP = 0x125;
+ public static final int TASK_STOP = 0x125;
public static final int TASK_SINGLE = 0x126;
- private static final Object LOCK = new Object();
+ private static final Object LOCK = new Object();
private static volatile CmdFactory INSTANCE = null;
private CmdFactory() {
@@ -61,36 +61,13 @@ public class CmdFactory {
return INSTANCE;
}
- /**
- * @param entity 下载实体
- * @param type 命令类型{@link #TASK_CREATE}、{@link #TASK_START}、{@link #TASK_CANCEL}、{@link
- * #TASK_STOP}
- */
- public IDownloadCmd createCmd(DownloadTaskEntity entity, int type) {
- switch (type) {
- case TASK_CREATE:
- return createAddCmd(entity);
- case TASK_RESUME:
- case TASK_START:
- return createStartCmd(entity);
- case TASK_CANCEL:
- return createCancelCmd(entity);
- case TASK_STOP:
- return createStopCmd(entity);
- case TASK_SINGLE:
- //return new SingleCmd(entity);
- default:
- return null;
- }
- }
-
/**
* @param target 创建任务的对象
* @param entity 下载实体
* @param type 命令类型{@link #TASK_CREATE}、{@link #TASK_START}、{@link #TASK_CANCEL}、{@link
* #TASK_STOP}
*/
- public IDownloadCmd createCmd(String target, DownloadTaskEntity entity, int type) {
+ public IDownloadCmd createCmd(String target, T entity, int type) {
switch (type) {
case TASK_CREATE:
return createAddCmd(target, entity);
@@ -113,43 +90,25 @@ public class CmdFactory {
*
* @return {@link StopCmd}
*/
- private StopCmd createStopCmd(String target, DownloadTaskEntity entity) {
+ private StopCmd createStopCmd(String target, T entity) {
return new StopCmd(target, entity);
}
- /**
- * 创建停止命令
- *
- * @return {@link StopCmd}
- */
- private StopCmd createStopCmd(DownloadTaskEntity entity) {
- return new StopCmd(entity);
- }
-
/**
* 创建下载任务命令
*
* @return {@link AddCmd}
*/
- private AddCmd createAddCmd(String target, DownloadTaskEntity entity) {
+ private AddCmd createAddCmd(String target, T entity) {
return new AddCmd(target, entity);
}
- /**
- * 创建下载任务命令
- *
- * @return {@link AddCmd}
- */
- private AddCmd createAddCmd(DownloadTaskEntity entity) {
- return new AddCmd(entity);
- }
-
/**
* 创建启动下载命令
*
* @return {@link StartCmd}
*/
- private StartCmd createStartCmd(String target, DownloadTaskEntity entity) {
+ private StartCmd createStartCmd(String target, T entity) {
return new StartCmd(target, entity);
}
@@ -158,25 +117,7 @@ public class CmdFactory {
*
* @return {@link StartCmd}
*/
- private StartCmd createStartCmd(DownloadTaskEntity entity) {
- return new StartCmd(entity);
- }
-
- /**
- * 创建 取消下载的命令
- *
- * @return {@link CancelCmd}
- */
- private CancelCmd createCancelCmd(String target, DownloadTaskEntity entity) {
+ private CancelCmd createCancelCmd(String target, T entity) {
return new CancelCmd(target, entity);
}
-
- /**
- * 创建 取消下载的命令
- *
- * @return {@link CancelCmd}
- */
- private CancelCmd createCancelCmd(DownloadTaskEntity entity) {
- return new CancelCmd(entity);
- }
}
\ No newline at end of file
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/command/IDownloadCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/IDownloadCmd.java
similarity index 73%
rename from Aria/src/main/java/com/arialyy/aria/core/download/command/IDownloadCmd.java
rename to Aria/src/main/java/com/arialyy/aria/core/command/IDownloadCmd.java
index b0d47767..54d10401 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/command/IDownloadCmd.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/command/IDownloadCmd.java
@@ -14,12 +14,15 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.command;
+package com.arialyy.aria.core.command;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.queue.ITaskQueue;
+import com.arialyy.aria.core.inf.ITaskEntity;
+import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.inf.ICmd;
+import com.arialyy.aria.core.task.DownloadTask;
+import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
@@ -27,28 +30,20 @@ import com.arialyy.aria.util.CommonUtil;
* Created by lyy on 2016/8/22.
* 下载命令
*/
-public abstract class IDownloadCmd implements ICmd{
+public abstract class IDownloadCmd implements ICmd {
ITaskQueue mQueue;
- DownloadTaskEntity mEntity;
+ T mEntity;
String TAG;
String mTargetName;
- /**
- * @param entity 下载实体
- */
- IDownloadCmd(DownloadTaskEntity entity) {
- this(null, entity);
- }
-
/**
* @param targetName 产生任务的对象名
*/
- IDownloadCmd(String targetName, DownloadTaskEntity entity) {
- CheckUtil.checkDownloadEntity(entity.downloadEntity);
+ IDownloadCmd(String targetName, T entity) {
+ CheckUtil.checkTaskEntity(entity);
mTargetName = targetName;
mEntity = entity;
TAG = CommonUtil.getClassName(this);
mQueue = AriaManager.getInstance(AriaManager.APP).getTaskQueue();
}
-
}
\ No newline at end of file
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/command/StartCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java
similarity index 53%
rename from Aria/src/main/java/com/arialyy/aria/core/download/command/StartCmd.java
rename to Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java
index 316db667..3ecabcbc 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/command/StartCmd.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java
@@ -14,33 +14,42 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.command;
+package com.arialyy.aria.core.command;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.inf.ITaskEntity;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Created by lyy on 2016/8/22.
* 开始命令
*/
-class StartCmd extends IDownloadCmd {
+class StartCmd extends IDownloadCmd {
- StartCmd(DownloadTaskEntity entity) {
- super(entity);
- }
-
- StartCmd(String targetName, DownloadTaskEntity entity) {
+ StartCmd(String targetName, T entity) {
super(targetName, entity);
}
@Override public void executeCmd() {
- DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
- if (task == null) {
- task = mQueue.createTask(mTargetName, mEntity);
- }
- if (task != null) {
- task.setTargetName(mTargetName);
- mQueue.startTask(task);
- }
+
}
+
+ //StartCmd(DownloadTaskEntity entity) {
+ // super(entity);
+ //}
+ //
+ //StartCmd(String targetName, DownloadTaskEntity entity) {
+ // super(targetName, entity);
+ //}
+ //
+ //@Override public void executeCmd() {
+ // DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
+ // if (task == null) {
+ // task = mQueue.createTask(mTargetName, mEntity);
+ // }
+ // if (task != null) {
+ // task.setTargetName(mTargetName);
+ // mQueue.startTask(task);
+ // }
+ //}
}
\ No newline at end of file
diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/StopCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/StopCmd.java
new file mode 100644
index 00000000..b13f62e3
--- /dev/null
+++ b/Aria/src/main/java/com/arialyy/aria/core/command/StopCmd.java
@@ -0,0 +1,64 @@
+/*
+ * 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.command;
+
+import android.text.TextUtils;
+import android.util.Log;
+import com.arialyy.aria.core.download.DownloadEntity;
+import com.arialyy.aria.core.download.DownloadTaskEntity;
+import com.arialyy.aria.core.inf.ITaskEntity;
+import com.arialyy.aria.core.task.DownloadTask;
+
+/**
+ * Created by lyy on 2016/9/20.
+ * 停止命令
+ */
+class StopCmd extends IDownloadCmd {
+
+ StopCmd(String targetName, T entity) {
+ super(targetName, entity);
+ }
+
+ @Override public void executeCmd() {
+
+ }
+
+ //StopCmd(DownloadTaskEntity entity) {
+ // super(entity);
+ //}
+ //
+ //StopCmd(String targetName, DownloadTaskEntity entity) {
+ // super(targetName, entity);
+ //}
+ //
+ //@Override public void executeCmd() {
+ // DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
+ // if (task == null) {
+ // if (mEntity.downloadEntity.getState() == DownloadEntity.STATE_DOWNLOAD_ING) {
+ // task = mQueue.createTask(mTargetName, mEntity);
+ // mQueue.stopTask(task);
+ // } else {
+ // Log.w(TAG, "停止命令执行失败,【调度器中没有该任务】");
+ // }
+ // } else {
+ // if (!TextUtils.isEmpty(mTargetName)) {
+ // task.setTargetName(mTargetName);
+ // }
+ // mQueue.stopTask(task);
+ // }
+ //}
+}
\ No newline at end of file
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java
index af97dc53..0a255ddd 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadEntity.java
@@ -19,6 +19,7 @@ package com.arialyy.aria.core.download;
import android.os.Parcel;
import android.os.Parcelable;
+import com.arialyy.aria.core.inf.ITaskEntity;
import com.arialyy.aria.orm.Ignore;
import com.arialyy.aria.orm.DbEntity;
@@ -28,7 +29,7 @@ import com.arialyy.aria.orm.DbEntity;
* !!! 注意:CREATOR要进行@Ignore注解
* !!!并且需要Parcelable时需要手动填写rowID;
*/
-public class DownloadEntity extends DbEntity implements Parcelable {
+public class DownloadEntity extends DbEntity implements Parcelable{
/**
* 其它状态
*/
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 6979e802..befae967 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
@@ -18,10 +18,10 @@ package com.arialyy.aria.core.download;
import android.support.annotation.NonNull;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.IReceiver;
-import com.arialyy.aria.core.download.command.CmdFactory;
-import com.arialyy.aria.core.download.command.IDownloadCmd;
-import com.arialyy.aria.core.download.scheduler.DownloadSchedulers;
-import com.arialyy.aria.core.download.scheduler.OnSchedulerListener;
+import com.arialyy.aria.core.command.CmdFactory;
+import com.arialyy.aria.core.command.IDownloadCmd;
+import com.arialyy.aria.core.scheduler.DownloadSchedulers;
+import com.arialyy.aria.core.scheduler.OnSchedulerListener;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.util.ArrayList;
@@ -70,15 +70,13 @@ public class DownloadReceiver implements IReceiver {
/**
* 移除回调
*/
- @Override
- public void removeSchedulerListener() {
+ @Override public void removeSchedulerListener() {
if (listener != null) {
DownloadSchedulers.getInstance().removeSchedulerListener(targetName, listener);
}
}
- @Override
- public void destroy() {
+ @Override public void destroy() {
targetName = null;
listener = null;
}
@@ -114,8 +112,8 @@ public class DownloadReceiver implements IReceiver {
List stopCmds = new ArrayList<>();
for (DownloadEntity entity : allEntity) {
if (entity.getState() == DownloadEntity.STATE_DOWNLOAD_ING) {
- stopCmds.add(
- CommonUtil.createDownloadCmd(new DownloadTaskEntity(entity), CmdFactory.TASK_STOP));
+ stopCmds.add(CommonUtil.createDownloadCmd(targetName, new DownloadTaskEntity(entity),
+ CmdFactory.TASK_STOP));
}
}
ariaManager.setCmds(stopCmds).exe();
@@ -129,8 +127,8 @@ public class DownloadReceiver implements IReceiver {
List allEntity = ariaManager.getAllDownloadEntity();
List cancelCmds = new ArrayList<>();
for (DownloadEntity entity : allEntity) {
- cancelCmds.add(
- CommonUtil.createDownloadCmd(new DownloadTaskEntity(entity), CmdFactory.TASK_CANCEL));
+ cancelCmds.add(CommonUtil.createDownloadCmd(targetName, new DownloadTaskEntity(entity),
+ CmdFactory.TASK_CANCEL));
}
ariaManager.setCmds(cancelCmds).exe();
Set keys = ariaManager.getReceiver().keySet();
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
index f168d10b..59e19b38 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
@@ -19,8 +19,8 @@ import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.RequestEnum;
-import com.arialyy.aria.core.download.command.CmdFactory;
-import com.arialyy.aria.core.download.command.IDownloadCmd;
+import com.arialyy.aria.core.command.CmdFactory;
+import com.arialyy.aria.core.command.IDownloadCmd;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.util.ArrayList;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTaskEntity.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTaskEntity.java
index b28ff240..91d15f7b 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTaskEntity.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTaskEntity.java
@@ -16,6 +16,7 @@
package com.arialyy.aria.core.download;
import com.arialyy.aria.core.RequestEnum;
+import com.arialyy.aria.core.inf.ITaskEntity;
import java.util.HashMap;
import java.util.Map;
@@ -23,7 +24,7 @@ import java.util.Map;
* Created by Aria.Lao on 2017/1/23.
* 下载任务实体
*/
-public class DownloadTaskEntity {
+public class DownloadTaskEntity implements ITaskEntity {
public DownloadEntity downloadEntity;
public RequestEnum requestEnum = RequestEnum.GET;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/command/SingleCmd.java b/Aria/src/main/java/com/arialyy/aria/core/download/command/SingleCmd.java
deleted file mode 100644
index b816ac00..00000000
--- a/Aria/src/main/java/com/arialyy/aria/core/download/command/SingleCmd.java
+++ /dev/null
@@ -1,48 +0,0 @@
-///*
-// * 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.command.download;
-//
-//import android.util.Log;
-//import com.arialyy.aria.core.download.DownloadEntity;
-//import com.arialyy.aria.core.task.DownloadTask;
-//
-///**
-// * Created by lyy on 2016/11/30.
-// * 获取任务状态命令
-// */
-//class SingleCmd extends IDownloadCmd {
-// /**
-// * @param entity 下载实体
-// */
-// SingleCmd(String target, DownloadEntity entity) {
-// super(target, entity);
-// }
-//
-// SingleCmd(DownloadEntity entity) {
-// super(entity);
-// }
-//
-// @Override public void executeCmd() {
-// DownloadTask task = mQueue.getTask(mEntity);
-// if (task == null) {
-// task = mQueue.createTask(mTargetName, mEntity);
-// } else {
-// Log.w(TAG, "添加命令执行失败,【该任务已经存在】");
-// }
-// task.setTargetName(mTargetName);
-// mQueue.startTask(task);
-// }
-//}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/command/StopCmd.java b/Aria/src/main/java/com/arialyy/aria/core/download/command/StopCmd.java
deleted file mode 100644
index 2b342757..00000000
--- a/Aria/src/main/java/com/arialyy/aria/core/download/command/StopCmd.java
+++ /dev/null
@@ -1,55 +0,0 @@
-/*
- * 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.download.command;
-
-import android.text.TextUtils;
-import android.util.Log;
-import com.arialyy.aria.core.download.DownloadEntity;
-import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
-
-/**
- * Created by lyy on 2016/9/20.
- * 停止命令
- */
-class StopCmd extends IDownloadCmd {
-
- StopCmd(DownloadTaskEntity entity) {
- super(entity);
- }
-
- StopCmd(String targetName, DownloadTaskEntity entity) {
- super(targetName, entity);
- }
-
- @Override public void executeCmd() {
- DownloadTask task = mQueue.getTask(mEntity.downloadEntity);
- if (task == null) {
- if (mEntity.downloadEntity.getState() == DownloadEntity.STATE_DOWNLOAD_ING) {
- task = mQueue.createTask(mTargetName, mEntity);
- mQueue.stopTask(task);
- } else {
- Log.w(TAG, "停止命令执行失败,【调度器中没有该任务】");
- }
- } else {
- if (!TextUtils.isEmpty(mTargetName)) {
- task.setTargetName(mTargetName);
- }
- mQueue.stopTask(task);
- }
- }
-}
\ No newline at end of file
diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/ITask.java b/Aria/src/main/java/com/arialyy/aria/core/inf/ITask.java
new file mode 100644
index 00000000..43193d68
--- /dev/null
+++ b/Aria/src/main/java/com/arialyy/aria/core/inf/ITask.java
@@ -0,0 +1,8 @@
+package com.arialyy.aria.core.inf;
+
+/**
+ * Created by Aria.Lao on 2017/2/13.
+ */
+
+public interface ITask {
+}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/ItaskEntity.java b/Aria/src/main/java/com/arialyy/aria/core/inf/ItaskEntity.java
new file mode 100644
index 00000000..377298f3
--- /dev/null
+++ b/Aria/src/main/java/com/arialyy/aria/core/inf/ItaskEntity.java
@@ -0,0 +1,8 @@
+package com.arialyy.aria.core.inf;
+
+/**
+ * Created by Aria.Lao on 2017/2/13.
+ */
+
+public interface ITaskEntity {
+}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/queue/DownloadTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
similarity index 93%
rename from Aria/src/main/java/com/arialyy/aria/core/download/queue/DownloadTaskQueue.java
rename to Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
index 346902af..6cff034f 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/queue/DownloadTaskQueue.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
@@ -14,18 +14,18 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.queue;
+package com.arialyy.aria.core.queue;
import android.content.Context;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.queue.pool.CachePool;
-import com.arialyy.aria.core.download.queue.pool.ExecutePool;
-import com.arialyy.aria.core.download.scheduler.DownloadSchedulers;
-import com.arialyy.aria.core.download.task.DownloadTask;
-import com.arialyy.aria.core.download.task.DownloadTaskFactory;
+import com.arialyy.aria.core.queue.pool.CachePool;
+import com.arialyy.aria.core.queue.pool.ExecutePool;
+import com.arialyy.aria.core.scheduler.DownloadSchedulers;
+import com.arialyy.aria.core.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTaskFactory;
import com.arialyy.aria.util.Configuration;
/**
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/queue/IDownloader.java b/Aria/src/main/java/com/arialyy/aria/core/queue/IDownloader.java
similarity index 92%
rename from Aria/src/main/java/com/arialyy/aria/core/download/queue/IDownloader.java
rename to Aria/src/main/java/com/arialyy/aria/core/queue/IDownloader.java
index cf855db2..dde6452b 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/queue/IDownloader.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/queue/IDownloader.java
@@ -15,9 +15,9 @@
*/
-package com.arialyy.aria.core.download.queue;
+package com.arialyy.aria.core.queue;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Created by lyy on 2016/8/16.
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/queue/IPool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/IPool.java
similarity index 94%
rename from Aria/src/main/java/com/arialyy/aria/core/download/queue/IPool.java
rename to Aria/src/main/java/com/arialyy/aria/core/queue/IPool.java
index 722353fa..e112076d 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/queue/IPool.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/queue/IPool.java
@@ -15,9 +15,9 @@
*/
-package com.arialyy.aria.core.download.queue;
+package com.arialyy.aria.core.queue;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Created by lyy on 2016/8/14.
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/queue/ITaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/ITaskQueue.java
similarity index 90%
rename from Aria/src/main/java/com/arialyy/aria/core/download/queue/ITaskQueue.java
rename to Aria/src/main/java/com/arialyy/aria/core/queue/ITaskQueue.java
index 3cc29ff5..dc6205ee 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/queue/ITaskQueue.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/queue/ITaskQueue.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.queue;
+package com.arialyy.aria.core.queue;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Created by lyy on 2016/8/16.
@@ -26,11 +26,6 @@ import com.arialyy.aria.core.download.task.DownloadTask;
*/
public interface ITaskQueue extends IDownloader {
- ///**
- // * 获取调度器
- // */
- //public IDownloadSchedulers getDownloadSchedulers();
-
/**
* 任务池队列大小
*/
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/CachePool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/CachePool.java
similarity index 96%
rename from Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/CachePool.java
rename to Aria/src/main/java/com/arialyy/aria/core/queue/pool/CachePool.java
index 1d860a48..91f8518e 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/CachePool.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/CachePool.java
@@ -14,12 +14,12 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.queue.pool;
+package com.arialyy.aria.core.queue.pool;
import android.text.TextUtils;
import android.util.Log;
-import com.arialyy.aria.core.download.queue.IPool;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.queue.IPool;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import java.util.HashMap;
import java.util.Map;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/ExecutePool.java b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/ExecutePool.java
similarity index 97%
rename from Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/ExecutePool.java
rename to Aria/src/main/java/com/arialyy/aria/core/queue/pool/ExecutePool.java
index 1dc36d9a..3274e3ff 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/queue/pool/ExecutePool.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/queue/pool/ExecutePool.java
@@ -14,13 +14,13 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.queue.pool;
+package com.arialyy.aria.core.queue.pool;
import android.text.TextUtils;
import android.util.Log;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
-import com.arialyy.aria.core.download.queue.IPool;
+import com.arialyy.aria.core.queue.IPool;
import com.arialyy.aria.util.Configuration;
import java.util.HashMap;
import java.util.Map;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/scheduler/DownloadSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
similarity index 97%
rename from Aria/src/main/java/com/arialyy/aria/core/download/scheduler/DownloadSchedulers.java
rename to Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
index f9db071b..0ded01cb 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/scheduler/DownloadSchedulers.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
@@ -14,15 +14,15 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.scheduler;
+package com.arialyy.aria.core.scheduler;
import android.os.CountDownTimer;
import android.os.Message;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
-import com.arialyy.aria.core.download.queue.ITaskQueue;
+import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.download.DownloadEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.Configuration;
import java.util.Iterator;
import java.util.Map;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/scheduler/IDownloadSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/IDownloadSchedulers.java
similarity index 97%
rename from Aria/src/main/java/com/arialyy/aria/core/download/scheduler/IDownloadSchedulers.java
rename to Aria/src/main/java/com/arialyy/aria/core/scheduler/IDownloadSchedulers.java
index 98997122..6100f461 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/scheduler/IDownloadSchedulers.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/IDownloadSchedulers.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.scheduler;
+package com.arialyy.aria.core.scheduler;
import android.os.Handler;
import com.arialyy.aria.core.download.DownloadEntity;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/scheduler/OnSchedulerListener.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/OnSchedulerListener.java
similarity index 92%
rename from Aria/src/main/java/com/arialyy/aria/core/download/scheduler/OnSchedulerListener.java
rename to Aria/src/main/java/com/arialyy/aria/core/scheduler/OnSchedulerListener.java
index c83d2839..e4472565 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/scheduler/OnSchedulerListener.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/OnSchedulerListener.java
@@ -13,9 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.arialyy.aria.core.download.scheduler;
+package com.arialyy.aria.core.scheduler;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
/**
* Target处理任务监听
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/ConnectionHelp.java b/Aria/src/main/java/com/arialyy/aria/core/task/ConnectionHelp.java
similarity index 98%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/ConnectionHelp.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/ConnectionHelp.java
index 1f6bd47a..1b6fcb3f 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/ConnectionHelp.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/ConnectionHelp.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.util.CAConfiguration;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadListener.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadListener.java
similarity index 96%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadListener.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/DownloadListener.java
index e012df53..bab38eae 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadListener.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadListener.java
@@ -15,7 +15,7 @@
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
class DownloadListener implements IDownloadListener {
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadStateConstance.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadStateConstance.java
similarity index 97%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadStateConstance.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/DownloadStateConstance.java
index 785312bc..00da093b 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadStateConstance.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadStateConstance.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
/**
* Created by lyy on 2017/1/18.
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTask.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadTask.java
similarity index 98%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTask.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/DownloadTask.java
index b56defad..b88251f4 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTask.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadTask.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
import android.content.Context;
import android.content.Intent;
@@ -22,8 +22,8 @@ import android.os.Handler;
import android.util.Log;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.scheduler.DownloadSchedulers;
-import com.arialyy.aria.core.download.scheduler.IDownloadSchedulers;
+import com.arialyy.aria.core.scheduler.DownloadSchedulers;
+import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTaskFactory.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadTaskFactory.java
similarity index 94%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTaskFactory.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/DownloadTaskFactory.java
index 2ac06054..01a99865 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadTaskFactory.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadTaskFactory.java
@@ -14,11 +14,11 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
import android.content.Context;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.scheduler.IDownloadSchedulers;
+import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
/**
* Created by lyy on 2016/8/18.
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java
similarity index 99%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadUtil.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java
index cabef40a..e68f5e29 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/DownloadUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
import android.content.Context;
import android.util.Log;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadListener.java b/Aria/src/main/java/com/arialyy/aria/core/task/IDownloadListener.java
similarity index 97%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadListener.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/IDownloadListener.java
index 8d1c6271..5d28a2b8 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadListener.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/IDownloadListener.java
@@ -14,7 +14,7 @@
* limitations under the License.
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
/**
* 下载监听
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/task/IDownloadUtil.java
similarity index 96%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadUtil.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/IDownloadUtil.java
index 348d9051..171637dd 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/IDownloadUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/IDownloadUtil.java
@@ -15,7 +15,7 @@
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
/**
* Created by “AriaLyy@outlook.com” on 2016/10/31.
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/task/SingleThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/task/SingleThreadTask.java
similarity index 99%
rename from Aria/src/main/java/com/arialyy/aria/core/download/task/SingleThreadTask.java
rename to Aria/src/main/java/com/arialyy/aria/core/task/SingleThreadTask.java
index 8b954b41..2f6afc82 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/task/SingleThreadTask.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/task/SingleThreadTask.java
@@ -13,7 +13,7 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
-package com.arialyy.aria.core.download.task;
+package com.arialyy.aria.core.task;
import android.util.Log;
import com.arialyy.aria.util.CommonUtil;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java
index 848c8273..c4853d83 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java
@@ -1,6 +1,7 @@
package com.arialyy.aria.core.upload;
import com.arialyy.aria.core.RequestEnum;
+import com.arialyy.aria.core.inf.ITaskEntity;
import java.util.HashMap;
import java.util.Map;
@@ -8,21 +9,21 @@ import java.util.Map;
* Created by Aria.Lao on 2017/2/9.
*/
-public class UploadTaskEntity {
+public class UploadTaskEntity implements ITaskEntity {
public UploadEntity uploadEntity;
public RequestEnum requestEnum = RequestEnum.GET;
public String uploadUrl; //上传路径
public String attachment; //文件上传需要的key
- public String contentType = "multipart/form-data"; //上传的文件类型
- public String charset = "utf-8";
+ public String contentType = "multipart/form-data"; //上传的文件类型
+ public String charset = "utf-8";
/**
* http 请求头
*/
- public Map headers = new HashMap<>();
+ public Map headers = new HashMap<>();
/**
* 文件上传表单
*/
- public Map formFields = new HashMap<>();
+ public Map formFields = new HashMap<>();
public UploadTaskEntity(UploadEntity downloadEntity) {
this.uploadEntity = downloadEntity;
diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java
index 57ea3b35..3e1e538c 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadUtil.java
@@ -3,7 +3,6 @@ package com.arialyy.aria.core.upload;
import android.util.Log;
import com.arialyy.aria.util.CheckUtil;
import java.io.BufferedReader;
-import java.io.DataOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.IOException;
@@ -67,8 +66,8 @@ public class UploadUtil implements Runnable {
mHttpConn.setDoInput(true);
mHttpConn.setRequestProperty("Content-Type", "multipart/form-data; boundary=" + BOUNDARY);
mHttpConn.setRequestProperty("User-Agent", "CodeJava Agent");
+ mHttpConn.setRequestProperty("Range", "bytes=" + 0 + "-" + "100");
//内部缓冲区---分段上传防止oom
- //System.setProperty("http.keepAlive", "false");
mHttpConn.setChunkedStreamingMode(1024);
//添加Http请求头部
diff --git a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
index 08d56d48..3f9a6745 100644
--- a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
@@ -19,7 +19,10 @@ package com.arialyy.aria.util;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.download.DownloadEntity;
+import com.arialyy.aria.core.download.DownloadTaskEntity;
+import com.arialyy.aria.core.inf.ITaskEntity;
import com.arialyy.aria.core.upload.UploadEntity;
+import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.exception.FileException;
import java.io.File;
import java.util.regex.Matcher;
@@ -74,6 +77,17 @@ public class CheckUtil {
if (TextUtils.isEmpty(downloadUrl)) throw new IllegalArgumentException("下载链接不能为null");
}
+ /**
+ * 检查任务实体
+ */
+ public static void checkTaskEntity(ITaskEntity entity) {
+ if (entity instanceof DownloadTaskEntity) {
+ checkDownloadEntity(((DownloadTaskEntity) entity).downloadEntity);
+ } else if (entity instanceof UploadTaskEntity) {
+ checkUploadEntity(((UploadTaskEntity) entity).uploadEntity);
+ }
+ }
+
/**
* 检查上传实体是否合法
*/
diff --git a/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java b/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
index 43ece013..2da387e1 100644
--- a/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
@@ -22,8 +22,9 @@ import android.content.SharedPreferences;
import android.net.Uri;
import android.util.Log;
import com.arialyy.aria.core.download.DownloadTaskEntity;
-import com.arialyy.aria.core.download.command.CmdFactory;
-import com.arialyy.aria.core.download.command.IDownloadCmd;
+import com.arialyy.aria.core.command.CmdFactory;
+import com.arialyy.aria.core.command.IDownloadCmd;
+import com.arialyy.aria.core.inf.ITaskEntity;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
@@ -40,14 +41,10 @@ import java.util.Properties;
public class CommonUtil {
private static final String TAG = "util";
- public static IDownloadCmd createDownloadCmd(String target, DownloadTaskEntity entity, int cmd) {
+ public static IDownloadCmd createDownloadCmd(String target, T entity, int cmd) {
return CmdFactory.getInstance().createCmd(target, entity, cmd);
}
- public static IDownloadCmd createDownloadCmd(DownloadTaskEntity entity, int cmd) {
- return CmdFactory.getInstance().createCmd(entity, cmd);
- }
-
/**
* 创建隐性的Intent
*/
diff --git a/app/src/main/java/com/arialyy/simple/dialog_task/DownloadDialog.java b/app/src/main/java/com/arialyy/simple/dialog_task/DownloadDialog.java
index 76788d97..89fcea19 100644
--- a/app/src/main/java/com/arialyy/simple/dialog_task/DownloadDialog.java
+++ b/app/src/main/java/com/arialyy/simple/dialog_task/DownloadDialog.java
@@ -10,7 +10,7 @@ import butterknife.OnClick;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.core.AbsDialog;
import com.arialyy.simple.R;
diff --git a/app/src/main/java/com/arialyy/simple/fragment_task/DownloadFragment.java b/app/src/main/java/com/arialyy/simple/fragment_task/DownloadFragment.java
index 7f2ac88f..d0d2e7b6 100644
--- a/app/src/main/java/com/arialyy/simple/fragment_task/DownloadFragment.java
+++ b/app/src/main/java/com/arialyy/simple/fragment_task/DownloadFragment.java
@@ -10,7 +10,7 @@ import butterknife.OnClick;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.core.AbsFragment;
import com.arialyy.simple.R;
diff --git a/app/src/main/java/com/arialyy/simple/multi_task/DownloadActivity.java b/app/src/main/java/com/arialyy/simple/multi_task/DownloadActivity.java
index 69fb7ba9..cc10b7bf 100644
--- a/app/src/main/java/com/arialyy/simple/multi_task/DownloadActivity.java
+++ b/app/src/main/java/com/arialyy/simple/multi_task/DownloadActivity.java
@@ -5,7 +5,7 @@ import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView;
import butterknife.Bind;
import com.arialyy.aria.core.Aria;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
diff --git a/app/src/main/java/com/arialyy/simple/multi_task/MultiTaskActivity.java b/app/src/main/java/com/arialyy/simple/multi_task/MultiTaskActivity.java
index fcad3a1b..b6fb7e58 100644
--- a/app/src/main/java/com/arialyy/simple/multi_task/MultiTaskActivity.java
+++ b/app/src/main/java/com/arialyy/simple/multi_task/MultiTaskActivity.java
@@ -24,7 +24,7 @@ import android.support.v7.widget.Toolbar;
import android.view.View;
import butterknife.Bind;
import com.arialyy.aria.core.Aria;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityMultiBinding;
diff --git a/app/src/main/java/com/arialyy/simple/notification/SimpleNotification.java b/app/src/main/java/com/arialyy/simple/notification/SimpleNotification.java
index 248fcfca..75715f57 100644
--- a/app/src/main/java/com/arialyy/simple/notification/SimpleNotification.java
+++ b/app/src/main/java/com/arialyy/simple/notification/SimpleNotification.java
@@ -5,7 +5,7 @@ import android.content.Context;
import android.os.Environment;
import android.support.v4.app.NotificationCompat;
import com.arialyy.aria.core.Aria;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.simple.R;
/**
diff --git a/app/src/main/java/com/arialyy/simple/pop_task/DownloadPopupWindow.java b/app/src/main/java/com/arialyy/simple/pop_task/DownloadPopupWindow.java
index 744a7748..42bed733 100644
--- a/app/src/main/java/com/arialyy/simple/pop_task/DownloadPopupWindow.java
+++ b/app/src/main/java/com/arialyy/simple/pop_task/DownloadPopupWindow.java
@@ -12,7 +12,7 @@ import butterknife.OnClick;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.core.AbsPopupWindow;
import com.arialyy.simple.R;
diff --git a/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java
index db9cb4bc..be7e4aff 100644
--- a/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java
+++ b/app/src/main/java/com/arialyy/simple/single_task/SingleTaskActivity.java
@@ -33,7 +33,7 @@ import butterknife.Bind;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
-import com.arialyy.aria.core.download.task.DownloadTask;
+import com.arialyy.aria.core.task.DownloadTask;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R;