增加非静态的成员类警告提示
This commit is contained in:
@@ -19,11 +19,11 @@ package com.arialyy.aria.util;
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.exception.ParamException;
|
||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Modifier;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@@ -34,26 +34,15 @@ public class CheckUtil {
|
||||
private static final String TAG = "CheckUtil";
|
||||
|
||||
/**
|
||||
* 检查ftp上传路径,如果ftp上传路径为空,抛出空指针异常
|
||||
* 如果ftp上传路径不是以"ftp"或"sftp",抛出参数异常
|
||||
*
|
||||
* @param ftpUrl ftp上传路径
|
||||
* 检查成员类是否是静态和public
|
||||
*/
|
||||
public static void checkFtpUploadUrl(String ftpUrl) {
|
||||
if (TextUtils.isEmpty(ftpUrl)) {
|
||||
throw new ParamException("ftp上传路径为空");
|
||||
} else if (!ftpUrl.startsWith("ftp") || !ftpUrl.startsWith("sftp")) {
|
||||
throw new ParamException("ftp上传路径无效");
|
||||
public static void checkMemberClass(Class clazz) {
|
||||
int modifiers = clazz.getModifiers();
|
||||
if (!clazz.isMemberClass() || !Modifier.isStatic(modifiers) || Modifier.isPrivate(modifiers)) {
|
||||
ALog.e(TAG, "为了放置内存泄漏,请使用静态的成员类(public static class xxx)或文件类(A.java)");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 判空
|
||||
*/
|
||||
public static void checkNull(Object obj) {
|
||||
if (obj == null) throw new IllegalArgumentException("不能传入空对象");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查分页数据,需要查询的页数,从1开始,如果page小于1 或 num 小于1,则抛出{@link NullPointerException}
|
||||
*
|
||||
@@ -64,15 +53,6 @@ public class CheckUtil {
|
||||
if (page < 1 || num < 1) throw new NullPointerException("page和num不能小于1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查下载实体
|
||||
*/
|
||||
public static void checkDownloadEntity(DownloadEntity entity) {
|
||||
checkUrlInvalidThrow(entity.getUrl());
|
||||
entity.setUrl(entity.getUrl());
|
||||
checkPath(entity.getDownloadPath());
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测下载链接是否为null
|
||||
*/
|
||||
@@ -150,15 +130,6 @@ public class CheckUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查下载任务组保存路径
|
||||
*/
|
||||
public static void checkDownloadPaths(List<String> paths) {
|
||||
if (paths == null || paths.isEmpty()) {
|
||||
throw new IllegalArgumentException("链接保存路径不能为null");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测上传地址是否为null
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user