新增taskEntityManager

pull/330/head
AriaLyy 7 years ago
parent 70539c6539
commit fb76b012a0
  1. 11
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/command/normal/AbsNormalCmd.java
  3. 1
      Aria/src/main/java/com/arialyy/aria/core/command/normal/ResumeAllCmd.java
  4. 1
      Aria/src/main/java/com/arialyy/aria/core/command/normal/StartCmd.java
  5. 1
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  6. 7
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpInfoThread.java
  7. 4
      Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  8. 18
      Aria/src/main/java/com/arialyy/aria/core/download/BaseGroupTarget.java
  9. 2
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupEntity.java
  10. 26
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java
  11. 52
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
  12. 1
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
  13. 16
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java
  14. 31
      Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java
  15. 21
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsUploadTarget.java
  16. 58
      Aria/src/main/java/com/arialyy/aria/core/manager/DGTEntityFactory.java
  17. 47
      Aria/src/main/java/com/arialyy/aria/core/manager/DTEntityFactory.java
  18. 12
      Aria/src/main/java/com/arialyy/aria/core/manager/IGTEntityFactory.java
  19. 2
      Aria/src/main/java/com/arialyy/aria/core/manager/ITEntityFactory.java
  20. 3
      Aria/src/main/java/com/arialyy/aria/core/manager/SubTaskManager.java
  21. 177
      Aria/src/main/java/com/arialyy/aria/core/manager/TEManager.java
  22. 7
      Aria/src/main/java/com/arialyy/aria/core/manager/TaskManager.java
  23. 68
      Aria/src/main/java/com/arialyy/aria/core/manager/UTEntityFactory.java
  24. 3
      Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java
  25. 8
      Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java
  26. 18
      Aria/src/main/java/com/arialyy/aria/core/upload/FtpUploadTarget.java
  27. 19
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java
  28. 12
      Aria/src/main/java/com/arialyy/aria/util/ALog.java
  29. 6
      DEV_LOG.md
  30. 2
      README.md
  31. 4
      app/src/main/assets/aria_config.xml
  32. 2
      app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java
  33. 13
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  34. 2
      build.gradle

