1 parent
96efa35c4e
commit
e015c2a2f7
55 files changed
+324
-523
No files matched your search
@@ -1,4 +1,7 @@
|
|||||||
## 开发日志
|
## 开发日志
|
||||||
|
+ v_3.8.6
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/608
|
||||||
|
- 优化异常提示
|
||||||
+ v_3.8.5 (2020/1/18)
|
+ v_3.8.5 (2020/1/18)
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/599
|
- fix bug https://github.com/AriaLyy/Aria/issues/599
|
||||||
- 增加密钥url转换器的参数 https://github.com/AriaLyy/Aria/issues/603
|
- 增加密钥url转换器的参数 https://github.com/AriaLyy/Aria/issues/603
|
||||||
|
|||||||
@@ -31,8 +31,7 @@ import com.arialyy.aria.core.common.FtpConnectionMode;
|
|||||||
import com.arialyy.aria.core.loader.IInfoTask;
|
import com.arialyy.aria.core.loader.IInfoTask;
|
||||||
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaFTPException;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CheckUtil;
|
import com.arialyy.aria.util.CheckUtil;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
@@ -161,9 +160,9 @@ public abstract class AbsFtpInfoTask<ENTITY extends AbsEntity, TASK_WRAPPER exte
|
|||||||
loginSuccess = client.login(urlEntity.user, urlEntity.password, urlEntity.account);
|
loginSuccess = client.login(urlEntity.user, urlEntity.password, urlEntity.account);
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ALog.e(TAG,
|
e.printStackTrace();
|
||||||
new TaskException(TAG, String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(),
|
ALog.e(TAG, String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(),
|
||||||
client.getReplyString()), e));
|
client.getReplyString()));
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -329,7 +328,7 @@ public abstract class AbsFtpInfoTask<ENTITY extends AbsEntity, TASK_WRAPPER exte
|
|||||||
needRetry = needRetry && !CheckUtil.ftpIsBadRequest(client.getReplyCode());
|
needRetry = needRetry && !CheckUtil.ftpIsBadRequest(client.getReplyCode());
|
||||||
}
|
}
|
||||||
|
|
||||||
callback.onFail(mEntity, new AriaIOException(TAG, msg), needRetry);
|
callback.onFail(mEntity, new AriaFTPException(TAG, msg), needRetry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.arialyy.aria.core.FtpUrlEntity;
|
|||||||
import com.arialyy.aria.core.common.FtpConnectionMode;
|
import com.arialyy.aria.core.common.FtpConnectionMode;
|
||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaFTPException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.SSLContextUtil;
|
import com.arialyy.aria.util.SSLContextUtil;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
@@ -105,7 +105,7 @@ public abstract class BaseFtpThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
int reply = client.getReplyCode();
|
int reply = client.getReplyCode();
|
||||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaFTPException(TAG,
|
||||||
String.format("无法连接到ftp服务器,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
|
String.format("无法连接到ftp服务器,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import aria.apache.commons.net.ftp.FTPReply;
|
|||||||
import com.arialyy.aria.core.common.CompleteInfo;
|
import com.arialyy.aria.core.common.CompleteInfo;
|
||||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaFTPException;
|
||||||
import com.arialyy.aria.ftp.AbsFtpInfoTask;
|
import com.arialyy.aria.ftp.AbsFtpInfoTask;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.FileUtil;
|
import com.arialyy.aria.util.FileUtil;
|
||||||
@@ -41,7 +41,7 @@ final class FtpDFileInfoTask extends AbsFtpInfoTask<DownloadEntity, DTaskWrapper
|
|||||||
@Override protected void handleFile(String remotePath, FTPFile ftpFile) {
|
@Override protected void handleFile(String remotePath, FTPFile ftpFile) {
|
||||||
super.handleFile(remotePath, ftpFile);
|
super.handleFile(remotePath, ftpFile);
|
||||||
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), ftpFile.getSize())) {
|
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), ftpFile.getSize())) {
|
||||||
callback.onFail(mEntity, new AriaIOException(TAG,
|
callback.onFail(mEntity, new AriaFTPException(TAG,
|
||||||
String.format("获取ftp文件信息失败,内存空间不足, filePath: %s", mEntity.getFilePath())),
|
String.format("获取ftp文件信息失败,内存空间不足, filePath: %s", mEntity.getFilePath())),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.arialyy.aria.core.inf.IEntity;
|
|||||||
import com.arialyy.aria.core.listener.IEventListener;
|
import com.arialyy.aria.core.listener.IEventListener;
|
||||||
import com.arialyy.aria.core.loader.IInfoTask;
|
import com.arialyy.aria.core.loader.IInfoTask;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -79,7 +79,7 @@ final class FtpDGLoader extends AbsGroupLoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
//getListener().onFail(needRetry, e);
|
//getListener().onFail(needRetry, e);
|
||||||
fail(e, needRetry);
|
fail(e, needRetry);
|
||||||
}
|
}
|
||||||
|
|||||||
+11
-11
@@ -18,8 +18,7 @@ package com.arialyy.aria.ftp.download;
|
|||||||
import aria.apache.commons.net.ftp.FTPClient;
|
import aria.apache.commons.net.ftp.FTPClient;
|
||||||
import aria.apache.commons.net.ftp.FTPReply;
|
import aria.apache.commons.net.ftp.FTPReply;
|
||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaFTPException;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.ftp.BaseFtpThreadTaskAdapter;
|
import com.arialyy.aria.ftp.BaseFtpThreadTaskAdapter;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||||
@@ -57,7 +56,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
getThreadRecord().endLocation));
|
getThreadRecord().endLocation));
|
||||||
client = createClient();
|
client = createClient();
|
||||||
if (client == null) {
|
if (client == null) {
|
||||||
fail(new TaskException(TAG, "ftp client 创建失败"), false);
|
fail(new AriaFTPException(TAG, "ftp client 创建失败"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (getThreadRecord().startLocation > 0) {
|
if (getThreadRecord().startLocation > 0) {
|
||||||
@@ -66,7 +65,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
//发送第二次指令时,还需要再做一次判断
|
//发送第二次指令时,还需要再做一次判断
|
||||||
int reply = client.getReplyCode();
|
int reply = client.getReplyCode();
|
||||||
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.COMMAND_OK) {
|
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.COMMAND_OK) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaFTPException(TAG,
|
||||||
String.format("获取文件信息错误,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
|
String.format("获取文件信息错误,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
@@ -77,7 +76,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
is = client.retrieveFileStream(remotePath);
|
is = client.retrieveFileStream(remotePath);
|
||||||
reply = client.getReplyCode();
|
reply = client.getReplyCode();
|
||||||
if (!FTPReply.isPositivePreliminary(reply)) {
|
if (!FTPReply.isPositivePreliminary(reply)) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaFTPException(TAG,
|
||||||
String.format("获取流失败,错误码为:%s,msg:%s", reply, client.getReplyString())), true);
|
String.format("获取流失败,错误码为:%s,msg:%s", reply, client.getReplyString())), true);
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
return;
|
return;
|
||||||
@@ -90,9 +89,9 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
handleComplete();
|
handleComplete();
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), false);
|
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), false);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (is != null) {
|
if (is != null) {
|
||||||
@@ -154,7 +153,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
handleComplete();
|
handleComplete();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (fos != null) {
|
if (fos != null) {
|
||||||
@@ -179,8 +178,9 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
BufferedRandomAccessFile file = null;
|
BufferedRandomAccessFile file = null;
|
||||||
try {
|
try {
|
||||||
file =
|
file =
|
||||||
new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd", getTaskConfig().getBuffSize());
|
new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd",
|
||||||
if (getThreadRecord().startLocation > 0){
|
getTaskConfig().getBuffSize());
|
||||||
|
if (getThreadRecord().startLocation > 0) {
|
||||||
file.seek(getThreadRecord().startLocation);
|
file.seek(getThreadRecord().startLocation);
|
||||||
}
|
}
|
||||||
byte[] buffer = new byte[getTaskConfig().getBuffSize()];
|
byte[] buffer = new byte[getTaskConfig().getBuffSize()];
|
||||||
@@ -203,7 +203,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), true);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import com.arialyy.aria.core.loader.NormalLoader;
|
|||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.core.task.IThreadTask;
|
import com.arialyy.aria.core.task.IThreadTask;
|
||||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
|
|
||||||
final class FtpULoader extends NormalLoader<UTaskWrapper> {
|
final class FtpULoader extends NormalLoader<UTaskWrapper> {
|
||||||
private FTPFile ftpFile;
|
private FTPFile ftpFile;
|
||||||
@@ -79,7 +79,7 @@ final class FtpULoader extends NormalLoader<UTaskWrapper> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
getListener().onFail(needRetry, e);
|
getListener().onFail(needRetry, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -21,7 +21,7 @@ import aria.apache.commons.net.ftp.FTPReply;
|
|||||||
import aria.apache.commons.net.ftp.OnFtpInputStreamListener;
|
import aria.apache.commons.net.ftp.OnFtpInputStreamListener;
|
||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaFTPException;
|
||||||
import com.arialyy.aria.ftp.BaseFtpThreadTaskAdapter;
|
import com.arialyy.aria.ftp.BaseFtpThreadTaskAdapter;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||||
@@ -63,7 +63,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
client.setRestartOffset(getThreadRecord().startLocation);
|
client.setRestartOffset(getThreadRecord().startLocation);
|
||||||
int reply = client.getReplyCode();
|
int reply = client.getReplyCode();
|
||||||
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.FILE_ACTION_OK) {
|
if (!FTPReply.isPositivePreliminary(reply) && reply != FTPReply.FILE_ACTION_OK) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaFTPException(TAG,
|
||||||
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply,
|
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply,
|
||||||
client.getReplyString(), getEntity().getFilePath())), false);
|
client.getReplyString(), getEntity().getFilePath())), false);
|
||||||
client.disconnect();
|
client.disconnect();
|
||||||
@@ -80,8 +80,8 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
if (getThreadTask().isBreak()) {
|
if (getThreadTask().isBreak()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
if (!complete){
|
if (!complete) {
|
||||||
fail(new AriaIOException(TAG, "ftp文件上传失败"), false);
|
fail(new AriaFTPException(TAG, "ftp文件上传失败"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
ALog.i(TAG,
|
ALog.i(TAG,
|
||||||
@@ -89,11 +89,11 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
complete();
|
complete();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaFTPException(TAG,
|
||||||
String.format("上传失败,filePath: %s, uploadUrl: %s", getEntity().getFilePath(),
|
String.format("上传失败,filePath: %s, uploadUrl: %s", getEntity().getFilePath(),
|
||||||
getThreadConfig().url)), true);
|
getThreadConfig().url)), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(new AriaIOException(TAG, null, e), false);
|
fail(new AriaFTPException(TAG, null, e), false);
|
||||||
} finally {
|
} finally {
|
||||||
try {
|
try {
|
||||||
if (file != null) {
|
if (file != null) {
|
||||||
@@ -132,7 +132,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
@Override public void run() {
|
@Override public void run() {
|
||||||
try {
|
try {
|
||||||
if (isTimeOut) {
|
if (isTimeOut) {
|
||||||
fail(new AriaIOException(TAG, "socket连接失败,该问题一般出现于网络断开,客户端重新连接,"
|
fail(new AriaFTPException(TAG, "socket连接失败,该问题一般出现于网络断开,客户端重新连接,"
|
||||||
+ "但是服务器端无法创建socket缺没有返回错误码的情况。"), false);
|
+ "但是服务器端无法创建socket缺没有返回错误码的情况。"), false);
|
||||||
if (fa != null) {
|
if (fa != null) {
|
||||||
fa.close();
|
fa.close();
|
||||||
@@ -195,7 +195,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
if (e.getMessage().contains("AriaIOException caught while copying")) {
|
if (e.getMessage().contains("AriaIOException caught while copying")) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
} else {
|
} else {
|
||||||
fail(new AriaIOException(TAG, msg, e), !storeSuccess);
|
fail(new AriaFTPException(TAG, msg, e), !storeSuccess);
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
} finally {
|
} finally {
|
||||||
@@ -204,7 +204,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
|
|||||||
int reply = client.getReplyCode();
|
int reply = client.getReplyCode();
|
||||||
if (!FTPReply.isPositiveCompletion(reply)) {
|
if (!FTPReply.isPositiveCompletion(reply)) {
|
||||||
if (reply != FTPReply.TRANSFER_ABORTED) {
|
if (reply != FTPReply.TRANSFER_ABORTED) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaFTPException(TAG,
|
||||||
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply, client.getReplyString(),
|
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply, client.getReplyString(),
|
||||||
getEntity().getFilePath())), false);
|
getEntity().getFilePath())), false);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -27,9 +27,7 @@ import com.arialyy.aria.core.download.DownloadEntity;
|
|||||||
import com.arialyy.aria.core.loader.IInfoTask;
|
import com.arialyy.aria.core.loader.IInfoTask;
|
||||||
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
||||||
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaHTTPException;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.http.ConnectionHelp;
|
import com.arialyy.aria.http.ConnectionHelp;
|
||||||
import com.arialyy.aria.http.HttpTaskOption;
|
import com.arialyy.aria.http.HttpTaskOption;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
@@ -40,6 +38,7 @@ import com.arialyy.aria.util.RecordUtil;
|
|||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
import java.io.InputStream;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.OutputStreamWriter;
|
import java.io.OutputStreamWriter;
|
||||||
import java.io.UnsupportedEncodingException;
|
import java.io.UnsupportedEncodingException;
|
||||||
@@ -85,14 +84,16 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
conn.connect();
|
conn.connect();
|
||||||
handleConnect(conn);
|
handleConnect(conn);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
failDownload(new AriaHTTPException(TAG,
|
||||||
failDownload(new AriaIOException(TAG,
|
String.format("下载失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl()),
|
||||||
String.format("下载失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl())),
|
e), true);
|
||||||
true);
|
|
||||||
} finally {
|
} finally {
|
||||||
if (conn != null) {
|
if (conn != null) {
|
||||||
try {
|
try {
|
||||||
conn.getInputStream().close();
|
InputStream is = conn.getInputStream();
|
||||||
|
if (is != null){
|
||||||
|
is.close();
|
||||||
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -132,7 +133,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
long len = lenAdapter.handleFileLen(conn.getHeaderFields());
|
long len = lenAdapter.handleFileLen(conn.getHeaderFields());
|
||||||
|
|
||||||
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), len)) {
|
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), len)) {
|
||||||
failDownload(new TaskException(TAG,
|
failDownload(new AriaHTTPException(TAG,
|
||||||
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getFilePath(),
|
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getFilePath(),
|
||||||
mEntity.getUrl())), false);
|
mEntity.getUrl())), false);
|
||||||
return;
|
return;
|
||||||
@@ -176,7 +177,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
if (!checkLen(len) && !isChunked) {
|
if (!checkLen(len) && !isChunked) {
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
failDownload(
|
failDownload(
|
||||||
new AriaIOException(TAG, String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
new AriaHTTPException(TAG,
|
||||||
|
String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
@@ -203,7 +205,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
} else if (!checkLen(len) && !isChunked) {
|
} else if (!checkLen(len) && !isChunked) {
|
||||||
if (len < 0) {
|
if (len < 0) {
|
||||||
failDownload(
|
failDownload(
|
||||||
new AriaIOException(TAG, String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
new AriaHTTPException(TAG,
|
||||||
|
String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
ALog.d(TAG, "len < 0");
|
ALog.d(TAG, "len < 0");
|
||||||
@@ -214,8 +217,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
mTaskWrapper.setSupportBP(false);
|
mTaskWrapper.setSupportBP(false);
|
||||||
end = true;
|
end = true;
|
||||||
} else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
|
} else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
|
||||||
failDownload(new AriaIOException(TAG,
|
failDownload(new AriaHTTPException(TAG,
|
||||||
String.format("任务下载失败,errorCode:404, url: %s", mEntity.getUrl())), true);
|
String.format("任务下载失败,errorCode:404, url: %s", mEntity.getUrl())), false);
|
||||||
} else if (code == HttpURLConnection.HTTP_MOVED_TEMP
|
} else if (code == HttpURLConnection.HTTP_MOVED_TEMP
|
||||||
|| code == HttpURLConnection.HTTP_MOVED_PERM
|
|| code == HttpURLConnection.HTTP_MOVED_PERM
|
||||||
|| code == HttpURLConnection.HTTP_SEE_OTHER
|
|| code == HttpURLConnection.HTTP_SEE_OTHER
|
||||||
@@ -223,7 +226,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
|| code == 307) {
|
|| code == 307) {
|
||||||
handleUrlReTurn(conn, conn.getHeaderField("Location"));
|
handleUrlReTurn(conn, conn.getHeaderField("Location"));
|
||||||
} else {
|
} else {
|
||||||
failDownload(new AriaIOException(TAG,
|
failDownload(new AriaHTTPException(TAG,
|
||||||
String.format("任务下载失败,errorCode:%s, errorMsg: %s, url: %s", code,
|
String.format("任务下载失败,errorCode:%s, errorMsg: %s, url: %s", code,
|
||||||
conn.getResponseMessage(), mEntity.getUrl())), !CheckUtil.httpIsBadRequest(code));
|
conn.getResponseMessage(), mEntity.getUrl())), !CheckUtil.httpIsBadRequest(code));
|
||||||
}
|
}
|
||||||
@@ -298,7 +301,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
||||||
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false);
|
callback.onFail(mEntity, new AriaHTTPException(TAG, "获取重定向链接失败"), false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -308,7 +311,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckUtil.checkUrl(newUrl)) {
|
if (!CheckUtil.checkUrl(newUrl)) {
|
||||||
failDownload(new TaskException(TAG, "下载失败,重定向url错误"), false);
|
failDownload(new AriaHTTPException(TAG, "下载失败,重定向url错误"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
taskOption.setRedirectUrl(newUrl);
|
taskOption.setRedirectUrl(newUrl);
|
||||||
@@ -341,7 +344,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void failDownload(BaseException e, boolean needRetry) {
|
private void failDownload(AriaHTTPException e, boolean needRetry) {
|
||||||
if (callback != null) {
|
if (callback != null) {
|
||||||
callback.onFail(mEntity, e, needRetry);
|
callback.onFail(mEntity, e, needRetry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -23,8 +23,8 @@ import com.arialyy.aria.core.download.DownloadEntity;
|
|||||||
import com.arialyy.aria.core.listener.DownloadGroupListener;
|
import com.arialyy.aria.core.listener.DownloadGroupListener;
|
||||||
import com.arialyy.aria.core.loader.IInfoTask;
|
import com.arialyy.aria.core.loader.IInfoTask;
|
||||||
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaHTTPException;
|
||||||
import com.arialyy.aria.http.HttpTaskOption;
|
import com.arialyy.aria.http.HttpTaskOption;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
@@ -55,11 +55,11 @@ public final class HttpDGInfoTask implements IInfoTask {
|
|||||||
ALog.d(TAG, "获取子任务信息完成");
|
ALog.d(TAG, "获取子任务信息完成");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
ALog.e(TAG, String.format("获取文件信息失败,url:%s", ((DownloadEntity) entity).getUrl()));
|
ALog.e(TAG, String.format("获取文件信息失败,url:%s", ((DownloadEntity) entity).getUrl()));
|
||||||
count++;
|
count++;
|
||||||
failCount++;
|
failCount++;
|
||||||
listener.onSubFail((DownloadEntity) entity, new AriaIOException(TAG,
|
listener.onSubFail((DownloadEntity) entity, new AriaHTTPException(TAG,
|
||||||
String.format("子任务获取文件长度失败,url:%s", ((DownloadEntity) entity).getUrl())));
|
String.format("子任务获取文件长度失败,url:%s", ((DownloadEntity) entity).getUrl())));
|
||||||
checkGetSizeComplete(count, failCount);
|
checkGetSizeComplete(count, failCount);
|
||||||
}
|
}
|
||||||
@@ -121,7 +121,7 @@ public final class HttpDGInfoTask implements IInfoTask {
|
|||||||
*/
|
*/
|
||||||
private void checkGetSizeComplete(int count, int failCount) {
|
private void checkGetSizeComplete(int count, int failCount) {
|
||||||
if (failCount == wrapper.getSubTaskWrapper().size()) {
|
if (failCount == wrapper.getSubTaskWrapper().size()) {
|
||||||
callback.onFail(wrapper.getEntity(), new AriaIOException(TAG, "获取子任务长度失败"), false);
|
callback.onFail(wrapper.getEntity(), new AriaHTTPException(TAG, "获取子任务长度失败"), false);
|
||||||
notifyLock();
|
notifyLock();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -25,7 +25,7 @@ import com.arialyy.aria.core.group.AbsSubDLoadUtil;
|
|||||||
import com.arialyy.aria.core.listener.DownloadGroupListener;
|
import com.arialyy.aria.core.listener.DownloadGroupListener;
|
||||||
import com.arialyy.aria.core.loader.IInfoTask;
|
import com.arialyy.aria.core.loader.IInfoTask;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* http 组合任务加载器
|
* http 组合任务加载器
|
||||||
@@ -65,7 +65,7 @@ final class HttpDGLoader extends AbsGroupLoader {
|
|||||||
startSub();
|
startSub();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
fail(e, needRetry);
|
fail(e, needRetry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+8
-9
@@ -18,8 +18,7 @@ package com.arialyy.aria.http.download;
|
|||||||
import com.arialyy.aria.core.common.RequestEnum;
|
import com.arialyy.aria.core.common.RequestEnum;
|
||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaHTTPException;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
|
import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
|
||||||
import com.arialyy.aria.http.ConnectionHelp;
|
import com.arialyy.aria.http.ConnectionHelp;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
@@ -118,19 +117,19 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
handleComplete();
|
handleComplete();
|
||||||
}
|
}
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||||
getEntity().getFilePath(), getEntity().getUrl()), e), true);
|
getEntity().getFilePath(), getEntity().getUrl()), e), true);
|
||||||
} catch (ArrayIndexOutOfBoundsException e) {
|
} catch (ArrayIndexOutOfBoundsException e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||||
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -172,9 +171,9 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
handleComplete();
|
handleComplete();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
|
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
|
||||||
getThreadConfig().url)), true);
|
getThreadConfig().url), e), true);
|
||||||
} finally {
|
} finally {
|
||||||
if (fos != null) {
|
if (fos != null) {
|
||||||
try {
|
try {
|
||||||
@@ -225,7 +224,7 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
handleComplete();
|
handleComplete();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
|
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
|
||||||
getThreadConfig().url), e), true);
|
getThreadConfig().url), e), true);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -26,7 +26,7 @@ import com.arialyy.aria.core.loader.IThreadTaskBuilder;
|
|||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.core.task.IThreadTask;
|
import com.arialyy.aria.core.task.IThreadTask;
|
||||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaHTTPException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
@@ -62,7 +62,7 @@ final class HttpULoader extends AbsNormalLoader<UTaskWrapper> {
|
|||||||
new Handler(looper, mStateManager.getHandlerCallback()));
|
new Handler(looper, mStateManager.getHandlerCallback()));
|
||||||
if (tt == null || tt.isEmpty()) {
|
if (tt == null || tt.isEmpty()) {
|
||||||
ALog.e(TAG, "创建线程任务失败");
|
ALog.e(TAG, "创建线程任务失败");
|
||||||
getListener().onFail(false, new AriaIOException(TAG, "创建线程任务失败"));
|
getListener().onFail(false, new AriaHTTPException(TAG, "创建线程任务失败"));
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+5
-7
@@ -18,9 +18,7 @@ package com.arialyy.aria.http.upload;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaHTTPException;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
|
import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
@@ -56,7 +54,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
@Override protected void handlerThreadTask() {
|
@Override protected void handlerThreadTask() {
|
||||||
File uploadFile = new File(getEntity().getFilePath());
|
File uploadFile = new File(getEntity().getFilePath());
|
||||||
if (!uploadFile.exists()) {
|
if (!uploadFile.exists()) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("上传失败,文件不存在;filePath: %s, url: %s", getEntity().getFilePath(),
|
String.format("上传失败,文件不存在;filePath: %s, url: %s", getEntity().getFilePath(),
|
||||||
getEntity().getUrl())));
|
getEntity().getUrl())));
|
||||||
return;
|
return;
|
||||||
@@ -106,13 +104,13 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
getEntity().setResponseStr(finish(writer));
|
getEntity().setResponseStr(finish(writer));
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaHTTPException(TAG,
|
||||||
String.format("上传失败,filePath: %s, url: %s", getEntity().getFilePath(),
|
String.format("上传失败,filePath: %s, url: %s", getEntity().getFilePath(),
|
||||||
getEntity().getUrl()), e));
|
getEntity().getUrl()), e));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fail(BaseException e1) {
|
private void fail(AriaHTTPException e1) {
|
||||||
try {
|
try {
|
||||||
fail(e1, false);
|
fail(e1, false);
|
||||||
if (mOutputStream != null) {
|
if (mOutputStream != null) {
|
||||||
@@ -222,7 +220,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
} else {
|
} else {
|
||||||
String msg = "response msg: " + mHttpConn.getResponseMessage() + ",code: " + status;
|
String msg = "response msg: " + mHttpConn.getResponseMessage() + ",code: " + status;
|
||||||
ALog.e(TAG, msg);
|
ALog.e(TAG, msg);
|
||||||
fail(new AriaIOException(TAG, msg), false);
|
fail(new AriaHTTPException(TAG, msg), false);
|
||||||
}
|
}
|
||||||
writer.flush();
|
writer.flush();
|
||||||
writer.close();
|
writer.close();
|
||||||
|
|||||||
@@ -30,8 +30,7 @@ import com.arialyy.aria.core.processor.IBandWidthUrlConverter;
|
|||||||
import com.arialyy.aria.core.processor.IKeyUrlConverter;
|
import com.arialyy.aria.core.processor.IKeyUrlConverter;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||||
import com.arialyy.aria.exception.M3U8Exception;
|
import com.arialyy.aria.exception.AriaM3U8Exception;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.http.ConnectionHelp;
|
import com.arialyy.aria.http.ConnectionHelp;
|
||||||
import com.arialyy.aria.http.HttpTaskOption;
|
import com.arialyy.aria.http.HttpTaskOption;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
@@ -296,7 +295,7 @@ final public class M3U8InfoTask implements IInfoTask {
|
|||||||
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
||||||
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
||||||
if (mCallback != null) {
|
if (mCallback != null) {
|
||||||
mCallback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false);
|
mCallback.onFail(mEntity, new AriaM3U8Exception(TAG, "获取重定向链接失败"), false);
|
||||||
}
|
}
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@@ -354,7 +353,7 @@ final public class M3U8InfoTask implements IInfoTask {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void failDownload(String errorInfo, boolean needRetry) {
|
private void failDownload(String errorInfo, boolean needRetry) {
|
||||||
mCallback.onFail(mEntity, new M3U8Exception(TAG, errorInfo), needRetry);
|
mCallback.onFail(mEntity, new AriaM3U8Exception(TAG, errorInfo), needRetry);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -21,8 +21,7 @@ import com.arialyy.aria.core.common.RequestEnum;
|
|||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
||||||
import com.arialyy.aria.exception.AriaIOException;
|
import com.arialyy.aria.exception.AriaM3U8Exception;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.http.ConnectionHelp;
|
import com.arialyy.aria.http.ConnectionHelp;
|
||||||
import com.arialyy.aria.http.HttpTaskOption;
|
import com.arialyy.aria.http.HttpTaskOption;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
@@ -92,15 +91,15 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
|
|
||||||
handleConn(conn);
|
handleConn(conn);
|
||||||
} catch (MalformedURLException e) {
|
} catch (MalformedURLException e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaM3U8Exception(TAG,
|
||||||
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
||||||
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
|
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaM3U8Exception(TAG,
|
||||||
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
||||||
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), true);
|
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), true);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaM3U8Exception(TAG,
|
||||||
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
|
||||||
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
|
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -138,7 +137,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
|| code == 307) {
|
|| code == 307) {
|
||||||
handleUrlReTurn(conn, conn.getHeaderField("Location"));
|
handleUrlReTurn(conn, conn.getHeaderField("Location"));
|
||||||
} else {
|
} else {
|
||||||
fail(new TaskException(TAG,
|
fail(new AriaM3U8Exception(TAG,
|
||||||
String.format("连接错误,http错误码:%s,url:%s", code, getThreadConfig().url)),
|
String.format("连接错误,http错误码:%s,url:%s", code, getThreadConfig().url)),
|
||||||
false);
|
false);
|
||||||
}
|
}
|
||||||
@@ -151,7 +150,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
private void handleUrlReTurn(HttpURLConnection conn, String newUrl) throws IOException {
|
private void handleUrlReTurn(HttpURLConnection conn, String newUrl) throws IOException {
|
||||||
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
|
||||||
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
|
||||||
fail(new AriaIOException(TAG, "下载失败,重定向url为空"), false);
|
fail(new AriaM3U8Exception(TAG, "下载失败,重定向url为空"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -161,14 +160,14 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (!CheckUtil.checkUrl(newUrl)) {
|
if (!CheckUtil.checkUrl(newUrl)) {
|
||||||
fail(new AriaIOException(TAG, "下载失败,重定向url错误"), false);
|
fail(new AriaM3U8Exception(TAG, "下载失败,重定向url错误"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
String cookies = conn.getHeaderField("Set-Cookie");
|
String cookies = conn.getHeaderField("Set-Cookie");
|
||||||
conn.disconnect(); // 关闭上一个连接
|
conn.disconnect(); // 关闭上一个连接
|
||||||
URL url = ConnectionHelp.handleUrl(newUrl, mHttpTaskOption);
|
URL url = ConnectionHelp.handleUrl(newUrl, mHttpTaskOption);
|
||||||
conn = ConnectionHelp.handleConnection(url, mHttpTaskOption);
|
conn = ConnectionHelp.handleConnection(url, mHttpTaskOption);
|
||||||
if (!TextUtils.isEmpty(cookies)){
|
if (!TextUtils.isEmpty(cookies)) {
|
||||||
conn.setRequestProperty("Cookie", cookies);
|
conn.setRequestProperty("Cookie", cookies);
|
||||||
}
|
}
|
||||||
if (mHttpTaskOption.isChunked()) {
|
if (mHttpTaskOption.isChunked()) {
|
||||||
@@ -199,7 +198,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
handleComplete();
|
handleComplete();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaM3U8Exception(TAG,
|
||||||
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
|
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
|
||||||
getThreadConfig().url), e), true);
|
getThreadConfig().url), e), true);
|
||||||
} finally {
|
} finally {
|
||||||
@@ -242,7 +241,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
handleComplete();
|
handleComplete();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
fail(new AriaIOException(TAG,
|
fail(new AriaM3U8Exception(TAG,
|
||||||
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
|
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
|
||||||
getThreadConfig().url), e), true);
|
getThreadConfig().url), e), true);
|
||||||
} finally {
|
} finally {
|
||||||
|
|||||||
@@ -32,9 +32,8 @@ import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
|
|||||||
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
||||||
import com.arialyy.aria.core.task.ThreadTask;
|
import com.arialyy.aria.core.task.ThreadTask;
|
||||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaM3U8Exception;
|
||||||
import com.arialyy.aria.exception.M3U8Exception;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
|
||||||
import com.arialyy.aria.m3u8.BaseM3U8Loader;
|
import com.arialyy.aria.m3u8.BaseM3U8Loader;
|
||||||
import com.arialyy.aria.m3u8.IdGenerator;
|
import com.arialyy.aria.m3u8.IdGenerator;
|
||||||
import com.arialyy.aria.m3u8.M3U8InfoTask;
|
import com.arialyy.aria.m3u8.M3U8InfoTask;
|
||||||
@@ -255,7 +254,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
|
|||||||
ALog.d(TAG, "更新直播的m3u8文件");
|
ALog.d(TAG, "更新直播的m3u8文件");
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -275,7 +274,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (TextUtils.isEmpty(url) || !url.startsWith("http")) {
|
if (TextUtils.isEmpty(url) || !url.startsWith("http")) {
|
||||||
fail(new M3U8Exception(TAG, String.format("ts地址错误,url:%s", url)), false);
|
fail(new AriaM3U8Exception(TAG, String.format("ts地址错误,url:%s", url)), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
offerPeer(new M3U8LiveLoader.ExtInfo(url, extInf));
|
offerPeer(new M3U8LiveLoader.ExtInfo(url, extInf));
|
||||||
@@ -283,7 +282,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void fail(BaseException e, boolean needRetry) {
|
private void fail(AriaM3U8Exception e, boolean needRetry) {
|
||||||
getListener().onFail(needRetry, e);
|
getListener().onFail(needRetry, e);
|
||||||
handleComplete();
|
handleComplete();
|
||||||
}
|
}
|
||||||
@@ -296,13 +295,13 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
|
|||||||
if (generateIndexFile(true)) {
|
if (generateIndexFile(true)) {
|
||||||
getListener().onComplete();
|
getListener().onComplete();
|
||||||
} else {
|
} else {
|
||||||
getListener().onFail(false, new TaskException(TAG, "创建索引文件失败"));
|
getListener().onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败"));
|
||||||
}
|
}
|
||||||
} else if (mM3U8Option.isMergeFile()) {
|
} else if (mM3U8Option.isMergeFile()) {
|
||||||
if (mergeFile()) {
|
if (mergeFile()) {
|
||||||
getListener().onComplete();
|
getListener().onComplete();
|
||||||
} else {
|
} else {
|
||||||
getListener().onFail(false, new M3U8Exception(TAG, "合并文件失败"));
|
getListener().onFail(false, new AriaM3U8Exception(TAG, "合并文件失败"));
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
getListener().onComplete();
|
getListener().onComplete();
|
||||||
|
|||||||
@@ -35,8 +35,8 @@ import com.arialyy.aria.core.manager.ThreadTaskManager;
|
|||||||
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
|
import com.arialyy.aria.core.processor.IVodTsUrlConverter;
|
||||||
import com.arialyy.aria.core.task.ThreadTask;
|
import com.arialyy.aria.core.task.ThreadTask;
|
||||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.exception.M3U8Exception;
|
import com.arialyy.aria.exception.AriaM3U8Exception;
|
||||||
import com.arialyy.aria.m3u8.BaseM3U8Loader;
|
import com.arialyy.aria.m3u8.BaseM3U8Loader;
|
||||||
import com.arialyy.aria.m3u8.M3U8Listener;
|
import com.arialyy.aria.m3u8.M3U8Listener;
|
||||||
import com.arialyy.aria.m3u8.M3U8TaskOption;
|
import com.arialyy.aria.m3u8.M3U8TaskOption;
|
||||||
@@ -517,10 +517,10 @@ final class M3U8VodLoader extends BaseM3U8Loader {
|
|||||||
urls.addAll((Collection<? extends String>) info.obj);
|
urls.addAll((Collection<? extends String>) info.obj);
|
||||||
}
|
}
|
||||||
if (urls.isEmpty()) {
|
if (urls.isEmpty()) {
|
||||||
fail(new M3U8Exception(TAG, "获取地址失败"), false);
|
fail(new AriaM3U8Exception(TAG, "获取地址失败"), false);
|
||||||
return;
|
return;
|
||||||
} else if (!urls.get(0).startsWith("http")) {
|
} else if (!urls.get(0).startsWith("http")) {
|
||||||
fail(new M3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false);
|
fail(new AriaM3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mM3U8Option.setUrls(urls);
|
mM3U8Option.setUrls(urls);
|
||||||
@@ -534,13 +534,13 @@ final class M3U8VodLoader extends BaseM3U8Loader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
fail(e, needRetry);
|
fail(e, needRetry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fail(BaseException e, boolean needRetry) {
|
protected void fail(AriaException e, boolean needRetry) {
|
||||||
if (isBreak()) {
|
if (isBreak()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -29,8 +29,8 @@ import com.arialyy.aria.core.loader.ILoaderVisitor;
|
|||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
import com.arialyy.aria.core.processor.ITsMergeHandler;
|
||||||
import com.arialyy.aria.core.task.ThreadTask;
|
import com.arialyy.aria.core.task.ThreadTask;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaM3U8Exception;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.m3u8.BaseM3U8Loader;
|
import com.arialyy.aria.m3u8.BaseM3U8Loader;
|
||||||
import com.arialyy.aria.m3u8.M3U8Listener;
|
import com.arialyy.aria.m3u8.M3U8Listener;
|
||||||
import com.arialyy.aria.m3u8.M3U8TaskOption;
|
import com.arialyy.aria.m3u8.M3U8TaskOption;
|
||||||
@@ -113,7 +113,7 @@ public final class VodStateManager implements IThreadStateManager {
|
|||||||
ALog.d(TAG, String.format("vod任务【%s】失败", loader.getTempFile().getName()));
|
ALog.d(TAG, String.format("vod任务【%s】失败", loader.getTempFile().getName()));
|
||||||
Bundle b = msg.getData();
|
Bundle b = msg.getData();
|
||||||
listener.onFail(b.getBoolean(DATA_RETRY, true),
|
listener.onFail(b.getBoolean(DATA_RETRY, true),
|
||||||
(BaseException) b.getSerializable(DATA_ERROR_INFO));
|
(AriaException) b.getSerializable(DATA_ERROR_INFO));
|
||||||
quitLooper();
|
quitLooper();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
@@ -148,7 +148,7 @@ public final class VodStateManager implements IThreadStateManager {
|
|||||||
if (loader.generateIndexFile(false)) {
|
if (loader.generateIndexFile(false)) {
|
||||||
listener.onComplete();
|
listener.onComplete();
|
||||||
} else {
|
} else {
|
||||||
listener.onFail(false, new TaskException(TAG, "创建索引文件失败"));
|
listener.onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败"));
|
||||||
}
|
}
|
||||||
} else if (m3U8Option.isMergeFile()) {
|
} else if (m3U8Option.isMergeFile()) {
|
||||||
if (mergeFile()) {
|
if (mergeFile()) {
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import com.arialyy.aria.core.loader.ILoaderVisitor;
|
|||||||
import com.arialyy.aria.core.loader.IRecordHandler;
|
import com.arialyy.aria.core.loader.IRecordHandler;
|
||||||
import com.arialyy.aria.core.loader.IThreadTaskBuilder;
|
import com.arialyy.aria.core.loader.IThreadTaskBuilder;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -321,7 +321,7 @@ public abstract class AbsGroupLoader implements ILoaderVisitor, ILoader {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fail(BaseException e, boolean needRetry){
|
protected void fail(AriaException e, boolean needRetry){
|
||||||
closeTimer();
|
closeTimer();
|
||||||
getListener().onFail(needRetry, e);
|
getListener().onFail(needRetry, e);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -24,7 +24,7 @@ import com.arialyy.aria.core.config.Configuration;
|
|||||||
import com.arialyy.aria.core.inf.IThreadStateManager;
|
import com.arialyy.aria.core.inf.IThreadStateManager;
|
||||||
import com.arialyy.aria.core.loader.IRecordHandler;
|
import com.arialyy.aria.core.loader.IRecordHandler;
|
||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.aria.util.NetUtils;
|
import com.arialyy.aria.util.NetUtils;
|
||||||
@@ -113,7 +113,7 @@ final class SimpleSchedulers implements Handler.Callback {
|
|||||||
|| loaderUtil.getLoader() == null // 如果获取不到文件信息,loader为空
|
|| loaderUtil.getLoader() == null // 如果获取不到文件信息,loader为空
|
||||||
|| loaderUtil.getEntity().getFailNum() > num) {
|
|| loaderUtil.getEntity().getFailNum() > num) {
|
||||||
mQueue.removeTaskFromExecQ(loaderUtil);
|
mQueue.removeTaskFromExecQ(loaderUtil);
|
||||||
mGState.listener.onSubFail(loaderUtil.getEntity(), new TaskException(TAG,
|
mGState.listener.onSubFail(loaderUtil.getEntity(), new AriaException(TAG,
|
||||||
String.format("任务组子任务【%s】下载失败,下载地址【%s】", loaderUtil.getEntity().getFileName(),
|
String.format("任务组子任务【%s】下载失败,下载地址【%s】", loaderUtil.getEntity().getFileName(),
|
||||||
loaderUtil.getEntity().getUrl())));
|
loaderUtil.getEntity().getUrl())));
|
||||||
mGState.countFailNum(loaderUtil.getKey());
|
mGState.countFailNum(loaderUtil.getKey());
|
||||||
@@ -122,7 +122,7 @@ final class SimpleSchedulers implements Handler.Callback {
|
|||||||
== mGState.getSubSize()) {
|
== mGState.getSubSize()) {
|
||||||
mQueue.clear();
|
mQueue.clear();
|
||||||
mGState.isRunning = false;
|
mGState.isRunning = false;
|
||||||
mGState.listener.onFail(false, new TaskException(TAG,
|
mGState.listener.onFail(false, new AriaException(TAG,
|
||||||
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
|
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
|
||||||
} else {
|
} else {
|
||||||
startNext();
|
startNext();
|
||||||
|
|||||||
@@ -16,13 +16,14 @@
|
|||||||
package com.arialyy.aria.core.listener;
|
package com.arialyy.aria.core.listener;
|
||||||
|
|
||||||
import android.os.Handler;
|
import android.os.Handler;
|
||||||
|
import android.util.Log;
|
||||||
import com.arialyy.aria.core.common.AbsEntity;
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
import com.arialyy.aria.core.inf.IEntity;
|
||||||
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
||||||
import com.arialyy.aria.core.task.AbsTask;
|
import com.arialyy.aria.core.task.AbsTask;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.aria.util.ErrorHelp;
|
import com.arialyy.aria.util.ErrorHelp;
|
||||||
@@ -114,7 +115,7 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(boolean needRetry, BaseException e) {
|
@Override public void onFail(boolean needRetry, AriaException e) {
|
||||||
mEntity.setFailNum(mEntity.getFailNum() + 1);
|
mEntity.setFailNum(mEntity.getFailNum() + 1);
|
||||||
saveData(IEntity.STATE_FAIL, mEntity.getCurrentProgress());
|
saveData(IEntity.STATE_FAIL, mEntity.getCurrentProgress());
|
||||||
handleSpeed(0);
|
handleSpeed(0);
|
||||||
@@ -123,8 +124,8 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
|
|||||||
sendInState2Target(ISchedulers.FAIL);
|
sendInState2Target(ISchedulers.FAIL);
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
String error = ALog.getExceptionString(e);
|
String error = ALog.getExceptionString(e);
|
||||||
ALog.w(TAG, error);
|
ALog.e(TAG, error);
|
||||||
ErrorHelp.saveError(e.getTag(), "", error);
|
ErrorHelp.saveError(e.getTag(), e.getMessage(), error);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
+2
-2
@@ -24,7 +24,7 @@ import com.arialyy.aria.core.inf.IEntity;
|
|||||||
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
import com.arialyy.aria.core.inf.TaskSchedulerType;
|
||||||
import com.arialyy.aria.core.task.AbsTask;
|
import com.arialyy.aria.core.task.AbsTask;
|
||||||
import com.arialyy.aria.core.task.DownloadGroupTask;
|
import com.arialyy.aria.core.task.DownloadGroupTask;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.arialyy.aria.util.ErrorHelp;
|
import com.arialyy.aria.util.ErrorHelp;
|
||||||
@@ -81,7 +81,7 @@ public class DownloadGroupListener
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onSubFail(DownloadEntity subEntity, BaseException e) {
|
public void onSubFail(DownloadEntity subEntity, AriaException e) {
|
||||||
handleSubSpeed(subEntity, 0);
|
handleSubSpeed(subEntity, 0);
|
||||||
saveSubState(IEntity.STATE_FAIL, subEntity);
|
saveSubState(IEntity.STATE_FAIL, subEntity);
|
||||||
saveCurrentLocation();
|
saveCurrentLocation();
|
||||||
|
|||||||
@@ -16,7 +16,7 @@
|
|||||||
package com.arialyy.aria.core.listener;
|
package com.arialyy.aria.core.listener;
|
||||||
|
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Aria.Lao on 2017/7/20.
|
* Created by Aria.Lao on 2017/7/20.
|
||||||
@@ -54,7 +54,7 @@ public interface IDGroupListener extends IDLoadListener {
|
|||||||
/**
|
/**
|
||||||
* 子任务下载失败
|
* 子任务下载失败
|
||||||
*/
|
*/
|
||||||
void onSubFail(DownloadEntity subEntity, BaseException e);
|
void onSubFail(DownloadEntity subEntity, AriaException e);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 子任务取消下载
|
* 子任务取消下载
|
||||||
|
|||||||
@@ -15,7 +15,7 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.core.listener;
|
package com.arialyy.aria.core.listener;
|
||||||
|
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by Aria.Lao on 2017/7/18.
|
* Created by Aria.Lao on 2017/7/18.
|
||||||
@@ -64,5 +64,5 @@ public interface IEventListener {
|
|||||||
* @param needRetry 是否需要重试{@code true} 需要
|
* @param needRetry 是否需要重试{@code true} 需要
|
||||||
* @param e 失败信息
|
* @param e 失败信息
|
||||||
*/
|
*/
|
||||||
void onFail(boolean needRetry, BaseException e);
|
void onFail(boolean needRetry, AriaException e);
|
||||||
}
|
}
|
||||||
@@ -19,7 +19,7 @@ package com.arialyy.aria.core.loader;
|
|||||||
import com.arialyy.aria.core.inf.IUtil;
|
import com.arialyy.aria.core.inf.IUtil;
|
||||||
import com.arialyy.aria.core.listener.IEventListener;
|
import com.arialyy.aria.core.listener.IEventListener;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
|
|
||||||
@@ -135,7 +135,7 @@ public abstract class AbsNormalLoaderUtil implements IUtil {
|
|||||||
return mListener;
|
return mListener;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fail(BaseException e, boolean needRetry) {
|
protected void fail(AriaException e, boolean needRetry) {
|
||||||
if (isStop || isCancel) {
|
if (isStop || isCancel) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package com.arialyy.aria.core.loader;
|
|||||||
|
|
||||||
import com.arialyy.aria.core.common.AbsEntity;
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.CompleteInfo;
|
import com.arialyy.aria.core.common.CompleteInfo;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务信息采集
|
* 任务信息采集
|
||||||
@@ -47,6 +47,6 @@ public interface IInfoTask extends ILoaderComponent {
|
|||||||
*
|
*
|
||||||
* @param e 错误信息
|
* @param e 错误信息
|
||||||
*/
|
*/
|
||||||
void onFail(AbsEntity entity, BaseException e, boolean needRetry);
|
void onFail(AbsEntity entity, AriaException e, boolean needRetry);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -27,7 +27,7 @@ import com.arialyy.aria.core.listener.IEventListener;
|
|||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.core.task.IThreadTask;
|
import com.arialyy.aria.core.task.IThreadTask;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.FileUtil;
|
import com.arialyy.aria.util.FileUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -150,7 +150,7 @@ public class NormalLoader<T extends AbsTaskWrapper> extends AbsNormalLoader<T> {
|
|||||||
startThreadTask();
|
startThreadTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
getListener().onFail(needRetry, e);
|
getListener().onFail(needRetry, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+2
-2
@@ -22,7 +22,7 @@ import android.os.Message;
|
|||||||
import com.arialyy.aria.core.TaskRecord;
|
import com.arialyy.aria.core.TaskRecord;
|
||||||
import com.arialyy.aria.core.inf.IThreadStateManager;
|
import com.arialyy.aria.core.inf.IThreadStateManager;
|
||||||
import com.arialyy.aria.core.listener.IEventListener;
|
import com.arialyy.aria.core.listener.IEventListener;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.FileUtil;
|
import com.arialyy.aria.util.FileUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -91,7 +91,7 @@ public class NormalThreadStateManager implements IThreadStateManager {
|
|||||||
if (isFail()) {
|
if (isFail()) {
|
||||||
Bundle b = msg.getData();
|
Bundle b = msg.getData();
|
||||||
mListener.onFail(b.getBoolean(DATA_RETRY, false),
|
mListener.onFail(b.getBoolean(DATA_RETRY, false),
|
||||||
(BaseException) b.getSerializable(DATA_ERROR_INFO));
|
(AriaException) b.getSerializable(DATA_ERROR_INFO));
|
||||||
quitLooper();
|
quitLooper();
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -27,7 +27,7 @@ import com.arialyy.aria.core.manager.ThreadTaskManager;
|
|||||||
import com.arialyy.aria.core.task.IThreadTask;
|
import com.arialyy.aria.core.task.IThreadTask;
|
||||||
import com.arialyy.aria.core.task.ThreadTask;
|
import com.arialyy.aria.core.task.ThreadTask;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -207,7 +207,7 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
|
|||||||
handlerTask();
|
handlerTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
sendFailState(needRetry);
|
sendFailState(needRetry);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -255,7 +255,7 @@ public class ThreadTaskManager {
|
|||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
ALog.e(TAG, e);
|
ALog.e(TAG, "", e);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
mExePool.submit(task);
|
mExePool.submit(task);
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ import com.arialyy.aria.core.ThreadRecord;
|
|||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.config.BaseTaskConfig;
|
import com.arialyy.aria.core.config.BaseTaskConfig;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.BandwidthLimiter;
|
import com.arialyy.aria.util.BandwidthLimiter;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
|
|
||||||
@@ -110,7 +110,7 @@ public abstract class AbsThreadTaskAdapter implements IThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fail(BaseException ex, boolean needRetry) {
|
protected void fail(AriaException ex, boolean needRetry) {
|
||||||
if (mObserver != null) {
|
if (mObserver != null) {
|
||||||
mObserver.updateFailState(ex, needRetry);
|
mObserver.updateFailState(ex, needRetry);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package com.arialyy.aria.core.task;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import com.arialyy.aria.core.inf.IThreadStateManager;
|
import com.arialyy.aria.core.inf.IThreadStateManager;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 线程任务观察者
|
* 线程任务观察者
|
||||||
@@ -44,7 +44,7 @@ public interface IThreadTaskObserver {
|
|||||||
*
|
*
|
||||||
* @param needRetry 是否需要重试,一般是网络错误才需要重试
|
* @param needRetry 是否需要重试,一般是网络错误才需要重试
|
||||||
*/
|
*/
|
||||||
void updateFailState(BaseException e, boolean needRetry);
|
void updateFailState(AriaException e, boolean needRetry);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 更新进度
|
* 更新进度
|
||||||
|
|||||||
@@ -29,7 +29,7 @@ import com.arialyy.aria.core.listener.ISchedulers;
|
|||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
@@ -323,7 +323,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
|||||||
*
|
*
|
||||||
* @param needRetry 是否需要重试,一般是网络错误才需要重试
|
* @param needRetry 是否需要重试,一般是网络错误才需要重试
|
||||||
*/
|
*/
|
||||||
@Override public synchronized void updateFailState(BaseException e, boolean needRetry) {
|
@Override public synchronized void updateFailState(AriaException e, boolean needRetry) {
|
||||||
fail(mRangeProgress, e, needRetry);
|
fail(mRangeProgress, e, needRetry);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -396,7 +396,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
|||||||
*
|
*
|
||||||
* @param subCurrentLocation 当前子线程进度
|
* @param subCurrentLocation 当前子线程进度
|
||||||
*/
|
*/
|
||||||
protected void fail(final long subCurrentLocation, BaseException ex, boolean needRetry) {
|
protected void fail(final long subCurrentLocation, AriaException ex, boolean needRetry) {
|
||||||
if (ex != null) {
|
if (ex != null) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
@@ -505,7 +505,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
|||||||
/**
|
/**
|
||||||
* 发送失败信息
|
* 发送失败信息
|
||||||
*/
|
*/
|
||||||
private void sendFailMsg(BaseException e, boolean needRetry) {
|
private void sendFailMsg(AriaException e, boolean needRetry) {
|
||||||
Bundle b = new Bundle();
|
Bundle b = new Bundle();
|
||||||
b.putBoolean(IThreadStateManager.DATA_RETRY, needRetry);
|
b.putBoolean(IThreadStateManager.DATA_RETRY, needRetry);
|
||||||
if (e != null) {
|
if (e != null) {
|
||||||
|
|||||||
@@ -15,14 +15,22 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.exception;
|
package com.arialyy.aria.exception;
|
||||||
|
|
||||||
public class AriaException extends BaseException {
|
public class AriaException extends Exception {
|
||||||
private static final String ARIA_NET_EXCEPTION = "Aria Exception:";
|
|
||||||
|
private String tag;
|
||||||
|
|
||||||
public AriaException(String tag, String message) {
|
public AriaException(String tag, String message) {
|
||||||
super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message));
|
super(message);
|
||||||
|
this.tag = tag;
|
||||||
}
|
}
|
||||||
|
|
||||||
public AriaException(String tag, String message, Exception e) {
|
public AriaException(String tag, String message, Exception e) {
|
||||||
super(tag, message, e);
|
super(String.format("%s, %s\n%s", tag, message == null ? "" : message,
|
||||||
|
e == null ? "" : e.getMessage()));
|
||||||
|
this.tag = tag;
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getTag() {
|
||||||
|
return tag;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-5
@@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.exception;
|
package com.arialyy.aria.exception;
|
||||||
|
|
||||||
public class M3U8Exception extends BaseException{
|
public class AriaFTPException extends AriaException {
|
||||||
private static final String M3U8_EXCEPTION = "M3U8 Exception:";
|
private static final String FTP_EXCEPTION = "Aria SFTP Exception:";
|
||||||
|
|
||||||
public M3U8Exception(String tag, String message) {
|
public AriaFTPException(String tag, String message) {
|
||||||
super(tag, String.format("%s%s", M3U8_EXCEPTION, message));
|
super(tag, String.format("%s\n%s", FTP_EXCEPTION, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public M3U8Exception(String tag, String message, Exception e){
|
public AriaFTPException(String tag, String message, Exception e) {
|
||||||
super(tag, message, e);
|
super(tag, message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-5
@@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.exception;
|
package com.arialyy.aria.exception;
|
||||||
|
|
||||||
public class AriaLoginException extends BaseException{
|
public class AriaHTTPException extends AriaException {
|
||||||
private static final String ARIA_NET_EXCEPTION = "Aria Login Exception:";
|
private static final String HTTP_EXCEPTION = "Aria HTTP Exception:";
|
||||||
|
|
||||||
public AriaLoginException(String tag, String message) {
|
public AriaHTTPException(String tag, String message) {
|
||||||
super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message));
|
super(tag, String.format("%s\n%s", HTTP_EXCEPTION, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AriaLoginException(String tag, String message, Exception e){
|
public AriaHTTPException(String tag, String message, Exception e) {
|
||||||
super(tag, message, e);
|
super(tag, message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-5
@@ -15,14 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.exception;
|
package com.arialyy.aria.exception;
|
||||||
|
|
||||||
public class AriaIOException extends BaseException{
|
public class AriaM3U8Exception extends AriaException {
|
||||||
private static final String ARIA_NET_EXCEPTION = "Aria Net Exception:";
|
private static final String M3U8_EXCEPTION = "Aria M3U8 Exception:";
|
||||||
|
|
||||||
public AriaIOException(String tag, String message) {
|
public AriaM3U8Exception(String tag, String message) {
|
||||||
super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message));
|
super(tag, String.format("%s\n%s", M3U8_EXCEPTION, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public AriaIOException(String tag, String message, Exception e){
|
public AriaM3U8Exception(String tag, String message, Exception e){
|
||||||
super(tag, message, e);
|
super(tag, message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
+5
-8
@@ -15,17 +15,14 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.exception;
|
package com.arialyy.aria.exception;
|
||||||
|
|
||||||
/**
|
public class AriaSFTPException extends AriaException {
|
||||||
* 任务异常
|
private static final String SFTP_EXCEPTION = "Aria SFTP Exception:";
|
||||||
*/
|
|
||||||
public class TaskException extends BaseException {
|
|
||||||
private static final String ARIA_TASK_EXCEPTION = "Aria Task Exception:";
|
|
||||||
|
|
||||||
public TaskException(String tag, String detailMessage) {
|
public AriaSFTPException(String tag, String message) {
|
||||||
super(tag, String.format("%s, %s", ARIA_TASK_EXCEPTION, detailMessage));
|
super(tag, String.format("%s\n%s", SFTP_EXCEPTION, message));
|
||||||
}
|
}
|
||||||
|
|
||||||
public TaskException(String tag, String message, Exception e){
|
public AriaSFTPException(String tag, String message, Exception e) {
|
||||||
super(tag, message, e);
|
super(tag, message, e);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
|
||||||
*
|
|
||||||
* Licensed 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.exception;
|
|
||||||
|
|
||||||
public abstract class BaseException extends Exception {
|
|
||||||
|
|
||||||
private String tag;
|
|
||||||
|
|
||||||
public BaseException(String tag, String message) {
|
|
||||||
super(message);
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public BaseException(String tag, String message, Exception e) {
|
|
||||||
super(String.format("%s\n%s", message == null ? "" : message, e == null ? "" : e.getMessage()));
|
|
||||||
this.tag = tag;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getTag() {
|
|
||||||
return tag;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
|
||||||
*
|
|
||||||
* Licensed 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.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by lyy on 2017/1/18.
|
|
||||||
* Aria 文件异常
|
|
||||||
*/
|
|
||||||
public class FileException extends BaseException {
|
|
||||||
private static final String ARIA_FILE_EXCEPTION = "Aria File Exception:";
|
|
||||||
|
|
||||||
public FileException(String tag, String detailMessage) {
|
|
||||||
super(tag, String.format("%s%s", ARIA_FILE_EXCEPTION, detailMessage));
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileException(String tag, String message, Exception e){
|
|
||||||
super(tag, message, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,32 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
|
||||||
*
|
|
||||||
* Licensed 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.exception;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by lyy on 2017/1/18.
|
|
||||||
* Aria 文件异常
|
|
||||||
*/
|
|
||||||
public class FileNotFoundException extends BaseException {
|
|
||||||
private static final String ARIA_FILE_EXCEPTION = "Aria File not found Exception:";
|
|
||||||
|
|
||||||
public FileNotFoundException(String tag, String detailMessage) {
|
|
||||||
super(tag, String.format("%s%s", ARIA_FILE_EXCEPTION, detailMessage));
|
|
||||||
}
|
|
||||||
|
|
||||||
public FileNotFoundException(String tag, String message, Exception e) {
|
|
||||||
super(tag, message, e);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -1,24 +0,0 @@
|
|||||||
/*
|
|
||||||
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
|
||||||
*
|
|
||||||
* Licensed 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.exception;
|
|
||||||
|
|
||||||
public class ParamException extends RuntimeException {
|
|
||||||
private static final String ARIA_NET_EXCEPTION = "Aria Params Exception:";
|
|
||||||
|
|
||||||
public ParamException(String message) {
|
|
||||||
super(String.format("%s%s", ARIA_NET_EXCEPTION, message));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
@@ -63,10 +63,8 @@ public class ALog {
|
|||||||
return println(Log.ERROR, tag, msg);
|
return println(Log.ERROR, tag, msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static int e(String tag, Throwable e) {
|
public static void e(String tag, String msg, Throwable e) {
|
||||||
String msg = getExceptionString(e);
|
Log.e(tag, msg, e);
|
||||||
ErrorHelp.saveError(tag, "", msg);
|
|
||||||
return println(Log.ERROR, tag, msg);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -534,7 +534,7 @@ public class CommonUtil {
|
|||||||
try {
|
try {
|
||||||
is = new FileInputStream(updateFile);
|
is = new FileInputStream(updateFile);
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
ALog.e(TAG, e);
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -549,7 +549,7 @@ public class CommonUtil {
|
|||||||
try {
|
try {
|
||||||
digest = MessageDigest.getInstance("MD5");
|
digest = MessageDigest.getInstance("MD5");
|
||||||
} catch (NoSuchAlgorithmException e) {
|
} catch (NoSuchAlgorithmException e) {
|
||||||
ALog.e(TAG, e);
|
e.printStackTrace();
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -571,7 +571,7 @@ public class CommonUtil {
|
|||||||
try {
|
try {
|
||||||
is.close();
|
is.close();
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
ALog.e(TAG, e);
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,7 +19,8 @@ import com.arialyy.aria.core.FtpUrlEntity;
|
|||||||
import com.arialyy.aria.core.loader.IInfoTask;
|
import com.arialyy.aria.core.loader.IInfoTask;
|
||||||
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
import com.arialyy.aria.core.loader.ILoaderVisitor;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
|
import com.arialyy.aria.exception.AriaSFTPException;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import com.jcraft.jsch.JSchException;
|
import com.jcraft.jsch.JSchException;
|
||||||
import com.jcraft.jsch.Session;
|
import com.jcraft.jsch.Session;
|
||||||
@@ -53,14 +54,11 @@ public abstract class AbsSFtpInfoTask<WP extends AbsTaskWrapper> implements IInf
|
|||||||
}
|
}
|
||||||
getFileInfo(session);
|
getFileInfo(session);
|
||||||
} catch (JSchException e) {
|
} catch (JSchException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "jsch错误", e), false);
|
||||||
fail(false, null);
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
|
||||||
fail(false, null);
|
|
||||||
} catch (SftpException e) {
|
} catch (SftpException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
|
||||||
fail(false, null);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -72,7 +70,7 @@ public abstract class AbsSFtpInfoTask<WP extends AbsTaskWrapper> implements IInf
|
|||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void fail(boolean needRetry, BaseException e) {
|
protected void fail(AriaException e, boolean needRetry) {
|
||||||
callback.onFail(getWrapper().getEntity(), e, needRetry);
|
callback.onFail(getWrapper().getEntity(), e, needRetry);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ package com.arialyy.aria.sftp.download;
|
|||||||
|
|
||||||
import com.arialyy.aria.core.common.CompleteInfo;
|
import com.arialyy.aria.core.common.CompleteInfo;
|
||||||
import com.arialyy.aria.core.download.DTaskWrapper;
|
import com.arialyy.aria.core.download.DTaskWrapper;
|
||||||
import com.arialyy.aria.exception.AriaException;
|
import com.arialyy.aria.exception.AriaSFTPException;
|
||||||
import com.arialyy.aria.sftp.AbsSFtpInfoTask;
|
import com.arialyy.aria.sftp.AbsSFtpInfoTask;
|
||||||
import com.arialyy.aria.sftp.SFtpTaskOption;
|
import com.arialyy.aria.sftp.SFtpTaskOption;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
@@ -63,7 +63,7 @@ final class SFtpDInfoTask extends AbsSFtpInfoTask<DTaskWrapper> {
|
|||||||
callback.onSucceed(getWrapper().getKey(), info);
|
callback.onSucceed(getWrapper().getKey(), info);
|
||||||
} else {
|
} else {
|
||||||
callback.onFail(getWrapper().getEntity(),
|
callback.onFail(getWrapper().getEntity(),
|
||||||
new AriaException(TAG, String.format("文件不存在,remotePath:%s", remotePath)), false);
|
new AriaSFTPException(TAG, String.format("文件不存在,remotePath:%s", remotePath)), false);
|
||||||
}
|
}
|
||||||
channel.disconnect();
|
channel.disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import com.arialyy.aria.core.loader.IRecordHandler;
|
|||||||
import com.arialyy.aria.core.loader.IThreadTaskBuilder;
|
import com.arialyy.aria.core.loader.IThreadTaskBuilder;
|
||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.core.task.IThreadTask;
|
import com.arialyy.aria.core.task.IThreadTask;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.FileUtil;
|
import com.arialyy.aria.util.FileUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
|
||||||
@@ -140,7 +140,7 @@ final class SFtpDLoader extends AbsNormalLoader<DTaskWrapper> {
|
|||||||
startThreadTask();
|
startThreadTask();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
getListener().onFail(needRetry, e);
|
getListener().onFail(needRetry, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+6
-11
@@ -17,7 +17,7 @@ package com.arialyy.aria.sftp.download;
|
|||||||
|
|
||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
||||||
import com.arialyy.aria.exception.AriaException;
|
import com.arialyy.aria.exception.AriaSFTPException;
|
||||||
import com.arialyy.aria.sftp.SFtpTaskOption;
|
import com.arialyy.aria.sftp.SFtpTaskOption;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
@@ -53,7 +53,7 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
|
|
||||||
@Override protected void handlerThreadTask() {
|
@Override protected void handlerThreadTask() {
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
fail(new AriaException(TAG, "session 为空"), false);
|
fail(new AriaSFTPException(TAG, "session 为空"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -74,18 +74,13 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
CommonUtil.convertSFtpChar(charSet, option.getUrlEntity().remotePath);
|
CommonUtil.convertSFtpChar(charSet, option.getUrlEntity().remotePath);
|
||||||
download(remotePath);
|
download(remotePath);
|
||||||
} catch (SftpException e) {
|
} catch (SftpException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
|
||||||
ALog.e(TAG, "错误类型:" + e.id);
|
|
||||||
fail(null, false);
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
} catch (UnsupportedEncodingException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
|
||||||
fail(null, false);
|
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "", e), true);
|
||||||
fail(null, true);
|
|
||||||
} catch (JSchException e) {
|
} catch (JSchException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "jsch 错误", e), false);
|
||||||
fail(null, false);
|
|
||||||
} finally {
|
} finally {
|
||||||
channelSftp.disconnect();
|
channelSftp.disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ import com.arialyy.aria.core.manager.ThreadTaskManager;
|
|||||||
import com.arialyy.aria.core.task.IThreadTask;
|
import com.arialyy.aria.core.task.IThreadTask;
|
||||||
import com.arialyy.aria.core.upload.UTaskWrapper;
|
import com.arialyy.aria.core.upload.UTaskWrapper;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.exception.BaseException;
|
import com.arialyy.aria.exception.AriaException;
|
||||||
import com.arialyy.aria.util.FileUtil;
|
import com.arialyy.aria.util.FileUtil;
|
||||||
import com.jcraft.jsch.SftpATTRS;
|
import com.jcraft.jsch.SftpATTRS;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@@ -139,7 +139,7 @@ final class SFtpULoader extends AbsNormalLoader<UTaskWrapper> {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
|
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
|
||||||
getListener().onFail(needRetry, e);
|
getListener().onFail(needRetry, e);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
+9
-14
@@ -18,7 +18,7 @@ package com.arialyy.aria.sftp.upload;
|
|||||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||||
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
|
||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.exception.AriaException;
|
import com.arialyy.aria.exception.AriaSFTPException;
|
||||||
import com.arialyy.aria.sftp.SFtpTaskOption;
|
import com.arialyy.aria.sftp.SFtpTaskOption;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||||
@@ -50,7 +50,7 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
|
|
||||||
@Override protected void handlerThreadTask() {
|
@Override protected void handlerThreadTask() {
|
||||||
if (session == null) {
|
if (session == null) {
|
||||||
fail(new AriaException(TAG, "session 为空"), false);
|
fail(new AriaSFTPException(TAG, "session 为空"), false);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
@@ -74,19 +74,14 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter {
|
|||||||
}
|
}
|
||||||
channelSftp.cd(remotePath);
|
channelSftp.cd(remotePath);
|
||||||
upload(remotePath);
|
upload(remotePath);
|
||||||
} catch (JSchException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
fail(null, false);
|
|
||||||
} catch (UnsupportedEncodingException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
fail(null, false);
|
|
||||||
} catch (IOException e) {
|
|
||||||
e.printStackTrace();
|
|
||||||
fail(null, true);
|
|
||||||
} catch (SftpException e) {
|
} catch (SftpException e) {
|
||||||
e.printStackTrace();
|
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
|
||||||
fail(null, false);
|
} catch (UnsupportedEncodingException e) {
|
||||||
ALog.d(TAG, "错误类型:" + e.id);
|
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
|
||||||
|
} catch (IOException e) {
|
||||||
|
fail(new AriaSFTPException(TAG, "", e), true);
|
||||||
|
} catch (JSchException e) {
|
||||||
|
fail(new AriaSFTPException(TAG, "jsch 错误", e), false);
|
||||||
} finally {
|
} finally {
|
||||||
channelSftp.disconnect();
|
channelSftp.disconnect();
|
||||||
}
|
}
|
||||||
|
|||||||
+54
-76
@@ -17,22 +17,21 @@ package com.arialyy.simple.core.download.group;
|
|||||||
|
|
||||||
import android.os.Bundle;
|
import android.os.Bundle;
|
||||||
import android.os.Environment;
|
import android.os.Environment;
|
||||||
import android.util.Log;
|
|
||||||
import android.view.View;
|
import android.view.View;
|
||||||
import com.arialyy.annotations.DownloadGroup;
|
import com.arialyy.annotations.DownloadGroup;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.HttpOption;
|
import com.arialyy.aria.core.common.HttpOption;
|
||||||
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
|
||||||
import com.arialyy.aria.core.task.DownloadGroupTask;
|
import com.arialyy.aria.core.task.DownloadGroupTask;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.frame.util.show.L;
|
|
||||||
import com.arialyy.frame.util.show.T;
|
import com.arialyy.frame.util.show.T;
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.databinding.ActivityDownloadGroupBinding;
|
import com.arialyy.simple.databinding.ActivityDownloadGroupBinding;
|
||||||
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import com.arialyy.simple.widget.SubStateLinearLayout;
|
import com.arialyy.simple.widget.SubStateLinearLayout;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
@@ -57,26 +56,47 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
|||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
mTaskId = entity.getId();
|
mTaskId = entity.getId();
|
||||||
mChildList.addData(entity.getSubEntities());
|
mChildList.addData(entity.getSubEntities());
|
||||||
getBinding().setStateStr(
|
|
||||||
entity.getState() == IEntity.STATE_RUNNING ? getString(R.string.stop)
|
|
||||||
: getString(R.string.resume));
|
|
||||||
getBinding().setFileSize(entity.getConvertFileSize());
|
|
||||||
if (entity.getFileSize() == 0) {
|
|
||||||
getBinding().setProgress(0);
|
|
||||||
} else {
|
|
||||||
getBinding().setProgress(entity.isComplete() ? 100
|
|
||||||
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
|
|
||||||
}
|
|
||||||
ALog.d(TAG, "progress = " + getBinding().getProgress());
|
|
||||||
ALog.d(TAG,
|
ALog.d(TAG,
|
||||||
"size = " + entity.getSubEntities().size() + "; len = " + entity.getConvertFileSize());
|
"size = " + entity.getSubEntities().size() + "; len = " + entity.getConvertFileSize());
|
||||||
|
}else {
|
||||||
|
entity = new DownloadGroupEntity();
|
||||||
}
|
}
|
||||||
|
getBinding().pl.setInfo(entity);
|
||||||
|
|
||||||
mChildList.setOnItemClickListener(new SubStateLinearLayout.OnItemClickListener() {
|
mChildList.setOnItemClickListener(new SubStateLinearLayout.OnItemClickListener() {
|
||||||
@Override public void onItemClick(int position, View view) {
|
@Override public void onItemClick(int position, View view) {
|
||||||
showPopupWindow(position);
|
showPopupWindow(position);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
mTaskId = Aria.download(this)
|
||||||
|
.loadGroup(mUrls)
|
||||||
|
.setDirPath(
|
||||||
|
Environment.getExternalStorageDirectory().getPath() + "/Download/group_imgs")
|
||||||
|
//.setSubFileName(getModule(GroupModule.class).getSubName2())
|
||||||
|
.setSubFileName(getModule(GroupModule.class).getSubName())
|
||||||
|
.unknownSize()
|
||||||
|
.option(getHttpOption())
|
||||||
|
.ignoreFilePathOccupy()
|
||||||
|
//.setFileSize(114981416)
|
||||||
|
//.updateUrls(temp)
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadGroup(mTaskId).stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadGroup(mTaskId).resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadGroup(mTaskId).cancel(true);
|
||||||
|
mTaskId = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void showPopupWindow(int position) {
|
private void showPopupWindow(int position) {
|
||||||
@@ -89,111 +109,69 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
|||||||
return R.layout.activity_download_group;
|
return R.layout.activity_download_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
private HttpOption getHttpOption() {
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
if (mTaskId == -1) {
|
|
||||||
mTaskId = Aria.download(this)
|
|
||||||
.loadGroup(mUrls)
|
|
||||||
.setDirPath(
|
|
||||||
Environment.getExternalStorageDirectory().getPath() + "/Download/group_imgs")
|
|
||||||
//.setSubFileName(getModule(GroupModule.class).getSubName2())
|
|
||||||
.setSubFileName(getModule(GroupModule.class).getSubName())
|
|
||||||
.unknownSize()
|
|
||||||
.option(getHttpOption())
|
|
||||||
.ignoreFilePathOccupy()
|
|
||||||
//.setFileSize(114981416)
|
|
||||||
//.updateUrls(temp)
|
|
||||||
.create();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.download(this).loadGroup(mTaskId).isRunning()) {
|
|
||||||
Aria.download(this).loadGroup(mTaskId).stop();
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else {
|
|
||||||
Aria.download(this).loadGroup(mTaskId).resume();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.download(this).loadGroup(mTaskId).cancel(true);
|
|
||||||
mTaskId = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private HttpOption getHttpOption(){
|
|
||||||
HttpOption option = new HttpOption();
|
HttpOption option = new HttpOption();
|
||||||
option.setFileLenAdapter(new HttpFileLenAdapter());
|
option.setFileLenAdapter(new HttpFileLenAdapter());
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onWait void taskWait(DownloadGroupTask task) {
|
@DownloadGroup.onWait void taskWait(DownloadGroupTask task) {
|
||||||
L.d(TAG, task.getTaskName() + "wait");
|
ALog.d(TAG, task.getTaskName() + "wait");
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onPre() protected void onPre(DownloadGroupTask task) {
|
@DownloadGroup.onPre() protected void onPre(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group pre, p = " + task.getPercent());
|
ALog.d(TAG, "group pre, p = " + task.getPercent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskPre() protected void onTaskPre(DownloadGroupTask task) {
|
@DownloadGroup.onTaskPre() protected void onTaskPre(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group task pre, p = " + task.getPercent());
|
ALog.d(TAG, "group task pre, p = " + task.getPercent());
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
|
||||||
if (mChildList.getSubData().size() <= 0) {
|
if (mChildList.getSubData().size() <= 0) {
|
||||||
mChildList.addData(task.getEntity().getSubEntities());
|
mChildList.addData(task.getEntity().getSubEntities());
|
||||||
}
|
}
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskStart() void taskStart(DownloadGroupTask task) {
|
@DownloadGroup.onTaskStart() void taskStart(DownloadGroupTask task) {
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
ALog.d(TAG, "group task create, p = " + task.getPercent());
|
||||||
L.d(TAG, "group task create, p = " + task.getPercent());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskRunning() protected void running(DownloadGroupTask task) {
|
@DownloadGroup.onTaskRunning() protected void running(DownloadGroupTask task) {
|
||||||
Log.d(TAG, "group running, p = "
|
ALog.d(TAG, "group running, p = "
|
||||||
+ task.getPercent()
|
+ task.getPercent()
|
||||||
+ ", speed = "
|
+ ", speed = "
|
||||||
+ task.getConvertSpeed()
|
+ task.getConvertSpeed()
|
||||||
+ ", current_p = "
|
+ ", current_p = "
|
||||||
+ task.getCurrentProgress());
|
+ task.getCurrentProgress());
|
||||||
getBinding().setProgress(task.getPercent());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
|
||||||
getBinding().setTimeLeft(task.getConvertTimeLeft());
|
|
||||||
//Log.d(TAG, "sub_len = " + task.getEntity().getSubEntities().size());
|
//Log.d(TAG, "sub_len = " + task.getEntity().getSubEntities().size());
|
||||||
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskResume() void taskResume(DownloadGroupTask task) {
|
@DownloadGroup.onTaskResume() void taskResume(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group task resume, p = " + task.getPercent());
|
ALog.d(TAG, "group task resume, p = " + task.getPercent());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskStop() void taskStop(DownloadGroupTask task) {
|
@DownloadGroup.onTaskStop() void taskStop(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group task stop");
|
ALog.d(TAG, "group task stop");
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
|
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group task cancel");
|
ALog.d(TAG, "group task cancel");
|
||||||
getBinding().setSpeed("");
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setProgress(0);
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskFail() void taskFail(DownloadGroupTask task) {
|
@DownloadGroup.onTaskFail() void taskFail(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group task fail");
|
ALog.d(TAG, "group task fail");
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setSpeed("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) {
|
@DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) {
|
||||||
getBinding().setProgress(100);
|
|
||||||
getBinding().setSpeed("");
|
|
||||||
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
||||||
T.showShort(this, "任务组下载完成");
|
T.showShort(this, "任务组下载完成");
|
||||||
L.d(TAG, "任务组下载完成");
|
ALog.d(TAG, "任务组下载完成");
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onSubTaskRunning void onSubTaskRunning(DownloadGroupTask groupTask,
|
@DownloadGroup.onSubTaskRunning void onSubTaskRunning(DownloadGroupTask groupTask,
|
||||||
@@ -246,7 +224,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
|||||||
DownloadEntity subEntity) {
|
DownloadEntity subEntity) {
|
||||||
}
|
}
|
||||||
|
|
||||||
static class HttpFileLenAdapter implements IHttpFileLenAdapter{
|
static class HttpFileLenAdapter implements IHttpFileLenAdapter {
|
||||||
@Override public long handleFileLen(Map<String, List<String>> headers) {
|
@Override public long handleFileLen(Map<String, List<String>> headers) {
|
||||||
|
|
||||||
List<String> sLength = headers.get("Content-Length");
|
List<String> sLength = headers.get("Content-Length");
|
||||||
|
|||||||
+55
-71
@@ -20,18 +20,17 @@ import android.os.Environment;
|
|||||||
import android.view.View;
|
import android.view.View;
|
||||||
import com.arialyy.annotations.DownloadGroup;
|
import com.arialyy.annotations.DownloadGroup;
|
||||||
import com.arialyy.aria.core.Aria;
|
import com.arialyy.aria.core.Aria;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
import com.arialyy.aria.core.common.FtpOption;
|
import com.arialyy.aria.core.common.FtpOption;
|
||||||
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
import com.arialyy.aria.core.download.DownloadGroupEntity;
|
||||||
import com.arialyy.aria.core.inf.IEntity;
|
|
||||||
import com.arialyy.aria.core.task.DownloadGroupTask;
|
import com.arialyy.aria.core.task.DownloadGroupTask;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.frame.util.show.L;
|
|
||||||
import com.arialyy.frame.util.show.T;
|
import com.arialyy.frame.util.show.T;
|
||||||
import com.arialyy.simple.R;
|
import com.arialyy.simple.R;
|
||||||
import com.arialyy.simple.base.BaseActivity;
|
import com.arialyy.simple.base.BaseActivity;
|
||||||
import com.arialyy.simple.databinding.ActivityDownloadGroupBinding;
|
import com.arialyy.simple.databinding.ActivityDownloadGroupBinding;
|
||||||
|
import com.arialyy.simple.widget.ProgressLayout;
|
||||||
import com.arialyy.simple.widget.SubStateLinearLayout;
|
import com.arialyy.simple.widget.SubStateLinearLayout;
|
||||||
import java.security.AlgorithmConstraints;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by lyy on 2017/7/6.
|
* Created by lyy on 2017/7/6.
|
||||||
@@ -52,110 +51,95 @@ public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBi
|
|||||||
if (entity != null) {
|
if (entity != null) {
|
||||||
mTaskId = entity.getId();
|
mTaskId = entity.getId();
|
||||||
mChildList.addData(entity.getSubEntities());
|
mChildList.addData(entity.getSubEntities());
|
||||||
getBinding().setFileSize(entity.getConvertFileSize());
|
getBinding().pl.setInfo(entity);
|
||||||
if (entity.getState() == IEntity.STATE_RUNNING) {
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
} else {
|
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
}
|
|
||||||
if (entity.getFileSize() == 0) {
|
|
||||||
getBinding().setProgress(0);
|
|
||||||
} else {
|
|
||||||
getBinding().setProgress(entity.isComplete() ? 100
|
|
||||||
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
|
||||||
|
@Override public void create(View v, AbsEntity entity) {
|
||||||
|
mTaskId = Aria.download(this)
|
||||||
|
.loadFtpDir(dir)
|
||||||
|
.setDirPath(
|
||||||
|
Environment.getExternalStorageDirectory().getPath() + "/Download/ftp_dir")
|
||||||
|
.setGroupAlias("ftp文件夹下载")
|
||||||
|
.option(getFtpOption())
|
||||||
|
.ignoreFilePathOccupy()
|
||||||
|
.create();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void stop(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadFtpDir(mTaskId).stop();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void resume(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this)
|
||||||
|
.loadFtpDir(mTaskId)
|
||||||
|
.option(getFtpOption())
|
||||||
|
.resume();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void cancel(View v, AbsEntity entity) {
|
||||||
|
Aria.download(this).loadFtpDir(mTaskId).cancel();
|
||||||
|
mTaskId = -1;
|
||||||
|
}
|
||||||
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected int setLayoutId() {
|
@Override protected int setLayoutId() {
|
||||||
return R.layout.activity_download_group;
|
return R.layout.activity_download_group;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void onClick(View view) {
|
|
||||||
switch (view.getId()) {
|
|
||||||
case R.id.start:
|
|
||||||
if (mTaskId == -1) {
|
|
||||||
mTaskId = Aria.download(this)
|
|
||||||
.loadFtpDir(dir)
|
|
||||||
.setDirPath(
|
|
||||||
Environment.getExternalStorageDirectory().getPath() + "/Download/ftp_dir")
|
|
||||||
.setGroupAlias("ftp文件夹下载")
|
|
||||||
.option(getFtpOption())
|
|
||||||
.ignoreFilePathOccupy()
|
|
||||||
.create();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
if (Aria.download(this).loadFtpDir(mTaskId).isRunning()) {
|
|
||||||
Aria.download(this).loadFtpDir(mTaskId).stop();
|
|
||||||
getBinding().setStateStr(getString(R.string.resume));
|
|
||||||
} else {
|
|
||||||
Aria.download(this)
|
|
||||||
.loadFtpDir(mTaskId)
|
|
||||||
.option(getFtpOption())
|
|
||||||
.resume();
|
|
||||||
getBinding().setStateStr(getString(R.string.stop));
|
|
||||||
}
|
|
||||||
break;
|
|
||||||
case R.id.cancel:
|
|
||||||
Aria.download(this).loadFtpDir(mTaskId).cancel();
|
|
||||||
mTaskId = -1;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private FtpOption getFtpOption() {
|
private FtpOption getFtpOption() {
|
||||||
FtpOption option = new FtpOption();
|
FtpOption option = new FtpOption();
|
||||||
option.login(user, pwd);
|
option.login(user, pwd);
|
||||||
return option;
|
return option;
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onPre() protected void onPre(DownloadGroupTask task) {
|
@DownloadGroup.onPre protected void onPre(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group pre");
|
ALog.d(TAG, "ftp dir pre");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskPre() protected void onTaskPre(DownloadGroupTask task) {
|
@DownloadGroup.onTaskPre protected void onTaskPre(DownloadGroupTask task) {
|
||||||
|
ALog.d(TAG, "ftp dir task pre");
|
||||||
if (mChildList.getSubData().size() <= 0) {
|
if (mChildList.getSubData().size() <= 0) {
|
||||||
mChildList.addData(task.getEntity().getSubEntities());
|
mChildList.addData(task.getEntity().getSubEntities());
|
||||||
}
|
}
|
||||||
getBinding().setFileSize(task.getConvertFileSize());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskStart() void taskStart(DownloadGroupTask task) {
|
@DownloadGroup.onTaskStart void taskStart(DownloadGroupTask task) {
|
||||||
|
ALog.d(TAG, "ftp dir start");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskRunning() protected void running(DownloadGroupTask task) {
|
@DownloadGroup.onTaskRunning protected void running(DownloadGroupTask task) {
|
||||||
ALog.d(TAG, "ftp dir running, p = " + task.getPercent());
|
ALog.d(TAG, "ftp dir running, p = " + task.getPercent());
|
||||||
getBinding().setProgress(task.getPercent());
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setSpeed(task.getConvertSpeed());
|
|
||||||
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskResume() void taskResume(DownloadGroupTask task) {
|
@DownloadGroup.onTaskResume void taskResume(DownloadGroupTask task) {
|
||||||
ALog.d(TAG, "ftp dir resume");
|
ALog.d(TAG, "ftp dir resume");
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskStop() void taskStop(DownloadGroupTask task) {
|
@DownloadGroup.onTaskStop void taskStop(DownloadGroupTask task) {
|
||||||
getBinding().setSpeed("");
|
ALog.d(TAG, "ftp dir stop");
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
|
@DownloadGroup.onTaskCancel void taskCancel(DownloadGroupTask task) {
|
||||||
getBinding().setSpeed("");
|
ALog.d(TAG, "ftp dir cancel");
|
||||||
getBinding().setProgress(0);
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setStateStr(getString(R.string.start));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskFail() void taskFail(DownloadGroupTask task) {
|
@DownloadGroup.onTaskFail void taskFail(DownloadGroupTask task) {
|
||||||
L.d(TAG, "group task fail");
|
ALog.d(TAG, "group task fail");
|
||||||
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) {
|
@DownloadGroup.onTaskComplete void taskComplete(DownloadGroupTask task) {
|
||||||
getBinding().setProgress(100);
|
|
||||||
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
||||||
getBinding().setStateStr(getString(R.string.re_start));
|
getBinding().pl.setInfo(task.getEntity());
|
||||||
getBinding().setSpeed("");
|
|
||||||
T.showShort(this, "任务组下载完成");
|
T.showShort(this, "任务组下载完成");
|
||||||
L.d(TAG, "任务组下载完成");
|
ALog.d(TAG, "任务组下载完成");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,30 +1,5 @@
|
|||||||
<?xml version="1.0" encoding="utf-8"?>
|
<?xml version="1.0" encoding="utf-8"?>
|
||||||
<layout xmlns:android="http://schemas.android.com/apk/res/android"
|
<layout xmlns:android="http://schemas.android.com/apk/res/android">
|
||||||
xmlns:bind="http://schemas.android.com/apk/res-auto"
|
|
||||||
>
|
|
||||||
<data>
|
|
||||||
<variable
|
|
||||||
name="fileSize"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="speed"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="progress"
|
|
||||||
type="int"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="stateStr"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
<variable
|
|
||||||
name="timeLeft"
|
|
||||||
type="String"
|
|
||||||
/>
|
|
||||||
|
|
||||||
</data>
|
|
||||||
|
|
||||||
<RelativeLayout
|
<RelativeLayout
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
@@ -32,26 +7,21 @@
|
|||||||
android:orientation="vertical"
|
android:orientation="vertical"
|
||||||
>
|
>
|
||||||
|
|
||||||
<include layout="@layout/layout_bar"/>
|
<include layout="@layout/layout_bar" />
|
||||||
|
|
||||||
<include
|
<com.arialyy.simple.widget.ProgressLayout
|
||||||
layout="@layout/layout_content_single"
|
android:id="@+id/pl"
|
||||||
android:id="@+id/content"
|
android:layout_width="match_parent"
|
||||||
android:layout_width="wrap_content"
|
|
||||||
android:layout_height="wrap_content"
|
android:layout_height="wrap_content"
|
||||||
android:layout_below="@+id/toolbar"
|
android:layout_below="@+id/toolbar"
|
||||||
bind:fileSize="@{fileSize}"
|
android:layout_margin="16dp"
|
||||||
bind:progress="@{progress}"
|
|
||||||
bind:speed="@{speed}"
|
|
||||||
bind:stateStr="@{stateStr}"
|
|
||||||
bind:timeLeft="@{timeLeft}"
|
|
||||||
/>
|
/>
|
||||||
|
|
||||||
<com.arialyy.simple.widget.SubStateLinearLayout
|
<com.arialyy.simple.widget.SubStateLinearLayout
|
||||||
android:id="@+id/child_list"
|
android:id="@+id/child_list"
|
||||||
android:layout_width="match_parent"
|
android:layout_width="match_parent"
|
||||||
android:layout_height="match_parent"
|
android:layout_height="match_parent"
|
||||||
android:layout_below="@+id/content"
|
android:layout_below="@+id/pl"
|
||||||
android:paddingLeft="16dp"
|
android:paddingLeft="16dp"
|
||||||
android:paddingRight="16dp"
|
android:paddingRight="16dp"
|
||||||
/>
|
/>
|
||||||
|
|||||||
@@ -53,6 +53,7 @@
|
|||||||
android:layout_alignTop="@+id/speed_or_state"
|
android:layout_alignTop="@+id/speed_or_state"
|
||||||
android:layout_alignParentEnd="true"
|
android:layout_alignParentEnd="true"
|
||||||
android:layout_alignParentRight="true"
|
android:layout_alignParentRight="true"
|
||||||
|
android:text="-/-"
|
||||||
android:textSize="@dimen/text_size_smallest"
|
android:textSize="@dimen/text_size_smallest"
|
||||||
tools:ignore="RelativeOverlap"
|
tools:ignore="RelativeOverlap"
|
||||||
/>
|
/>
|
||||||
|
|||||||
Reference in new issue
Block a user