|
|
@ -68,12 +68,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public DownloadTarget load(DownloadEntity entity, boolean refreshInfo) { |
|
|
|
public DownloadTarget load(DownloadEntity entity, boolean refreshInfo) { |
|
|
|
CheckUtil.checkDownloadUrl(entity.getUrl()); |
|
|
|
CheckUtil.checkDownloadEntity(entity); |
|
|
|
if (entity.getUrl().startsWith("ftp")) { |
|
|
|
|
|
|
|
ALog.w(TAG, |
|
|
|
|
|
|
|
"使用实体启动FTP下载,如果你的FTP服务器需要登录,那么你需要调用登录的接口,如:Aria.download(this).load(url).login(user, pw).start()"); |
|
|
|
|
|
|
|
return new FtpDownloadTarget(entity, targetName, refreshInfo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new DownloadTarget(entity, targetName, refreshInfo); |
|
|
|
return new DownloadTarget(entity, targetName, refreshInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -93,7 +88,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public DownloadTarget load(@NonNull String url, boolean refreshInfo) { |
|
|
|
public DownloadTarget load(@NonNull String url, boolean refreshInfo) { |
|
|
|
CheckUtil.checkDownloadUrl(url); |
|
|
|
CheckUtil.checkUrl(url); |
|
|
|
return new DownloadTarget(url, targetName, refreshInfo); |
|
|
|
return new DownloadTarget(url, targetName, refreshInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -105,6 +100,28 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
return new DownloadGroupTarget(urls, targetName); |
|
|
|
return new DownloadGroupTarget(urls, targetName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 使用下载实体执行FTP下载操作 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param entity 下载实体 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public FtpDownloadTarget loadFtp(DownloadEntity entity) { |
|
|
|
|
|
|
|
return loadFtp(entity, false); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
|
|
|
|
* 使用下载实体执行下载操作 |
|
|
|
|
|
|
|
* |
|
|
|
|
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
|
|
|
|
*/ |
|
|
|
|
|
|
|
public FtpDownloadTarget loadFtp(DownloadEntity entity, boolean refreshInfo) { |
|
|
|
|
|
|
|
CheckUtil.checkDownloadEntity(entity); |
|
|
|
|
|
|
|
if (!entity.getUrl().startsWith("ftp")) { |
|
|
|
|
|
|
|
throw new IllegalArgumentException("非FTP请求不能使用该方法"); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
return new FtpDownloadTarget(entity, targetName, refreshInfo); |
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
/** |
|
|
|
/** |
|
|
|
* 加载ftp单任务下载地址 |
|
|
|
* 加载ftp单任务下载地址 |
|
|
|
*/ |
|
|
|
*/ |
|
|
@ -118,7 +135,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
* @param refreshInfo 是否刷新下载信息 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public FtpDownloadTarget loadFtp(@NonNull String url, boolean refreshInfo) { |
|
|
|
public FtpDownloadTarget loadFtp(@NonNull String url, boolean refreshInfo) { |
|
|
|
CheckUtil.checkDownloadUrl(url); |
|
|
|
CheckUtil.checkUrl(url); |
|
|
|
return new FtpDownloadTarget(url, targetName, refreshInfo); |
|
|
|
return new FtpDownloadTarget(url, targetName, refreshInfo); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -136,7 +153,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
* 加载ftp文件夹下载地址 |
|
|
|
* 加载ftp文件夹下载地址 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public FtpDirDownloadTarget loadFtpDir(@NonNull String dirUrl) { |
|
|
|
public FtpDirDownloadTarget loadFtpDir(@NonNull String dirUrl) { |
|
|
|
CheckUtil.checkDownloadUrl(dirUrl); |
|
|
|
CheckUtil.checkUrl(dirUrl); |
|
|
|
return new FtpDirDownloadTarget(dirUrl, targetName); |
|
|
|
return new FtpDirDownloadTarget(dirUrl, targetName); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -192,7 +209,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
* 通过下载链接获取下载实体 |
|
|
|
* 通过下载链接获取下载实体 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public DownloadEntity getDownloadEntity(String downloadUrl) { |
|
|
|
public DownloadEntity getDownloadEntity(String downloadUrl) { |
|
|
|
CheckUtil.checkDownloadUrl(downloadUrl); |
|
|
|
CheckUtil.checkUrl(downloadUrl); |
|
|
|
return DbEntity.findFirst(DownloadEntity.class, "url=? and isGroupChild='false'", downloadUrl); |
|
|
|
return DbEntity.findFirst(DownloadEntity.class, "url=? and isGroupChild='false'", downloadUrl); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
@ -200,7 +217,7 @@ public class DownloadReceiver extends AbsReceiver { |
|
|
|
* 通过下载链接获取保存在数据库的下载任务实体 |
|
|
|
* 通过下载链接获取保存在数据库的下载任务实体 |
|
|
|
*/ |
|
|
|
*/ |
|
|
|
public DownloadTaskEntity getDownloadTask(String downloadUrl) { |
|
|
|
public DownloadTaskEntity getDownloadTask(String downloadUrl) { |
|
|
|
CheckUtil.checkDownloadUrl(downloadUrl); |
|
|
|
CheckUtil.checkUrl(downloadUrl); |
|
|
|
DownloadEntity entity = getDownloadEntity(downloadUrl); |
|
|
|
DownloadEntity entity = getDownloadEntity(downloadUrl); |
|
|
|
if (entity == null || TextUtils.isEmpty(entity.getDownloadPath())) return null; |
|
|
|
if (entity == null || TextUtils.isEmpty(entity.getDownloadPath())) return null; |
|
|
|
return DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false'", |
|
|
|
return DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false'", |
|
|
|