修复gradle 5.0 apt 失效的问题
This commit is contained in:
@@ -124,21 +124,23 @@ public class AriaConfig {
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_WIFI)
|
||||
.addTransportType(NetworkCapabilities.TRANSPORT_CELLULAR)
|
||||
.build();
|
||||
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP){
|
||||
cm.registerNetworkCallback(request, new ConnectivityManager.NetworkCallback() {
|
||||
|
||||
cm.registerNetworkCallback(request, new ConnectivityManager.NetworkCallback() {
|
||||
@Override public void onLost(Network network) {
|
||||
super.onLost(network);
|
||||
isConnectedNet = false;
|
||||
ALog.d(TAG, "onLost");
|
||||
}
|
||||
|
||||
@Override public void onLost(Network network) {
|
||||
super.onLost(network);
|
||||
isConnectedNet = false;
|
||||
ALog.d(TAG, "onLost");
|
||||
}
|
||||
@Override public void onAvailable(Network network) {
|
||||
super.onAvailable(network);
|
||||
ALog.d(TAG, "onAvailable");
|
||||
isConnectedNet = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@Override public void onAvailable(Network network) {
|
||||
super.onAvailable(network);
|
||||
ALog.d(TAG, "onAvailable");
|
||||
isConnectedNet = true;
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public boolean isConnectedNet() {
|
||||
|
||||
@@ -18,6 +18,7 @@ package com.arialyy.aria.core;
|
||||
import com.arialyy.aria.core.common.BaseOption;
|
||||
import com.arialyy.aria.core.inf.IEventHandler;
|
||||
import com.arialyy.aria.core.inf.IOptionConstant;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import java.lang.reflect.Field;
|
||||
import java.util.HashMap;
|
||||
|
||||
@@ -0,0 +1,34 @@
|
||||
/*
|
||||
* Licensed to the Apache Software Foundation (ASF) under one
|
||||
* or more contributor license agreements. See the NOTICE file
|
||||
* distributed with this work for additional information
|
||||
* regarding copyright ownership. The ASF licenses this file
|
||||
* to you 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.common;
|
||||
|
||||
public enum ErrorCode {
|
||||
ERROR_CODE_NORMAL(0, "正常"), ERROR_CODE_TASK_ID_NULL(1, "任务id为空的错误码"),
|
||||
ERROR_CODE_URL_NULL(2, "url 为空"), ERROR_CODE_URL_INVALID(3, "url 无效"),
|
||||
ERROR_CODE_PAGE_NUM(4, "page和num不能小于1"), ERROR_CODE_GROUP_URL_NULL(5, "组合任务url列表为空"),
|
||||
ERROR_CODE_UPLOAD_FILE_NULL(7, "上传文件不存在"),
|
||||
ERROR_CODE_MEMBER_WARNING(8, "为了防止内存泄漏,请使用静态的成员类(public static class xxx)或文件类(A.java)");
|
||||
|
||||
int code;
|
||||
String msg;
|
||||
|
||||
ErrorCode(int code, String msg) {
|
||||
this.code = code;
|
||||
this.msg = msg;
|
||||
}
|
||||
}
|
||||
@@ -184,19 +184,6 @@ public class RecordHandler implements IRecordHandler {
|
||||
ALog.d(TAG, String.format("保存记录,线程记录数:%s", mTaskRecord.threadRecords.size()));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取记录类型
|
||||
*
|
||||
* @return {@link #TYPE_DOWNLOAD}、{@link #TYPE_UPLOAD}
|
||||
*/
|
||||
private int getRecordType() {
|
||||
if (mEntity instanceof DownloadEntity) {
|
||||
return TYPE_DOWNLOAD;
|
||||
} else {
|
||||
return TYPE_UPLOAD;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取任务路径
|
||||
*
|
||||
|
||||
@@ -21,26 +21,6 @@ import java.util.List;
|
||||
|
||||
/**
|
||||
* FTP文件上传拦截器,如果远端已有同名文件,可使用该拦截器控制覆盖文件或修改该文件上传到服务器端端文件名
|
||||
* <pre>
|
||||
* <code>
|
||||
* Aria.upload(this)
|
||||
* .loadFtp(FILE_PATH)
|
||||
* .setUploadUrl(URL)
|
||||
* .setUploadInterceptor(
|
||||
* new IFtpUploadInterceptor() {
|
||||
*
|
||||
* @Override
|
||||
* public FtpInterceptHandler onIntercept(UploadEntity entity, List<String> fileList) {
|
||||
* FtpInterceptHandler.Builder builder = new FtpInterceptHandler.Builder();
|
||||
* builder.coverServerFile();
|
||||
* //builder.resetFileName("test");
|
||||
* return builder.build();
|
||||
* }
|
||||
* })
|
||||
* .create();
|
||||
* </code>
|
||||
*
|
||||
* </pre>
|
||||
*/
|
||||
public interface IFtpUploadInterceptor extends IEventHandler {
|
||||
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.arialyy.aria.core.wrapper;
|
||||
|
||||
import com.arialyy.aria.core.TaskOptionParams;
|
||||
import com.arialyy.aria.core.common.AbsEntity;
|
||||
import com.arialyy.aria.core.common.ErrorCode;
|
||||
import com.arialyy.aria.core.config.BaseTaskConfig;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
||||
@@ -25,6 +26,8 @@ import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.inf.ITaskOption;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.util.ComponentUtil;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/2/23. 所有任务实体的父类
|
||||
@@ -84,6 +87,15 @@ public abstract class AbsTaskWrapper<ENTITY extends AbsEntity>
|
||||
*/
|
||||
private TaskOptionParams optionParams = new TaskOptionParams();
|
||||
|
||||
/**
|
||||
* 初始状态列表
|
||||
*/
|
||||
private List<ErrorCode> errorCode = new ArrayList<>();
|
||||
|
||||
public List<ErrorCode> getErrorCode() {
|
||||
return errorCode;
|
||||
}
|
||||
|
||||
public void setTaskOption(ITaskOption option) {
|
||||
this.taskOption = option;
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@
|
||||
package com.arialyy.aria.util;
|
||||
|
||||
import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.ErrorCode;
|
||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||
@@ -39,7 +40,7 @@ public class CheckUtil {
|
||||
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)");
|
||||
ALog.e(TAG, "为了防止内存泄漏,请使用静态的成员类(public static class xxx)或文件类(A.java)");
|
||||
}
|
||||
}
|
||||
|
||||
@@ -53,22 +54,14 @@ public class CheckUtil {
|
||||
if (page < 1 || num < 1) throw new NullPointerException("page和num不能小于1");
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测下载链接是否为null
|
||||
*/
|
||||
public static void checkPath(String path) {
|
||||
if (TextUtils.isEmpty(path)) {
|
||||
throw new IllegalArgumentException("保存路径不能为null");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检测url是否合法,如果url不合法,将抛异常
|
||||
*/
|
||||
public static void checkTaskId(long taskId) {
|
||||
public static ErrorCode checkTaskId(long taskId) {
|
||||
if (taskId < 0) {
|
||||
throw new IllegalArgumentException("任务id不能小于0");
|
||||
return ErrorCode.ERROR_CODE_TASK_ID_NULL;
|
||||
}
|
||||
return ErrorCode.ERROR_CODE_NORMAL;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -154,38 +147,6 @@ public class CheckUtil {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查命令实体
|
||||
*
|
||||
* @param checkType 删除命令和停止命令不需要检查下载链接和保存路径
|
||||
* @return {@code false}实体无效
|
||||
*/
|
||||
public static boolean checkCmdEntity(AbsTaskWrapper entity, boolean checkType) {
|
||||
boolean b = false;
|
||||
if (entity instanceof DTaskWrapper) {
|
||||
DownloadEntity entity1 = ((DTaskWrapper) entity).getEntity();
|
||||
if (entity1 == null) {
|
||||
ALog.e(TAG, "下载实体不能为空");
|
||||
} else if (checkType && TextUtils.isEmpty(entity1.getUrl())) {
|
||||
ALog.e(TAG, "下载链接不能为空");
|
||||
} else if (checkType && TextUtils.isEmpty(entity1.getDownloadPath())) {
|
||||
ALog.e(TAG, "保存路径不能为空");
|
||||
} else {
|
||||
b = true;
|
||||
}
|
||||
} else if (entity instanceof UTaskWrapper) {
|
||||
UploadEntity entity1 = ((UTaskWrapper) entity).getEntity();
|
||||
if (entity1 == null) {
|
||||
ALog.e(TAG, "上传实体不能为空");
|
||||
} else if (TextUtils.isEmpty(entity1.getFilePath())) {
|
||||
ALog.e(TAG, "上传文件路径不能为空");
|
||||
} else {
|
||||
b = true;
|
||||
}
|
||||
}
|
||||
return b;
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查上传实体是否合法
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user