@ -69,14 +69,7 @@ import org.xml.sax.SAXException;
public static final String DOWNLOAD_TEMP_DIR = "/Aria/temp/download/";
public static final String UPLOAD_TEMP_DIR = "/Aria/temp/upload/";
public static final int LOG_LEVEL_VERBOSE = 2;
public static final int LOG_LEVEL_DEBUG = 3;
public static final int LOG_LEVEL_INFO = 4;
public static final int LOG_LEVEL_WARN = 5;
public static final int LOG_LEVEL_ERROR = 6;
public static final int LOG_LEVEL_ASSERT = 7;
public static final int LOG_CLOSE = 8;
public static final int LOG_DEFAULT = LOG_LEVEL_DEBUG;
@SuppressLint("StaticFieldLeak") private static volatile AriaManager INSTANCE = null;
private Map<String, AbsReceiver> mReceivers = new ConcurrentHashMap<>();
@ -108,7 +101,7 @@ import org.xml.sax.SAXException;
/**
* 设置Aria 日志级别
*
* @param level {@link #LOG_LEVEL_VERBOSE}
* @param level {@link ALog#LOG_LEVEL_VERBOSE}
*/
public void setLogLevel(int level) {
ALog.LOG_LEVEL = level;

@ -23,6 +23,7 @@ import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue;
@ -161,6 +162,7 @@ public abstract class AbsNormalCmd<T extends AbsTaskEntity> extends AbsCmd<T> {
* @return 创建的任务
*/
AbsTask createTask(AbsTaskEntity taskEntity) {
TEManager.getInstance().addTEntity(taskEntity);
return mQueue.createTask(mTargetName, taskEntity);
}
}

@ -1,5 +1,6 @@
package com.arialyy.aria.core.command.normal;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;

@ -24,6 +24,7 @@ import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue;

@ -367,6 +367,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
mFixedThreadPool.execute(task);
}
}
mTaskEntity.isNewTask = false;
}
/**

@ -83,11 +83,12 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
failDownload("文件不存在,任务链接【" + mTaskEntity.urlEntity.url + "】", false);
FTPFile[] files1 = client.listFiles();
if (files1.length > 0) {
ALog.i(TAG, "路径【" + setRemotePath() + "】下文件列表 ===================================");
ALog.i(TAG, "路径【" + setRemotePath() + "】下文件列表 ===================================");
for (FTPFile file : files1) {
ALog.d(TAG, file.toString());
}
ALog.i(TAG, "================================= --end-- ===================================");
ALog.i(TAG,
"================================= --end-- ===================================");
}
client.disconnect();
return;
@ -206,7 +207,7 @@ public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_ENTITY ext
client.setDataTimeout(10 * 1000);
client.enterLocalPassiveMode();
client.setFileType(FTP.BINARY_FILE_TYPE);
client.setControlKeepAliveTimeout(5);
client.setConnectTimeout(mConnectTimeOut);
} catch (IOException e) {
e.printStackTrace();
}

@ -107,8 +107,8 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
+ mConfig.TEMP_FILE.getName()
+ "】thread__"
+ mConfig.THREAD_ID
+ "__停止, stop location ==> "
+ currentTemp);
+ "__停止【停止位置: "
+ currentTemp + "】");
writeConfig(false, currentTemp);
if (STATE.isStop()) {
ALog.i(TAG, "任务【" + mConfig.TEMP_FILE.getName() + "】已停止");

@ -16,10 +16,10 @@
package com.arialyy.aria.core.download;
import android.text.TextUtils;
import com.arialyy.aria.core.SubTaskManager;
import com.arialyy.aria.core.inf.AbsDownloadTarget;
import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.inf.AbsGroupTaskEntity;
import com.arialyy.aria.core.inf.AbsTarget;
import com.arialyy.aria.core.manager.SubTaskManager;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CommonUtil;
import java.io.File;
@ -45,20 +45,6 @@ abstract class BaseGroupTarget<TARGET extends AbsTarget, TASK_ENTITY extends Abs
private SubTaskManager mSubTaskManager;
/**
* 查询任务组实体如果数据库不存在该实体则新创建一个新的任务组实体
*/
DownloadGroupEntity getDownloadGroupEntity() {
DownloadGroupEntity entity =
DbEntity.findFirst(DownloadGroupEntity.class, "groupName=?", mGroupName);
if (entity == null) {
entity = new DownloadGroupEntity();
entity.setGroupName(mGroupName);
entity.setUrls(mUrls);
}
return entity;
}
/**
* 获取子任务管理器
*

@ -54,7 +54,7 @@ public class DownloadGroupEntity extends AbsGroupEntity {
this.dirPath = dirPath;
}
void setGroupName(String key) {
public void setGroupName(String key) {
this.groupName = key;
}

@ -15,8 +15,7 @@
*/
package com.arialyy.aria.core.download;
import android.text.TextUtils;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
@ -35,24 +34,23 @@ public class DownloadGroupTarget
if (groupEntity.getUrls() != null && !groupEntity.getUrls().isEmpty()) {
this.mUrls.addAll(groupEntity.getUrls());
}
init(groupEntity.getGroupName());
mGroupName = CommonUtil.getMd5Code(groupEntity.getUrls());
mTaskEntity = TEManager.getInstance()
.getTEntity(DownloadGroupTaskEntity.class, mGroupName);
if (mTaskEntity == null) {
mTaskEntity =
TEManager.getInstance().createTEntity(DownloadGroupTaskEntity.class, groupEntity);
}
mEntity = mTaskEntity.entity;
}
DownloadGroupTarget(List<String> urls, String targetName) {
this.mTargetName = targetName;
this.mUrls = urls;
init(CommonUtil.getMd5Code(urls));
}
private void init(String key) {
mGroupName = key;
mTaskEntity = DbEntity.findFirst(DownloadGroupTaskEntity.class, "key=?", key);
mGroupName = CommonUtil.getMd5Code(urls);
mTaskEntity = TEManager.getInstance().getTEntity(DownloadGroupTaskEntity.class, mGroupName);
if (mTaskEntity == null) {
mTaskEntity = new DownloadGroupTaskEntity();
mTaskEntity.save(getDownloadGroupEntity());
}
if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getKey())) {
mTaskEntity.save(getDownloadGroupEntity());
mTaskEntity = TEManager.getInstance().createGTEntity(DownloadGroupTaskEntity.class, mUrls);
}
mEntity = mTaskEntity.entity;
}

