diff --git a/.gitignore b/.gitignore
index cda18dcf..0a7d0a5d 100644
--- a/.gitignore
+++ b/.gitignore
@@ -10,4 +10,5 @@
.externalNativeBuild
.idea/misc.xml
.gradle
-/.idea
\ No newline at end of file
+/.idea
+.idea
\ No newline at end of file
diff --git a/.idea/modules.xml b/.idea/modules.xml
index 5f6de159..b0a774eb 100644
--- a/.idea/modules.xml
+++ b/.idea/modules.xml
@@ -3,9 +3,7 @@
-
-
diff --git a/Aria/src/main/java/com/arialyy/aria/core/command/AbsCmd.java b/Aria/src/main/java/com/arialyy/aria/core/command/AbsCmd.java
index 72a86147..452b0a34 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/command/AbsCmd.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/command/AbsCmd.java
@@ -40,7 +40,7 @@ public abstract class AbsCmd implements ICmd {
* @param targetName 产生任务的对象名
*/
AbsCmd(String targetName, T entity) {
- CheckUtil.checkTaskEntity(entity);
+ CheckUtil.checkCmdEntity(entity);
mTargetName = targetName;
mEntity = entity;
TAG = CommonUtil.getClassName(this);
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
index 83fc3d46..54e94324 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
@@ -188,7 +188,7 @@ public class DownloadTask implements ITask {
public Builder(String targetName, DownloadTaskEntity taskEntity) {
- CheckUtil.checkDownloadEntity(taskEntity.downloadEntity);
+ CheckUtil.checkDownloadTaskEntity(taskEntity.downloadEntity);
this.targetName = targetName;
this.taskEntity = taskEntity;
}
diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java
index 81ae37df..38d76f38 100644
--- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadUtil.java
@@ -62,7 +62,7 @@ final class DownloadUtil implements IDownloadUtil, Runnable {
DownloadUtil(Context context, DownloadTaskEntity entity, IDownloadListener downloadListener,
int threadNum) {
- CheckUtil.checkDownloadEntity(entity.downloadEntity);
+ CheckUtil.checkDownloadTaskEntity(entity.downloadEntity);
mDownloadEntity = entity.downloadEntity;
mContext = context.getApplicationContext();
mDownloadTaskEntity = entity;
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 39fa7591..be264f97 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
@@ -50,7 +50,7 @@ final class UploadUtil implements Runnable {
UploadUtil(UploadTaskEntity taskEntity, IUploadListener listener) {
mTaskEntity = taskEntity;
- CheckUtil.checkUploadEntity(taskEntity.uploadEntity);
+ CheckUtil.checkUploadTaskEntity(taskEntity.uploadEntity);
mUploadEntity = taskEntity.uploadEntity;
if (listener == null) {
throw new IllegalArgumentException("上传监听不能为空");
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 901282fc..25608e5e 100644
--- a/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
+++ b/Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
@@ -17,14 +17,12 @@
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;
import java.util.regex.Pattern;
@@ -89,20 +87,40 @@ public class CheckUtil {
*/
public static void checkTaskEntity(ITaskEntity entity) {
if (entity instanceof DownloadTaskEntity) {
- checkDownloadEntity(((DownloadTaskEntity) entity).downloadEntity);
+ checkDownloadTaskEntity(((DownloadTaskEntity) entity).downloadEntity);
} else if (entity instanceof UploadTaskEntity) {
- checkUploadEntity(((UploadTaskEntity) entity).uploadEntity);
+ checkUploadTaskEntity(((UploadTaskEntity) entity).uploadEntity);
+ }
+ }
+
+ /**
+ * 检查命令实体
+ */
+ public static void checkCmdEntity(ITaskEntity entity) {
+ if (entity instanceof DownloadTaskEntity) {
+ DownloadEntity entity1 = ((DownloadTaskEntity) entity).downloadEntity;
+ if (entity1 == null) {
+ throw new NullPointerException("下载实体不能为空");
+ } else if (TextUtils.isEmpty(entity1.getDownloadUrl())) {
+ throw new IllegalArgumentException("下载链接不能为空");
+ }
+ } else if (entity instanceof UploadTaskEntity) {
+ UploadEntity entity1 = ((UploadTaskEntity) entity).uploadEntity;
+ if (entity1 == null) {
+ throw new NullPointerException("上传实体不能为空");
+ } else if (TextUtils.isEmpty(entity1.getFilePath())) {
+ throw new IllegalArgumentException("上传文件路径不能为空");
+ }
}
}
/**
* 检查上传实体是否合法
*/
- public static void checkUploadEntity(UploadEntity entity) {
+ public static void checkUploadTaskEntity(UploadEntity entity) {
if (entity == null) {
throw new NullPointerException("上传实体不能为空");
- }
- if (TextUtils.isEmpty(entity.getFilePath())) {
+ } else if (TextUtils.isEmpty(entity.getFilePath())) {
throw new IllegalArgumentException("上传文件路径不能为空");
} else if (TextUtils.isEmpty(entity.getFileName())) {
throw new IllegalArgumentException("上传文件名不能为空");
@@ -115,7 +133,7 @@ public class CheckUtil {
* @param entity 下载实体
* @return 合法(true)
*/
- public static void checkDownloadEntity(DownloadEntity entity) {
+ public static void checkDownloadTaskEntity(DownloadEntity entity) {
if (entity == null) {
throw new NullPointerException("下载实体不能为空");
} else if (TextUtils.isEmpty(entity.getDownloadUrl())) {
@@ -125,15 +143,5 @@ public class CheckUtil {
} else if (TextUtils.isEmpty(entity.getDownloadPath())) {
throw new FileException("文件保存路径不能为null");
}
- String fileName = entity.getFileName();
- if (fileName.contains(" ")) {
- fileName = fileName.replace(" ", "_");
- }
- String dPath = entity.getDownloadPath();
- File file = new File(dPath);
- if (file.isDirectory()) {
- dPath += fileName;
- entity.setDownloadPath(dPath);
- }
}
}
\ No newline at end of file