@ -17,8 +17,9 @@ package com.arialyy.aria.core.download;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.inf.AbsDownloadTarget;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CommonUtil;
@ -39,7 +40,11 @@ public class DownloadTarget
DownloadTarget(DownloadEntity entity, String targetName, boolean refreshInfo) {
this.url = entity.getUrl();
mTargetName = targetName;
initTask(entity);
mTaskEntity = TEManager.getInstance().getTEntity(DownloadTaskEntity.class, url);
if (mTaskEntity == null) {
mTaskEntity = TEManager.getInstance().createTEntity(DownloadTaskEntity.class, entity);
}
mEntity = mTaskEntity.entity;
mTaskEntity.refreshInfo = refreshInfo;
}
@ -50,44 +55,12 @@ public class DownloadTarget
DownloadTarget(String url, String targetName, boolean refreshInfo) {
this.url = url;
mTargetName = targetName;
initTask(getEntity(url));
mTaskEntity.refreshInfo = refreshInfo;
}
private void initTask(DownloadEntity entity) {
mTaskEntity =
DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false' and url=?",
entity.getDownloadPath(), entity.getUrl());
mTaskEntity = TEManager.getInstance().getTEntity(DownloadTaskEntity.class, url);
if (mTaskEntity == null) {
mTaskEntity = new DownloadTaskEntity();
mTaskEntity.save(entity);
} else if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getUrl())) {
mTaskEntity.save(entity);
} else if (!mTaskEntity.entity.getUrl().equals(entity.getUrl())) { //处理地址切换而保存路径不变
mTaskEntity.save(entity);
mTaskEntity = TEManager.getInstance().createTEntity(DownloadTaskEntity.class, url);
}
mEntity = entity;
}
/**
* 如果任务存在但是下载实体不存在则通过下载地址获取下载实体
*
* @param downloadUrl 下载地址
*/
private DownloadEntity getEntity(String downloadUrl) {
DownloadEntity entity =
DownloadEntity.findFirst(DownloadEntity.class, "url=? and isGroupChild='false'",
downloadUrl);
if (entity == null) {
entity = new DownloadEntity();
entity.setUrl(downloadUrl);
entity.setGroupChild(false);
}
File file = new File(entity.getDownloadPath());
if (!file.exists()) {
entity.setState(IEntity.STATE_WAIT);
}
return entity;
mEntity = mTaskEntity.entity;
mTaskEntity.refreshInfo = refreshInfo;
}
/**
@ -128,7 +101,8 @@ public class DownloadTarget
throw new IllegalArgumentException("保存路径不能为文件夹,路径需要是完整的文件路径,如:/mnt/sdcard/game.zip");
}
if (!downloadPath.equals(mEntity.getDownloadPath())) {
if (!mTaskEntity.refreshInfo && DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", downloadPath)) {
if (!mTaskEntity.refreshInfo && DbEntity.checkDataExist(DownloadEntity.class,
"downloadPath=?", downloadPath)) {
throw new IllegalArgumentException("保存路径【" + downloadPath + "】已经被其它任务占用,请设置其它保存路径");
}
File oldFile = new File(mEntity.getDownloadPath());

@ -18,6 +18,7 @@ package com.arialyy.aria.core.download;
import android.os.Handler;
import android.os.Looper;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.IUtil;
import com.arialyy.aria.core.download.downloader.SimpleDownloadUtil;

@ -17,9 +17,8 @@ package com.arialyy.aria.core.download;
import android.text.TextUtils;
import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
/**
* Created by Aria.Lao on 2017/7/26.
@ -30,22 +29,17 @@ public class FtpDirDownloadTarget
private final String TAG = "FtpDirDownloadTarget";
FtpDirDownloadTarget(String url, String targetName) {
init(url);
mTargetName = targetName;
mTaskEntity.urlEntity = CommonUtil.getFtpUrlInfo(url);
mTaskEntity.requestType = AbsTaskEntity.FTP_DIR;
init(url);
}
private void init(String key) {
mGroupName = key;
mTaskEntity = DbEntity.findFirst(DownloadGroupTaskEntity.class, "key=?", key);
mTaskEntity = TEManager.getInstance().getTEntity(DownloadGroupTaskEntity.class, key);
if (mTaskEntity == null) {
mTaskEntity = new DownloadGroupTaskEntity();
mTaskEntity.save(getDownloadGroupEntity());
}
if (mTaskEntity.entity == null) {
mTaskEntity.save(getDownloadGroupEntity());
mTaskEntity = TEManager.getInstance().createTEntity(DownloadGroupTaskEntity.class, key);
}
mTaskEntity.requestType = AbsTaskEntity.FTP_DIR;
mEntity = mTaskEntity.entity;
}

@ -42,6 +42,37 @@ public class FtpDownloadTarget extends DownloadTarget {
mTaskEntity.requestType = AbsTaskEntity.FTP;
}
/**
* 设置文件保存文件夹路径
* 关于文件名
* 1如果保存路径是该文件的保存路径/mnt/sdcard/file.zip则使用路径中的文件名file.zip
* 2如果保存路径是文件夹路径/mnt/sdcard/则使用FTP服务器该文件的文件名
*
* @param downloadPath 路径必须为文件路径不能为文件夹路径
*/
@Override public FtpDownloadTarget setDownloadPath(@NonNull String downloadPath) {
if (TextUtils.isEmpty(downloadPath)) {
throw new IllegalArgumentException("文件保持路径不能为null");
}
File file = new File(downloadPath);
if (file.isDirectory()) {
downloadPath += mEntity.getFileName();
}
if (!downloadPath.equals(mEntity.getDownloadPath())) {
File oldFile = new File(mEntity.getDownloadPath());
File newFile = new File(downloadPath);
if (TextUtils.isEmpty(mEntity.getDownloadPath()) || oldFile.renameTo(newFile)) {
mEntity.setDownloadPath(downloadPath);
mEntity.setFileName(newFile.getName());
mTaskEntity.key = downloadPath;
mEntity.update();
mTaskEntity.update();
CommonUtil.renameDownloadConfig(oldFile.getName(), newFile.getName());
}
}
return this;
}
/**
* 设置字符编码
*/

@ -45,27 +45,6 @@ public abstract class AbsUploadTarget<TARGET extends AbsUploadTarget, ENTITY ext
return (TARGET) this;
}
/**
* 从数据中读取上传实体如果数据库查不到则新创建一个上传实体
*
* @param filePath 上传文件的文件路径
*/
protected UploadEntity getUploadEntity(String filePath) {
UploadEntity entity = UploadEntity.findFirst(UploadEntity.class, "filePath=?", filePath);
if (entity == null) {
entity = new UploadEntity();
//String regex = "[/|\\\\|//]";
String regex = Regular.REG_FILE_NAME;
Pattern p = Pattern.compile(regex);
String[] strs = p.split(filePath);
String fileName = strs[strs.length - 1];
entity.setFileName(fileName);
entity.setFilePath(filePath);
entity.insert();
}
return entity;
}
/**
* 下载任务是否存在
*/

@ -19,28 +19,33 @@ import android.text.TextUtils;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CommonUtil;
import java.util.List;
/**
* Created by Aria.Lao on 2017/11/1.
* 任务实体工厂
*/
class DGTaskEntityFactory
implements ITaskEntityFactory<DownloadGroupEntity, DownloadGroupTaskEntity> {
private static final String TAG = "DTaskEntityFactory";
private static volatile DGTaskEntityFactory INSTANCE = null;
class DGTEntityFactory implements ITEntityFactory<DownloadGroupEntity, DownloadGroupTaskEntity>,
IGTEntityFactory<DownloadGroupEntity, DownloadGroupTaskEntity> {
private static final String TAG = "DTEntityFactory";
private static volatile DGTEntityFactory INSTANCE = null;
private DGTaskEntityFactory() {
private DGTEntityFactory() {
}
public static DGTaskEntityFactory getInstance() {
public static DGTEntityFactory getInstance() {
if (INSTANCE == null) {
synchronized (DGTaskEntityFactory.class) {
INSTANCE = new DGTaskEntityFactory();
synchronized (DGTEntityFactory.class) {
INSTANCE = new DGTEntityFactory();
}
}
return INSTANCE;
}
/**
* 通过下载实体创建任务实体
*/
@Override public DownloadGroupTaskEntity create(DownloadGroupEntity entity) {
DownloadGroupTaskEntity dgTaskEntity =
DbEntity.findFirst(DownloadGroupTaskEntity.class, "key=?", entity.getGroupName());
@ -53,4 +58,41 @@ class DGTaskEntityFactory
}
return dgTaskEntity;
}
/**
* 对于任务组不能使用这个可用于FTP文件夹下载
*
* @deprecated {@link #create(String, List)}
*/
@Override @Deprecated public DownloadGroupTaskEntity create(String key) {
DownloadGroupTaskEntity dgTaskEntity =
DbEntity.findFirst(DownloadGroupTaskEntity.class, "key=?", key);
if (dgTaskEntity == null) {
dgTaskEntity = new DownloadGroupTaskEntity();
dgTaskEntity.save(getDownloadGroupEntity(key, null));
}
if (dgTaskEntity.entity == null || TextUtils.isEmpty(dgTaskEntity.entity.getKey())) {
dgTaskEntity.save(getDownloadGroupEntity(key, null));
}
dgTaskEntity.urlEntity = CommonUtil.getFtpUrlInfo(key);
return dgTaskEntity;
}
@Override public DownloadGroupTaskEntity create(String groupName, List<String> urls) {
return create(getDownloadGroupEntity(groupName, urls));
}
/**
* 查询任务组实体如果数据库不存在该实体则新创建一个新的任务组实体
*/
private DownloadGroupEntity getDownloadGroupEntity(String groupName, List<String> urls) {
DownloadGroupEntity entity =
DbEntity.findFirst(DownloadGroupEntity.class, "groupName=?", groupName);
if (entity == null) {
entity = new DownloadGroupEntity();
entity.setGroupName(groupName);
entity.setUrls(urls);
}
return entity;
}
}

@ -18,28 +18,33 @@ package com.arialyy.aria.core.manager;
import android.text.TextUtils;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.orm.DbEntity;
import java.io.File;
/**
* Created by Aria.Lao on 2017/11/1.
* 任务实体工厂
*/
class DTaskEntityFactory implements ITaskEntityFactory<DownloadEntity, DownloadTaskEntity> {
private static final String TAG = "DTaskEntityFactory";
private static volatile DTaskEntityFactory INSTANCE = null;
class DTEntityFactory implements ITEntityFactory<DownloadEntity, DownloadTaskEntity> {
private static final String TAG = "DTEntityFactory";
private static volatile DTEntityFactory INSTANCE = null;
private DTaskEntityFactory() {
private DTEntityFactory() {
}
public static DTaskEntityFactory getInstance() {
public static DTEntityFactory getInstance() {
if (INSTANCE == null) {
synchronized (DTaskEntityFactory.class) {
INSTANCE = new DTaskEntityFactory();
synchronized (DTEntityFactory.class) {
INSTANCE = new DTEntityFactory();
}
}
return INSTANCE;
}
/**
* 通过下载实体创建任务实体
*/
@Override public DownloadTaskEntity create(DownloadEntity entity) {
DownloadTaskEntity taskEntity =
DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false' and url=?",
@ -54,4 +59,32 @@ class DTaskEntityFactory implements ITaskEntityFactory<DownloadEntity, DownloadT
}
return taskEntity;
}
/**
* 通过下载地址创建任务实体
*/
@Override public DownloadTaskEntity create(String downloadUrl) {
return create(getEntity(downloadUrl));
}
/**
* 如果任务存在但是下载实体不存在则通过下载地址获取下载实体
*
* @param downloadUrl 下载地址
*/
private DownloadEntity getEntity(String downloadUrl) {
DownloadEntity entity =
DownloadEntity.findFirst(DownloadEntity.class, "url=? and isGroupChild='false'",
downloadUrl);
if (entity == null) {
entity = new DownloadEntity();
entity.setUrl(downloadUrl);
entity.setGroupChild(false);
}
File file = new File(entity.getDownloadPath());
if (!file.exists()) {
entity.setState(IEntity.STATE_WAIT);
}
return entity;
}
}

@ -17,18 +17,16 @@ package com.arialyy.aria.core.manager;
import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity;
import java.util.List;
/**
* 任务组通过组创建任务
* Created by Aria.Lao on 2017/11/1.
*/
interface IEntityFactory<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>> {
/**
* 通过信息实体创建任务实体
*/
TASK_ENTITY create(ENTITY entity);
interface IGTEntityFactory<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>> {
/**
* 通过key创建任务只适应于单任务
* 通过key创建任务
*/
TASK_ENTITY create(String key);
TASK_ENTITY create(String groupName, List<String> urls);
}

@ -21,7 +21,7 @@ import com.arialyy.aria.core.inf.AbsTaskEntity;
/**
* Created by Aria.Lao on 2017/11/1.
*/
interface IEntityFactory<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>> {
interface ITEntityFactory<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>> {
/**
* 通过信息实体创建任务实体
*/

@ -13,9 +13,10 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.manager;
import android.text.TextUtils;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.command.group.GroupCmdFactory;
import com.arialyy.aria.core.inf.AbsGroupTaskEntity;
import com.arialyy.aria.util.ALog;

@ -15,79 +15,194 @@
*/
package com.arialyy.aria.core.manager;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.download.DownloadGroupTaskEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import java.util.concurrent.locks.Lock;
import java.util.concurrent.locks.ReentrantLock;
/**
* Created by Aria.Lao on 2017/11/1.
* 任务实体管理器负责
*/
public class TaskEntityManager {
public class TEManager {
private static final String TAG = "TaskManager";
private static volatile TaskEntityManager INSTANCE = null;
private static volatile TEManager INSTANCE = null;
private Map<String, AbsTaskEntity> map = new ConcurrentHashMap<>();
private Lock lock;
public static TaskEntityManager getInstance() {
public static TEManager getInstance() {
if (INSTANCE == null) {
synchronized (TaskEntityManager.class) {
INSTANCE = new TaskEntityManager();
synchronized (TEManager.class) {
INSTANCE = new TEManager();
}
}
return INSTANCE;
}
private TEManager() {
lock = new ReentrantLock();
}
/**
* 通过下载实体获取下载任务实体如果查找不到任务实体则重新创建任务实体
* 通过key创建任务只适应于单任务不能用于HTTP任务组可用于Ftp文件夹
* 如果是任务组请使用{@link #createGTEntity(Class, List)}
*
* @return 如果任务实体创建失败返回null
*/
public DownloadTaskEntity getDTEntity(DownloadEntity entity) {
AbsTaskEntity tEntity = map.get(convertKey(entity.getKey()));
if (tEntity == null || !(tEntity instanceof DownloadTaskEntity)) {
tEntity = DTEntityFactory.getInstance().create(entity);
map.put(convertKey(entity.getKey()), tEntity);
public <TE extends AbsTaskEntity> TE createTEntity(Class<TE> clazz, String key) {
final Lock lock = this.lock;
lock.lock();
try {
AbsTaskEntity tEntity = map.get(convertKey(key));
if (tEntity == null || tEntity.getClass() != clazz) {
ITEntityFactory factory = chooseFactory(clazz);
if (factory == null) {
ALog.e(TAG, "任务实体创建失败");
return null;
}
tEntity = factory.create(key);
map.put(convertKey(key), tEntity);
}
return (TE) tEntity;
} finally {
lock.unlock();
}
return (DownloadTaskEntity) tEntity;
}
/**
* 通过下载实体获取下载任务组实体如果查找不到任务组实体则重新创建任务组实体
* 创建任务组实体
*
* @return 如果任务实体创建失败返回null
*/
public DownloadGroupTaskEntity getDGTEntity(DownloadGroupEntity entity) {
AbsTaskEntity tEntity = map.get(convertKey(entity.getKey()));
if (tEntity == null || !(tEntity instanceof DownloadGroupTaskEntity)) {
tEntity = DGTEntityFactory.getInstance().create(entity);
map.put(convertKey(entity.getKey()), tEntity);
public <TE extends AbsTaskEntity> TE createGTEntity(Class<TE> clazz, List<String> urls) {
final Lock lock = this.lock;
lock.lock();
try {
String groupName = CommonUtil.getMd5Code(urls);
AbsTaskEntity tEntity = map.get(convertKey(groupName));
if (tEntity == null || tEntity.getClass() != clazz) {
IGTEntityFactory factory = chooseGroupFactory(clazz);
if (factory == null) {
ALog.e(TAG, "任务实体创建失败");
return null;
}
tEntity = factory.create(groupName, urls);
map.put(convertKey(groupName), tEntity);
}
return (TE) tEntity;
} finally {
lock.unlock();
}
return (DownloadGroupTaskEntity) tEntity;
}
/**
* 通过下载实体获取下载任务组实体如果查找不到任务组实体则重新创建任务组实体
* 通过实体创建任务
*
* @return 如果任务实体创建失败返回null
*/
public UploadTaskEntity getUTEntity(UploadEntity entity) {
AbsTaskEntity tEntity = map.get(convertKey(entity.getKey()));
if (tEntity == null || !(tEntity instanceof UploadTaskEntity)) {
tEntity = UTEntityFactory.getInstance().create(entity);
map.put(convertKey(entity.getKey()), tEntity);
public <TE extends AbsTaskEntity> TE createTEntity(Class<TE> clazz, AbsEntity absEntity) {
final Lock lock = this.lock;
lock.lock();
try {
AbsTaskEntity tEntity = map.get(convertKey(absEntity.getKey()));
if (tEntity == null || tEntity.getClass() != clazz) {
ITEntityFactory factory = chooseFactory(clazz);
if (factory == null) {
ALog.e(TAG, "任务实体创建失败");
return null;
}
tEntity = factory.create(absEntity);
map.put(convertKey(absEntity.getKey()), tEntity);
}
return (TE) tEntity;
} finally {
lock.unlock();
}
}
private IGTEntityFactory chooseGroupFactory(Class clazz) {
if (clazz == DownloadGroupTaskEntity.class) {
return DGTEntityFactory.getInstance();
}
return null;
}
private ITEntityFactory chooseFactory(Class clazz) {
if (clazz == DownloadTaskEntity.class) {
return DTEntityFactory.getInstance();
} else if (clazz == UploadTaskEntity.class) {
return UTEntityFactory.getInstance();
} else if (clazz == DownloadGroupTaskEntity.class) {
return DGTEntityFactory.getInstance();
}
return null;
}
/**
* 从任务实体管理器中获取任务实体
*/
public <TE extends AbsTaskEntity> TE getTEntity(Class<TE> clazz, String key) {
final Lock lock = this.lock;
lock.lock();
try {
AbsTaskEntity tEntity = map.get(convertKey(key));
if (tEntity == null) {
return null;
} else {
return (TE) tEntity;
}
} finally {
lock.unlock();
}
}
/**
* 向管理器中增加任务实体
*
* @return {@code false} 实体为null添加失败
*/
public boolean addTEntity(AbsTaskEntity te) {
if (te == null) {
ALog.e(TAG, "任务实体添加失败");
return false;
}
final Lock lock = this.lock;
lock.lock();
try {
return map.put(convertKey(te.key), te) != null;
} finally {
lock.unlock();
}
return (UploadTaskEntity) tEntity;
}
/**
* 通过key删除任务实体
*/
public AbsTaskEntity removeTEntity(String key) {
return map.remove(convertKey(key));
final Lock lock = this.lock;
lock.lock();
try {
return map.remove(convertKey(key));
} finally {
lock.unlock();
}
}
private String convertKey(String key) {
return CommonUtil.encryptBASE64(key);
final Lock lock = this.lock;
lock.lock();
try {
return CommonUtil.keyToHashKey(key);
} finally {
lock.unlock();
}
}
}

@ -13,8 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.aria.core;
package com.arialyy.aria.core.manager;
import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
@ -26,14 +27,14 @@ import java.util.concurrent.ConcurrentHashMap;
* Created by Aria.Lao on 2017/9/1.
* 任务管理器
*/
public class TaskManager {
class TaskManager {
private static final String TAG = "TaskManager";
private static volatile TaskManager INSTANCE = null;
private Map<String, AbsTask> map = new ConcurrentHashMap<>();
public static TaskManager getInstance() {
if (INSTANCE == null) {
synchronized (AriaManager.LOCK) {
synchronized (TaskManager.class) {
INSTANCE = new TaskManager();
}
}

@ -15,43 +15,67 @@
*/
package com.arialyy.aria.core.manager;
import android.text.TextUtils;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.Regular;
import java.util.regex.Pattern;
/**
* Created by Aria.Lao on 2017/11/1.
* 任务实体工厂
*/
class DTaskEntityFactory implements ITaskEntityFactory<DownloadEntity, DownloadTaskEntity> {
private static final String TAG = "DTaskEntityFactory";
private static volatile DTaskEntityFactory INSTANCE = null;
class UTEntityFactory implements ITEntityFactory<UploadEntity, UploadTaskEntity> {
private static final String TAG = "DTEntityFactory";
private static volatile UTEntityFactory INSTANCE = null;
private DTaskEntityFactory() {
private UTEntityFactory() {
}
public static DTaskEntityFactory getInstance() {
public static UTEntityFactory getInstance() {
if (INSTANCE == null) {
synchronized (DTaskEntityFactory.class) {
INSTANCE = new DTaskEntityFactory();
synchronized (UTEntityFactory.class) {
INSTANCE = new UTEntityFactory();
}
}
return INSTANCE;
}
@Override public DownloadTaskEntity create(DownloadEntity entity) {
DownloadTaskEntity taskEntity =
DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false' and url=?",
entity.getDownloadPath(), entity.getUrl());
if (taskEntity == null) {
taskEntity = new DownloadTaskEntity();
taskEntity.save(entity);
} else if (taskEntity.entity == null || TextUtils.isEmpty(taskEntity.entity.getUrl())) {
taskEntity.save(entity);
} else if (!taskEntity.entity.getUrl().equals(entity.getUrl())) { //处理地址切换而保存路径不变
taskEntity.save(entity);
@Override public UploadTaskEntity create(UploadEntity entity) {
UploadTaskEntity uTaskEntity =
DbEntity.findFirst(UploadTaskEntity.class, "key=?", entity.getFilePath());
if (uTaskEntity == null) {
uTaskEntity = new UploadTaskEntity();
uTaskEntity.entity = entity;
}
return taskEntity;
if (uTaskEntity.entity == null) {
uTaskEntity.entity = entity;
}
return uTaskEntity;
}
@Override public UploadTaskEntity create(String key) {
return create(getUploadEntity(key));
}
/**
* 从数据中读取上传实体如果数据库查不到则新创建一个上传实体
*
* @param filePath 上传文件的文件路径
*/
private UploadEntity getUploadEntity(String filePath) {
UploadEntity entity = UploadEntity.findFirst(UploadEntity.class, "filePath=?", filePath);
if (entity == null) {
entity = new UploadEntity();
//String regex = "[/|\\\\|//]";
String regex = Regular.REG_FILE_NAME;
Pattern p = Pattern.compile(regex);
String[] strs = p.split(filePath);
String fileName = strs[strs.length - 1];
entity.setFileName(fileName);
entity.setFilePath(filePath);
entity.insert();
}
return entity;
}
}

@ -20,6 +20,7 @@ import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.core.queue.pool.BaseCachePool;
import com.arialyy.aria.core.queue.pool.BaseExecutePool;
import com.arialyy.aria.util.ALog;
@ -164,6 +165,7 @@ abstract class AbsTaskQueue<TASK extends AbsTask, TASK_ENTITY extends AbsTaskEnt
}
@Override public void removeTaskFormQueue(String key) {
//TEManager.getInstance().removeTEntity(key);
TASK task = mExecutePool.getTask(key);
if (task != null) {
ALog.d(TAG, "从执行池删除任务,删除" + (mExecutePool.removeTask(task) ? "成功" : "失败"));
@ -172,6 +174,7 @@ abstract class AbsTaskQueue<TASK extends AbsTask, TASK_ENTITY extends AbsTaskEnt
if (task != null) {
ALog.d(TAG, "从缓存池删除任务,删除" + (mCachePool.removeTask(task) ? "成功" : "失败"));
}
}
@Override public void reTryStart(TASK task) {

@ -17,7 +17,6 @@ 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.DownloadTask;
import com.arialyy.aria.core.inf.AbsEntity;
@ -26,6 +25,7 @@ import com.arialyy.aria.core.inf.AbsTask;
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.manager.TEManager;
import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.upload.UploadTask;
import com.arialyy.aria.util.ALog;
@ -175,6 +175,9 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
handleFailTask(task);
break;
}
if (what == CANCEL || what == COMPLETE) {
TEManager.getInstance().removeTEntity(task.getKey());
}
callback(what, task);
}
@ -269,6 +272,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
} else {
mQueue.removeTaskFormQueue(task.getKey());
startNextTask();
TEManager.getInstance().removeTEntity(task.getKey());
}
}
};
@ -281,7 +285,7 @@ abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, TASK extends Abs
private void startNextTask() {
TASK newTask = mQueue.getNextTask();
if (newTask == null) {
ALog.d(TAG, "没有下一任务");
ALog.i(TAG, "没有下一任务");
return;
}
if (newTask.getState() == IEntity.STATE_WAIT) {

@ -17,10 +17,9 @@ package com.arialyy.aria.core.upload;
import android.support.annotation.NonNull;
import android.text.TextUtils;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.inf.AbsUploadTarget;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.core.manager.TEManager;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
@ -33,23 +32,22 @@ import java.io.File;
public class FtpUploadTarget
extends AbsUploadTarget<FtpUploadTarget, UploadEntity, UploadTaskEntity> {
private final String TAG = "FtpUploadTarget";
private FtpUrlEntity mUrlEntity;
FtpUploadTarget(String filePath, String targetName) {
this.mTargetName = targetName;
mTaskEntity = DbEntity.findFirst(UploadTaskEntity.class, "key=?", filePath);
initTask(filePath);
}
private void initTask(String filePath) {
mTaskEntity = TEManager.getInstance().getTEntity(UploadTaskEntity.class, filePath);
if (mTaskEntity == null) {
mTaskEntity = new UploadTaskEntity();
mTaskEntity.entity = getUploadEntity(filePath);
}
if (mTaskEntity.entity == null) {
mTaskEntity.entity = getUploadEntity(filePath);
mTaskEntity = TEManager.getInstance().createTEntity(UploadTaskEntity.class, filePath);
}
mTaskEntity.requestType = AbsTaskEntity.FTP;
mEntity = mTaskEntity.entity;
File file = new File(filePath);
mEntity.setFileName(file.getName());
mEntity.setFileSize(file.length());
mTaskEntity.requestType = AbsTaskEntity.FTP;
}
/**

@ -16,12 +16,9 @@
package com.arialyy.aria.core.upload;
import android.support.annotation.NonNull;
import com.arialyy.aria.core.inf.AbsDownloadTarget;
import com.arialyy.aria.core.inf.AbsUploadTarget;
import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.core.manager.TEManager;
import java.io.File;
import java.util.regex.Pattern;
/**
* Created by lyy on 2017/2/28.
@ -31,18 +28,18 @@ public class UploadTarget extends AbsUploadTarget<UploadTarget, UploadEntity, Up
UploadTarget(String filePath, String targetName) {
this.mTargetName = targetName;
mTaskEntity = DbEntity.findFirst(UploadTaskEntity.class, "key=?", filePath);
initTask(filePath);
}
private void initTask(String filePath) {
mTaskEntity = TEManager.getInstance().getTEntity(UploadTaskEntity.class, filePath);
if (mTaskEntity == null) {
mTaskEntity = new UploadTaskEntity();
mTaskEntity.entity = getUploadEntity(filePath);
}
if (mTaskEntity.entity == null) {
mTaskEntity.entity = getUploadEntity(filePath);
mTaskEntity = TEManager.getInstance().createTEntity(UploadTaskEntity.class, filePath);
}
mEntity = mTaskEntity.entity;
File file = new File(filePath);
mEntity.setFileName(file.getName());
mEntity.setFileSize(file.length());
mEntity = mTaskEntity.entity;
//http暂时不支持断点上传
mTaskEntity.isSupportBP = false;
}

@ -19,7 +19,6 @@ package com.arialyy.aria.util;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.aria.core.AriaManager;
/**
* Created by Aria.Lao on 2017/10/25.
@ -27,7 +26,16 @@ import com.arialyy.aria.core.AriaManager;
*/
public class ALog {
public static int LOG_LEVEL = AriaManager.LOG_DEFAULT;
public static final int LOG_LEVEL_VERBOSE = 2;
public static final int LOG_LEVEL_DEBUG = 3;
public static final int LOG_LEVEL_INFO = 4;
public static final int LOG_LEVEL_WARN = 5;
public static final int LOG_LEVEL_ERROR = 6;
public static final int LOG_LEVEL_ASSERT = 7;
public static final int LOG_CLOSE = 8;
public static final int LOG_DEFAULT = LOG_LEVEL_DEBUG;
public static int LOG_LEVEL = LOG_DEFAULT;
public static int v(String tag, String msg) {
return println(Log.VERBOSE, tag, msg);

@ -1,4 +1,10 @@
## 开发日志
+ v_3.3.6
- 增加日志输出级别控制
- 修复公网FTP地址不能下载的问题
- 修复http下载地址有空格的时候下载失败的问题
- 修复Activity在`onDestroy()`中调用`Aria.download(this).unRegister();`导致回调失效的问题
- 优化代码,优化了IO性能
+ v_3.3.5 修复任务组、上传任务无法启动的bug
+ v_3.3.4 优化任务代码结构,修复上一个版本暂停后无法自动执行任务的问题
+ v_3.3.3 修复进度条错乱的问题,修复同一时间多次调用start导致重复下载的问题

@ -91,6 +91,8 @@ protected void onCreate(Bundle savedInstanceState) {
### [更多说明,见WIKI](https://github.com/AriaLyy/Aria/wiki)
### [历史版本说明](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
## 混淆配置
```
-dontwarn com.arialyy.aria.**

@ -8,7 +8,7 @@
<threadNum value="1"/>
<!--设置下载队列最大任务数, 默认为2-->
<maxTaskNum value="1"/>
<maxTaskNum value="2"/>
<!--设置下载失败,重试次数,默认为10-->
<reTryNum value="2"/>
@ -17,7 +17,7 @@
<reTryInterval value="5000"/>
<!--设置url连接超时时间,单位为毫秒,默认5000毫秒-->
<connectTimeOut value="1000"/>
<connectTimeOut value="5000"/>
<!--设置IO流读取时间,单位为毫秒,默认20000毫秒,该时间不能少于10000毫秒-->
<iOTimeOut value="10000"/>

@ -37,7 +37,7 @@ import java.io.File;
public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding> {
//private final String URL = "ftp://192.168.1.9:21/下载/AriaPrj.zip";
//private final String URL = "ftp://192.168.1.9:21/下载/[电影天堂www.dy2018.com]赛车总动员3BD中英双字.mp4";
private final String URL = "ftp://j:j@g.dygod18.com:7978/江湖告急BD国粤双语中字[电影天堂www.dy2018.com].mkv";
private final String URL = "ftp://h:h@tv.dl1234.com:2199/付岩洞复仇者们05.mkv";
//private final String URL = "ftp://172.18.104.64:21/upload/测试/成都.mp3";
@Override protected void init(Bundle savedInstanceState) {

@ -34,6 +34,7 @@ import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.aria.core.download.DownloadTarget;
import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.show.L;
import com.arialyy.frame.util.show.T;
@ -47,7 +48,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
private static final String DOWNLOAD_URL =
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
//"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_1";
//"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";
@ -59,7 +60,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-";
//"http://172.18.104.50:8080/download/_302turn";
//"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk";
"http://172.21.1.99:8080/download/test+ 中文123.zip";
//"http://172.21.1.99:8080/download/test+ 中文123.zip";
@Bind(R.id.start) Button mStart;
@Bind(R.id.stop) Button mStop;
@Bind(R.id.cancel) Button mCancel;
@ -221,11 +222,17 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
}
private void startD(){
Aria.download(this).load("aaaa.apk");
//Aria.get(this).setLogLevel(ALog.LOG_CLOSE);
//Aria.download(this).load("aaaa.apk");
Aria.download(SingleTaskActivity.this)
.load(DOWNLOAD_URL)
.addHeader("groupName", "value")
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk")
.start();
}
@Override protected void onDestroy() {
super.onDestroy();
Aria.download(this).unRegister();
}
}

@ -39,7 +39,7 @@ task clean(type: Delete) {
ext {
userOrg = 'arialyy'
groupId = 'com.arialyy.aria'
publishVersion = '3.3.6_dev_1'
publishVersion = '3.3.6_dev_2'
// publishVersion = '1.0.3' //FTP插件
repoName='maven'
desc = 'android 下载框架'

Loading…
Cancel
Save