优化异常提示
pull/617/head
laoyuyu 5 years ago
parent 96efa35c4e
commit e015c2a2f7
  1. 3
      DEV_LOG.md
  2. 11
      FtpComponent/src/main/java/com/arialyy/aria/ftp/AbsFtpInfoTask.java
  3. 4
      FtpComponent/src/main/java/com/arialyy/aria/ftp/BaseFtpThreadTaskAdapter.java
  4. 4
      FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDFileInfoTask.java
  5. 4
      FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDGLoader.java
  6. 20
      FtpComponent/src/main/java/com/arialyy/aria/ftp/download/FtpDThreadTaskAdapter.java
  7. 4
      FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpULoader.java
  8. 16
      FtpComponent/src/main/java/com/arialyy/aria/ftp/upload/FtpUThreadTaskAdapter.java
  9. 37
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDFileInfoTask.java
  10. 10
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGInfoTask.java
  11. 4
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDGLoader.java
  12. 17
      HttpComponent/src/main/java/com/arialyy/aria/http/download/HttpDThreadTaskAdapter.java
  13. 4
      HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpULoader.java
  14. 12
      HttpComponent/src/main/java/com/arialyy/aria/http/upload/HttpUThreadTaskAdapter.java
  15. 7
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8InfoTask.java
  16. 19
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/M3U8ThreadTaskAdapter.java
  17. 15
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/live/M3U8LiveLoader.java
  18. 12
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/M3U8VodLoader.java
  19. 8
      M3U8Component/src/main/java/com/arialyy/aria/m3u8/vod/VodStateManager.java
  20. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/group/AbsGroupLoader.java
  21. 6
      PublicComponent/src/main/java/com/arialyy/aria/core/group/SimpleSchedulers.java
  22. 9
      PublicComponent/src/main/java/com/arialyy/aria/core/listener/BaseListener.java
  23. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/listener/DownloadGroupListener.java
  24. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/listener/IDGroupListener.java
  25. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/listener/IEventListener.java
  26. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/AbsNormalLoaderUtil.java
  27. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/IInfoTask.java
  28. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalLoader.java
  29. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/NormalThreadStateManager.java
  30. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/loader/SubLoader.java
  31. 2
      PublicComponent/src/main/java/com/arialyy/aria/core/manager/ThreadTaskManager.java
  32. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/task/AbsThreadTaskAdapter.java
  33. 4
      PublicComponent/src/main/java/com/arialyy/aria/core/task/IThreadTaskObserver.java
  34. 8
      PublicComponent/src/main/java/com/arialyy/aria/core/task/ThreadTask.java
  35. 16
      PublicComponent/src/main/java/com/arialyy/aria/exception/AriaException.java
  36. 10
      PublicComponent/src/main/java/com/arialyy/aria/exception/AriaFTPException.java
  37. 10
      PublicComponent/src/main/java/com/arialyy/aria/exception/AriaHTTPException.java
  38. 10
      PublicComponent/src/main/java/com/arialyy/aria/exception/AriaM3U8Exception.java
  39. 13
      PublicComponent/src/main/java/com/arialyy/aria/exception/AriaSFTPException.java
  40. 35
      PublicComponent/src/main/java/com/arialyy/aria/exception/BaseException.java
  41. 32
      PublicComponent/src/main/java/com/arialyy/aria/exception/FileException.java
  42. 32
      PublicComponent/src/main/java/com/arialyy/aria/exception/FileNotFoundException.java
  43. 24
      PublicComponent/src/main/java/com/arialyy/aria/exception/ParamException.java
  44. 6
      PublicComponent/src/main/java/com/arialyy/aria/util/ALog.java
  45. 6
      PublicComponent/src/main/java/com/arialyy/aria/util/CommonUtil.java
  46. 14
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/AbsSFtpInfoTask.java
  47. 4
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDInfoTask.java
  48. 4
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDLoader.java
  49. 17
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/download/SFtpDThreadTaskAdapter.java
  50. 4
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpULoader.java
  51. 21
      SFtpComponent/src/main/java/com/arialyy/aria/sftp/upload/SFtpUThreadTaskAdapter.java
  52. 108
      app/src/main/java/com/arialyy/simple/core/download/group/DownloadGroupActivity.java
  53. 98
      app/src/main/java/com/arialyy/simple/core/download/group/FTPDirDownloadActivity.java
  54. 42
      app/src/main/res/layout/activity_download_group.xml
  55. 1
      app/src/main/res/layout/layout_progress_content.xml

@ -1,4 +1,7 @@
## 开发日志
+ v_3.8.6
- fix bug https://github.com/AriaLyy/Aria/issues/608
- 优化异常提示
+ v_3.8.5 (2020/1/18)
- fix bug https://github.com/AriaLyy/Aria/issues/599
- 增加密钥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.ILoaderVisitor;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaFTPException;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CheckUtil;
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);
}
} catch (IOException e) {
ALog.e(TAG,
new TaskException(TAG, String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(),
client.getReplyString()), e));
e.printStackTrace();
ALog.e(TAG, String.format("登录失败,错误码为:%s, msg:%s", client.getReplyCode(),
client.getReplyString()));
return null;
}
}
@ -329,7 +328,7 @@ public abstract class AbsFtpInfoTask<ENTITY extends AbsEntity, TASK_WRAPPER exte
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.SubThreadConfig;
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.SSLContextUtil;
import java.io.IOException;
@ -105,7 +105,7 @@ public abstract class BaseFtpThreadTaskAdapter extends AbsThreadTaskAdapter {
int reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
client.disconnect();
fail(new AriaIOException(TAG,
fail(new AriaFTPException(TAG,
String.format("无法连接到ftp服务器,错误码为:%s,msg:%s", reply, client.getReplyString())), false);
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.download.DTaskWrapper;
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.util.ALog;
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) {
super.handleFile(remotePath, ftpFile);
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())),
false);
}

@ -25,7 +25,7 @@ import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.listener.IEventListener;
import com.arialyy.aria.core.loader.IInfoTask;
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;
/**
@ -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);
fail(e, needRetry);
}

@ -18,8 +18,7 @@ package com.arialyy.aria.ftp.download;
import aria.apache.commons.net.ftp.FTPClient;
import aria.apache.commons.net.ftp.FTPReply;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaFTPException;
import com.arialyy.aria.ftp.BaseFtpThreadTaskAdapter;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile;
@ -57,7 +56,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
getThreadRecord().endLocation));
client = createClient();
if (client == null) {
fail(new TaskException(TAG, "ftp client 创建失败"), false);
fail(new AriaFTPException(TAG, "ftp client 创建失败"), false);
return;
}
if (getThreadRecord().startLocation > 0) {
@ -66,7 +65,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
//发送第二次指令时,还需要再做一次判断
int reply = client.getReplyCode();
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);
client.disconnect();
return;
@ -77,7 +76,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
is = client.retrieveFileStream(remotePath);
reply = client.getReplyCode();
if (!FTPReply.isPositivePreliminary(reply)) {
fail(new AriaIOException(TAG,
fail(new AriaFTPException(TAG,
String.format("获取流失败,错误码为:%s,msg:%s", reply, client.getReplyString())), true);
client.disconnect();
return;
@ -90,9 +89,9 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
handleComplete();
}
} 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) {
fail(new AriaIOException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), false);
fail(new AriaFTPException(TAG, String.format("下载失败【%s】", getThreadConfig().url), e), false);
} finally {
try {
if (is != null) {
@ -154,7 +153,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
}
handleComplete();
} 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 {
try {
if (fos != null) {
@ -179,7 +178,8 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
BufferedRandomAccessFile file = null;
try {
file =
new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd", getTaskConfig().getBuffSize());
new BufferedRandomAccessFile(getThreadConfig().tempFile, "rwd",
getTaskConfig().getBuffSize());
if (getThreadRecord().startLocation > 0) {
file.seek(getThreadRecord().startLocation);
}
@ -203,7 +203,7 @@ final class FtpDThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
}
}
} 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 {
try {
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.task.IThreadTask;
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> {
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);
}
});

@ -21,7 +21,7 @@ import aria.apache.commons.net.ftp.FTPReply;
import aria.apache.commons.net.ftp.OnFtpInputStreamListener;
import com.arialyy.aria.core.common.SubThreadConfig;
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.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile;
@ -63,7 +63,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
client.setRestartOffset(getThreadRecord().startLocation);
int reply = client.getReplyCode();
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,
client.getReplyString(), getEntity().getFilePath())), false);
client.disconnect();
@ -81,7 +81,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
return;
}
if (!complete) {
fail(new AriaIOException(TAG, "ftp文件上传失败"), false);
fail(new AriaFTPException(TAG, "ftp文件上传失败"), false);
return;
}
ALog.i(TAG,
@ -89,11 +89,11 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
complete();
} catch (IOException e) {
e.printStackTrace();
fail(new AriaIOException(TAG,
fail(new AriaFTPException(TAG,
String.format("上传失败,filePath: %s, uploadUrl: %s", getEntity().getFilePath(),
getThreadConfig().url)), true);
} catch (Exception e) {
fail(new AriaIOException(TAG, null, e), false);
fail(new AriaFTPException(TAG, null, e), false);
} finally {
try {
if (file != null) {
@ -132,7 +132,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
@Override public void run() {
try {
if (isTimeOut) {
fail(new AriaIOException(TAG, "socket连接失败,该问题一般出现于网络断开,客户端重新连接,"
fail(new AriaFTPException(TAG, "socket连接失败,该问题一般出现于网络断开,客户端重新连接,"
+ "但是服务器端无法创建socket缺没有返回错误码的情况。"), false);
if (fa != null) {
fa.close();
@ -195,7 +195,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
if (e.getMessage().contains("AriaIOException caught while copying")) {
e.printStackTrace();
} else {
fail(new AriaIOException(TAG, msg, e), !storeSuccess);
fail(new AriaFTPException(TAG, msg, e), !storeSuccess);
}
return false;
} finally {
@ -204,7 +204,7 @@ final class FtpUThreadTaskAdapter extends BaseFtpThreadTaskAdapter {
int reply = client.getReplyCode();
if (!FTPReply.isPositiveCompletion(reply)) {
if (reply != FTPReply.TRANSFER_ABORTED) {
fail(new AriaIOException(TAG,
fail(new AriaFTPException(TAG,
String.format("文件上传错误,错误码为:%s, msg:%s, filePath: %s", reply, client.getReplyString(),
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.ILoaderVisitor;
import com.arialyy.aria.core.processor.IHttpFileLenAdapter;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaHTTPException;
import com.arialyy.aria.http.ConnectionHelp;
import com.arialyy.aria.http.HttpTaskOption;
import com.arialyy.aria.util.ALog;
@ -40,6 +38,7 @@ import com.arialyy.aria.util.RecordUtil;
import java.io.BufferedReader;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.UnsupportedEncodingException;
@ -85,14 +84,16 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
conn.connect();
handleConnect(conn);
} catch (IOException e) {
e.printStackTrace();
failDownload(new AriaIOException(TAG,
String.format("下载失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl())),
true);
failDownload(new AriaHTTPException(TAG,
String.format("下载失败,filePath: %s, url: %s", mEntity.getFilePath(), mEntity.getUrl()),
e), true);
} finally {
if (conn != null) {
try {
conn.getInputStream().close();
InputStream is = conn.getInputStream();
if (is != null){
is.close();
}
} catch (IOException e) {
e.printStackTrace();
}
@ -132,7 +133,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
long len = lenAdapter.handleFileLen(conn.getHeaderFields());
if (!FileUtil.checkMemorySpace(mEntity.getFilePath(), len)) {
failDownload(new TaskException(TAG,
failDownload(new AriaHTTPException(TAG,
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getFilePath(),
mEntity.getUrl())), false);
return;
@ -176,7 +177,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
if (!checkLen(len) && !isChunked) {
if (len < 0) {
failDownload(
new AriaIOException(TAG, String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
new AriaHTTPException(TAG,
String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
false);
}
return;
@ -203,7 +205,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
} else if (!checkLen(len) && !isChunked) {
if (len < 0) {
failDownload(
new AriaIOException(TAG, String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
new AriaHTTPException(TAG,
String.format("任务下载失败,文件长度小于0, url: %s", mEntity.getUrl())),
false);
}
ALog.d(TAG, "len < 0");
@ -214,8 +217,8 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
mTaskWrapper.setSupportBP(false);
end = true;
} else if (code == HttpURLConnection.HTTP_NOT_FOUND) {
failDownload(new AriaIOException(TAG,
String.format("任务下载失败,errorCode:404, url: %s", mEntity.getUrl())), true);
failDownload(new AriaHTTPException(TAG,
String.format("任务下载失败,errorCode:404, url: %s", mEntity.getUrl())), false);
} else if (code == HttpURLConnection.HTTP_MOVED_TEMP
|| code == HttpURLConnection.HTTP_MOVED_PERM
|| code == HttpURLConnection.HTTP_SEE_OTHER
@ -223,7 +226,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
|| code == 307) {
handleUrlReTurn(conn, conn.getHeaderField("Location"));
} else {
failDownload(new AriaIOException(TAG,
failDownload(new AriaHTTPException(TAG,
String.format("任务下载失败,errorCode:%s, errorMsg: %s, url: %s", code,
conn.getResponseMessage(), mEntity.getUrl())), !CheckUtil.httpIsBadRequest(code));
}
@ -298,7 +301,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
if (callback != null) {
callback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false);
callback.onFail(mEntity, new AriaHTTPException(TAG, "获取重定向链接失败"), false);
}
return;
}
@ -308,7 +311,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
}
if (!CheckUtil.checkUrl(newUrl)) {
failDownload(new TaskException(TAG, "下载失败,重定向url错误"), false);
failDownload(new AriaHTTPException(TAG, "下载失败,重定向url错误"), false);
return;
}
taskOption.setRedirectUrl(newUrl);
@ -341,7 +344,7 @@ final class HttpDFileInfoTask implements IInfoTask, Runnable {
return true;
}
private void failDownload(BaseException e, boolean needRetry) {
private void failDownload(AriaHTTPException e, boolean needRetry) {
if (callback != null) {
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.loader.IInfoTask;
import com.arialyy.aria.core.loader.ILoaderVisitor;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.AriaException;
import com.arialyy.aria.exception.AriaHTTPException;
import com.arialyy.aria.http.HttpTaskOption;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
@ -55,11 +55,11 @@ public final class HttpDGInfoTask implements IInfoTask {
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()));
count++;
failCount++;
listener.onSubFail((DownloadEntity) entity, new AriaIOException(TAG,
listener.onSubFail((DownloadEntity) entity, new AriaHTTPException(TAG,
String.format("子任务获取文件长度失败,url:%s", ((DownloadEntity) entity).getUrl())));
checkGetSizeComplete(count, failCount);
}
@ -121,7 +121,7 @@ public final class HttpDGInfoTask implements IInfoTask {
*/
private void checkGetSizeComplete(int count, int failCount) {
if (failCount == wrapper.getSubTaskWrapper().size()) {
callback.onFail(wrapper.getEntity(), new AriaIOException(TAG, "获取子任务长度失败"), false);
callback.onFail(wrapper.getEntity(), new AriaHTTPException(TAG, "获取子任务长度失败"), false);
notifyLock();
return;
}

@ -25,7 +25,7 @@ import com.arialyy.aria.core.group.AbsSubDLoadUtil;
import com.arialyy.aria.core.listener.DownloadGroupListener;
import com.arialyy.aria.core.loader.IInfoTask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.AriaException;
/**
* http 组合任务加载器
@ -65,7 +65,7 @@ final class HttpDGLoader extends AbsGroupLoader {
startSub();
}
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
fail(e, needRetry);
}
});

@ -18,8 +18,7 @@ package com.arialyy.aria.http.download;
import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaHTTPException;
import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
import com.arialyy.aria.http.ConnectionHelp;
import com.arialyy.aria.util.ALog;
@ -118,19 +117,19 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
handleComplete();
}
} catch (MalformedURLException e) {
fail(new TaskException(TAG,
fail(new AriaHTTPException(TAG,
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
getEntity().getFilePath(), getEntity().getUrl()), e), false);
} catch (IOException e) {
fail(new TaskException(TAG,
fail(new AriaHTTPException(TAG,
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
getEntity().getFilePath(), getEntity().getUrl()), e), true);
} catch (ArrayIndexOutOfBoundsException e) {
fail(new TaskException(TAG,
fail(new AriaHTTPException(TAG,
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
getEntity().getFilePath(), getEntity().getUrl()), e), false);
} catch (Exception e) {
fail(new TaskException(TAG,
fail(new AriaHTTPException(TAG,
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
getEntity().getFilePath(), getEntity().getUrl()), e), false);
} finally {
@ -172,9 +171,9 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
}
handleComplete();
} catch (IOException e) {
fail(new AriaIOException(TAG,
fail(new AriaHTTPException(TAG,
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
getThreadConfig().url)), true);
getThreadConfig().url), e), true);
} finally {
if (fos != null) {
try {
@ -225,7 +224,7 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
}
handleComplete();
} catch (IOException e) {
fail(new AriaIOException(TAG,
fail(new AriaHTTPException(TAG,
String.format("文件下载失败,savePath: %s, url: %s", getEntity().getFilePath(),
getThreadConfig().url), e), true);
} finally {

@ -26,7 +26,7 @@ import com.arialyy.aria.core.loader.IThreadTaskBuilder;
import com.arialyy.aria.core.manager.ThreadTaskManager;
import com.arialyy.aria.core.task.IThreadTask;
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 java.util.List;
@ -62,7 +62,7 @@ final class HttpULoader extends AbsNormalLoader<UTaskWrapper> {
new Handler(looper, mStateManager.getHandlerCallback()));
if (tt == null || tt.isEmpty()) {
ALog.e(TAG, "创建线程任务失败");
getListener().onFail(false, new AriaIOException(TAG, "创建线程任务失败"));
getListener().onFail(false, new AriaHTTPException(TAG, "创建线程任务失败"));
return;
}

@ -18,9 +18,7 @@ package com.arialyy.aria.http.upload;
import android.text.TextUtils;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaHTTPException;
import com.arialyy.aria.http.BaseHttpThreadTaskAdapter;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
@ -56,7 +54,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
@Override protected void handlerThreadTask() {
File uploadFile = new File(getEntity().getFilePath());
if (!uploadFile.exists()) {
fail(new TaskException(TAG,
fail(new AriaHTTPException(TAG,
String.format("上传失败,文件不存在;filePath: %s, url: %s", getEntity().getFilePath(),
getEntity().getUrl())));
return;
@ -106,13 +104,13 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
getEntity().setResponseStr(finish(writer));
} catch (Exception e) {
e.printStackTrace();
fail(new TaskException(TAG,
fail(new AriaHTTPException(TAG,
String.format("上传失败,filePath: %s, url: %s", getEntity().getFilePath(),
getEntity().getUrl()), e));
}
}
private void fail(BaseException e1) {
private void fail(AriaHTTPException e1) {
try {
fail(e1, false);
if (mOutputStream != null) {
@ -222,7 +220,7 @@ final class HttpUThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
} else {
String msg = "response msg: " + mHttpConn.getResponseMessage() + ",code: " + status;
ALog.e(TAG, msg);
fail(new AriaIOException(TAG, msg), false);
fail(new AriaHTTPException(TAG, msg), false);
}
writer.flush();
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.wrapper.AbsTaskWrapper;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.exception.M3U8Exception;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaM3U8Exception;
import com.arialyy.aria.http.ConnectionHelp;
import com.arialyy.aria.http.HttpTaskOption;
import com.arialyy.aria.util.ALog;
@ -296,7 +295,7 @@ final public class M3U8InfoTask implements IInfoTask {
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
if (mCallback != null) {
mCallback.onFail(mEntity, new TaskException(TAG, "获取重定向链接失败"), false);
mCallback.onFail(mEntity, new AriaM3U8Exception(TAG, "获取重定向链接失败"), false);
}
return;
}
@ -354,7 +353,7 @@ final public class M3U8InfoTask implements IInfoTask {
}
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.download.DownloadEntity;
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaM3U8Exception;
import com.arialyy.aria.http.ConnectionHelp;
import com.arialyy.aria.http.HttpTaskOption;
import com.arialyy.aria.util.ALog;
@ -92,15 +91,15 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
handleConn(conn);
} catch (MalformedURLException e) {
fail(new TaskException(TAG,
fail(new AriaM3U8Exception(TAG,
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
} catch (IOException e) {
fail(new TaskException(TAG,
fail(new AriaM3U8Exception(TAG,
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), true);
} catch (Exception e) {
fail(new TaskException(TAG,
fail(new AriaM3U8Exception(TAG,
String.format("分片【%s】下载失败,filePath: %s, url: %s", getThreadRecord().threadId,
getThreadConfig().tempFile.getPath(), getEntity().getUrl()), e), false);
} finally {
@ -138,7 +137,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
|| code == 307) {
handleUrlReTurn(conn, conn.getHeaderField("Location"));
} else {
fail(new TaskException(TAG,
fail(new AriaM3U8Exception(TAG,
String.format("连接错误,http错误码:%s,url:%s", code, getThreadConfig().url)),
false);
}
@ -151,7 +150,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
private void handleUrlReTurn(HttpURLConnection conn, String newUrl) throws IOException {
ALog.d(TAG, "30x跳转,新url为【" + newUrl + "】");
if (TextUtils.isEmpty(newUrl) || newUrl.equalsIgnoreCase("null")) {
fail(new AriaIOException(TAG, "下载失败,重定向url为空"), false);
fail(new AriaM3U8Exception(TAG, "下载失败,重定向url为空"), false);
return;
}
@ -161,7 +160,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
}
if (!CheckUtil.checkUrl(newUrl)) {
fail(new AriaIOException(TAG, "下载失败,重定向url错误"), false);
fail(new AriaM3U8Exception(TAG, "下载失败,重定向url错误"), false);
return;
}
String cookies = conn.getHeaderField("Set-Cookie");
@ -199,7 +198,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
}
handleComplete();
} catch (IOException e) {
fail(new AriaIOException(TAG,
fail(new AriaM3U8Exception(TAG,
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
getThreadConfig().url), e), true);
} finally {
@ -242,7 +241,7 @@ public final class M3U8ThreadTaskAdapter extends AbsThreadTaskAdapter {
}
handleComplete();
} catch (IOException e) {
fail(new AriaIOException(TAG,
fail(new AriaM3U8Exception(TAG,
String.format("文件下载失败,savePath: %s, url: %s", getThreadConfig().tempFile.getPath(),
getThreadConfig().url), e), true);
} finally {

@ -32,9 +32,8 @@ import com.arialyy.aria.core.processor.ILiveTsUrlConverter;
import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.core.task.ThreadTask;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.M3U8Exception;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaM3U8Exception;
import com.arialyy.aria.exception.AriaException;
import com.arialyy.aria.m3u8.BaseM3U8Loader;
import com.arialyy.aria.m3u8.IdGenerator;
import com.arialyy.aria.m3u8.M3U8InfoTask;
@ -255,7 +254,7 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
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")) {
fail(new M3U8Exception(TAG, String.format("ts地址错误,url:%s", url)), false);
fail(new AriaM3U8Exception(TAG, String.format("ts地址错误,url:%s", url)), false);
return;
}
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);
handleComplete();
}
@ -296,13 +295,13 @@ final class M3U8LiveLoader extends BaseM3U8Loader {
if (generateIndexFile(true)) {
getListener().onComplete();
} else {
getListener().onFail(false, new TaskException(TAG, "创建索引文件失败"));
getListener().onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败"));
}
} else if (mM3U8Option.isMergeFile()) {
if (mergeFile()) {
getListener().onComplete();
} else {
getListener().onFail(false, new M3U8Exception(TAG, "合并文件失败"));
getListener().onFail(false, new AriaM3U8Exception(TAG, "合并文件失败"));
}
} else {
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.task.ThreadTask;
import com.arialyy.aria.core.wrapper.ITaskWrapper;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.M3U8Exception;
import com.arialyy.aria.exception.AriaException;
import com.arialyy.aria.exception.AriaM3U8Exception;
import com.arialyy.aria.m3u8.BaseM3U8Loader;
import com.arialyy.aria.m3u8.M3U8Listener;
import com.arialyy.aria.m3u8.M3U8TaskOption;
@ -517,10 +517,10 @@ final class M3U8VodLoader extends BaseM3U8Loader {
urls.addAll((Collection<? extends String>) info.obj);
}
if (urls.isEmpty()) {
fail(new M3U8Exception(TAG, "获取地址失败"), false);
fail(new AriaM3U8Exception(TAG, "获取地址失败"), false);
return;
} else if (!urls.get(0).startsWith("http")) {
fail(new M3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false);
fail(new AriaM3U8Exception(TAG, "地址错误,请使用IVodTsUrlConverter处理你的url信息"), false);
return;
}
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);
}
});
}
protected void fail(BaseException e, boolean needRetry) {
protected void fail(AriaException e, boolean needRetry) {
if (isBreak()) {
return;
}

@ -29,8 +29,8 @@ import com.arialyy.aria.core.loader.ILoaderVisitor;
import com.arialyy.aria.core.manager.ThreadTaskManager;
import com.arialyy.aria.core.processor.ITsMergeHandler;
import com.arialyy.aria.core.task.ThreadTask;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.TaskException;
import com.arialyy.aria.exception.AriaM3U8Exception;
import com.arialyy.aria.exception.AriaException;
import com.arialyy.aria.m3u8.BaseM3U8Loader;
import com.arialyy.aria.m3u8.M3U8Listener;
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()));
Bundle b = msg.getData();
listener.onFail(b.getBoolean(DATA_RETRY, true),
(BaseException) b.getSerializable(DATA_ERROR_INFO));
(AriaException) b.getSerializable(DATA_ERROR_INFO));
quitLooper();
}
break;
@ -148,7 +148,7 @@ public final class VodStateManager implements IThreadStateManager {
if (loader.generateIndexFile(false)) {
listener.onComplete();
} else {
listener.onFail(false, new TaskException(TAG, "创建索引文件失败"));
listener.onFail(false, new AriaM3U8Exception(TAG, "创建索引文件失败"));
}
} else if (m3U8Option.isMergeFile()) {
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.IThreadTaskBuilder;
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.CommonUtil;
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();
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.loader.IRecordHandler;
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.CommonUtil;
import com.arialyy.aria.util.NetUtils;
@ -113,7 +113,7 @@ final class SimpleSchedulers implements Handler.Callback {
|| loaderUtil.getLoader() == null // 如果获取不到文件信息,loader为空
|| loaderUtil.getEntity().getFailNum() > num) {
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(),
loaderUtil.getEntity().getUrl())));
mGState.countFailNum(loaderUtil.getKey());
@ -122,7 +122,7 @@ final class SimpleSchedulers implements Handler.Callback {
== mGState.getSubSize()) {
mQueue.clear();
mGState.isRunning = false;
mGState.listener.onFail(false, new TaskException(TAG,
mGState.listener.onFail(false, new AriaException(TAG,
String.format("任务组【%s】下载失败", mGState.getGroupHash())));
} else {
startNext();

@ -16,13 +16,14 @@
package com.arialyy.aria.core.listener;
import android.os.Handler;
import android.util.Log;
import com.arialyy.aria.core.common.AbsEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.inf.TaskSchedulerType;
import com.arialyy.aria.core.task.AbsTask;
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
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.CommonUtil;
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);
saveData(IEntity.STATE_FAIL, mEntity.getCurrentProgress());
handleSpeed(0);
@ -123,8 +124,8 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
sendInState2Target(ISchedulers.FAIL);
if (e != null) {
String error = ALog.getExceptionString(e);
ALog.w(TAG, error);
ErrorHelp.saveError(e.getTag(), "", error);
ALog.e(TAG, error);
ErrorHelp.saveError(e.getTag(), e.getMessage(), error);
}
}

@ -24,7 +24,7 @@ import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.inf.TaskSchedulerType;
import com.arialyy.aria.core.task.AbsTask;
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.CommonUtil;
import com.arialyy.aria.util.ErrorHelp;
@ -81,7 +81,7 @@ public class DownloadGroupListener
}
@Override
public void onSubFail(DownloadEntity subEntity, BaseException e) {
public void onSubFail(DownloadEntity subEntity, AriaException e) {
handleSubSpeed(subEntity, 0);
saveSubState(IEntity.STATE_FAIL, subEntity);
saveCurrentLocation();

@ -16,7 +16,7 @@
package com.arialyy.aria.core.listener;
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.
@ -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;
import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.exception.AriaException;
/**
* Created by Aria.Lao on 2017/7/18.
@ -64,5 +64,5 @@ public interface IEventListener {
* @param needRetry 是否需要重试{@code true} 需要
* @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.listener.IEventListener;
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.CommonUtil;
@ -135,7 +135,7 @@ public abstract class AbsNormalLoaderUtil implements IUtil {
return mListener;
}
protected void fail(BaseException e, boolean needRetry) {
protected void fail(AriaException e, boolean needRetry) {
if (isStop || isCancel) {
return;
}

@ -17,7 +17,7 @@ package com.arialyy.aria.core.loader;
import com.arialyy.aria.core.common.AbsEntity;
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 错误信息
*/
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.task.IThreadTask;
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 java.io.File;
@ -150,7 +150,7 @@ public class NormalLoader<T extends AbsTaskWrapper> extends AbsNormalLoader<T> {
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);
}
});

@ -22,7 +22,7 @@ import android.os.Message;
import com.arialyy.aria.core.TaskRecord;
import com.arialyy.aria.core.inf.IThreadStateManager;
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.FileUtil;
import java.io.File;
@ -91,7 +91,7 @@ public class NormalThreadStateManager implements IThreadStateManager {
if (isFail()) {
Bundle b = msg.getData();
mListener.onFail(b.getBoolean(DATA_RETRY, false),
(BaseException) b.getSerializable(DATA_ERROR_INFO));
(AriaException) b.getSerializable(DATA_ERROR_INFO));
quitLooper();
}
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.ThreadTask;
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.CommonUtil;
import java.io.File;
@ -207,7 +207,7 @@ public final class SubLoader implements ILoader, ILoaderVisitor {
handlerTask();
}
@Override public void onFail(AbsEntity entity, BaseException e, boolean needRetry) {
@Override public void onFail(AbsEntity entity, AriaException e, boolean needRetry) {
sendFailState(needRetry);
}
});

@ -255,7 +255,7 @@ public class ThreadTaskManager {
return;
}
} catch (Exception e) {
ALog.e(TAG, e);
ALog.e(TAG, "", e);
return;
}
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.config.BaseTaskConfig;
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.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) {
mObserver.updateFailState(ex, needRetry);
}

@ -17,7 +17,7 @@ package com.arialyy.aria.core.task;
import android.os.Bundle;
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 是否需要重试一般是网络错误才需要重试
*/
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.wrapper.AbsTaskWrapper;
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.BufferedRandomAccessFile;
import com.arialyy.aria.util.CommonUtil;
@ -323,7 +323,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
*
* @param needRetry 是否需要重试一般是网络错误才需要重试
*/
@Override public synchronized void updateFailState(BaseException e, boolean needRetry) {
@Override public synchronized void updateFailState(AriaException e, boolean needRetry) {
fail(mRangeProgress, e, needRetry);
}
@ -396,7 +396,7 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
*
* @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) {
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();
b.putBoolean(IThreadStateManager.DATA_RETRY, needRetry);
if (e != null) {

@ -15,14 +15,22 @@
*/
package com.arialyy.aria.exception;
public class AriaException extends BaseException {
private static final String ARIA_NET_EXCEPTION = "Aria Exception:";
public class AriaException extends Exception {
private String tag;
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) {
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;
}
}

@ -15,14 +15,14 @@
*/
package com.arialyy.aria.exception;
public class M3U8Exception extends BaseException{
private static final String M3U8_EXCEPTION = "M3U8 Exception:";
public class AriaFTPException extends AriaException {
private static final String FTP_EXCEPTION = "Aria SFTP Exception:";
public M3U8Exception(String tag, String message) {
super(tag, String.format("%s%s", M3U8_EXCEPTION, message));
public AriaFTPException(String tag, String 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);
}
}

@ -15,14 +15,14 @@
*/
package com.arialyy.aria.exception;
public class AriaLoginException extends BaseException{
private static final String ARIA_NET_EXCEPTION = "Aria Login Exception:";
public class AriaHTTPException extends AriaException {
private static final String HTTP_EXCEPTION = "Aria HTTP Exception:";
public AriaLoginException(String tag, String message) {
super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message));
public AriaHTTPException(String tag, String 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);
}
}

@ -15,14 +15,14 @@
*/
package com.arialyy.aria.exception;
public class AriaIOException extends BaseException{
private static final String ARIA_NET_EXCEPTION = "Aria Net Exception:";
public class AriaM3U8Exception extends AriaException {
private static final String M3U8_EXCEPTION = "Aria M3U8 Exception:";
public AriaIOException(String tag, String message) {
super(tag, String.format("%s%s", ARIA_NET_EXCEPTION, message));
public AriaM3U8Exception(String tag, String 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);
}
}

@ -15,17 +15,14 @@
*/
package com.arialyy.aria.exception;
/**
* 任务异常
*/
public class TaskException extends BaseException {
private static final String ARIA_TASK_EXCEPTION = "Aria Task Exception:";
public class AriaSFTPException extends AriaException {
private static final String SFTP_EXCEPTION = "Aria SFTP Exception:";
public TaskException(String tag, String detailMessage) {
super(tag, String.format("%s, %s", ARIA_TASK_EXCEPTION, detailMessage));
public AriaSFTPException(String tag, String message) {
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);
}
}

@ -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);
}
public static int e(String tag, Throwable e) {
String msg = getExceptionString(e);
ErrorHelp.saveError(tag, "", msg);
return println(Log.ERROR, tag, msg);
public static void e(String tag, String msg, Throwable e) {
Log.e(tag, msg, e);
}
/**

@ -534,7 +534,7 @@ public class CommonUtil {
try {
is = new FileInputStream(updateFile);
} catch (FileNotFoundException e) {
ALog.e(TAG, e);
e.printStackTrace();
return null;
}
@ -549,7 +549,7 @@ public class CommonUtil {
try {
digest = MessageDigest.getInstance("MD5");
} catch (NoSuchAlgorithmException e) {
ALog.e(TAG, e);
e.printStackTrace();
return null;
}
@ -571,7 +571,7 @@ public class CommonUtil {
try {
is.close();
} 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.ILoaderVisitor;
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.jcraft.jsch.JSchException;
import com.jcraft.jsch.Session;
@ -53,14 +54,11 @@ public abstract class AbsSFtpInfoTask<WP extends AbsTaskWrapper> implements IInf
}
getFileInfo(session);
} catch (JSchException e) {
e.printStackTrace();
fail(false, null);
fail(new AriaSFTPException(TAG, "jsch错误", e), false);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
fail(false, null);
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
} catch (SftpException e) {
e.printStackTrace();
fail(false, null);
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
}
}
@ -72,7 +70,7 @@ public abstract class AbsSFtpInfoTask<WP extends AbsTaskWrapper> implements IInf
return wrapper;
}
protected void fail(boolean needRetry, BaseException e) {
protected void fail(AriaException e, boolean 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.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.SFtpTaskOption;
import com.arialyy.aria.util.ALog;
@ -63,7 +63,7 @@ final class SFtpDInfoTask extends AbsSFtpInfoTask<DTaskWrapper> {
callback.onSucceed(getWrapper().getKey(), info);
} else {
callback.onFail(getWrapper().getEntity(),
new AriaException(TAG, String.format("文件不存在,remotePath:%s", remotePath)), false);
new AriaSFTPException(TAG, String.format("文件不存在,remotePath:%s", remotePath)), false);
}
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.manager.ThreadTaskManager;
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 java.io.File;
@ -140,7 +140,7 @@ final class SFtpDLoader extends AbsNormalLoader<DTaskWrapper> {
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);
}
});

@ -17,7 +17,7 @@ package com.arialyy.aria.sftp.download;
import com.arialyy.aria.core.common.SubThreadConfig;
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.util.ALog;
import com.arialyy.aria.util.CommonUtil;
@ -53,7 +53,7 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter {
@Override protected void handlerThreadTask() {
if (session == null) {
fail(new AriaException(TAG, "session 为空"), false);
fail(new AriaSFTPException(TAG, "session 为空"), false);
return;
}
try {
@ -74,18 +74,13 @@ final class SFtpDThreadTaskAdapter extends AbsThreadTaskAdapter {
CommonUtil.convertSFtpChar(charSet, option.getUrlEntity().remotePath);
download(remotePath);
} catch (SftpException e) {
e.printStackTrace();
ALog.e(TAG, "错误类型:" + e.id);
fail(null, false);
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
fail(null, false);
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
} catch (IOException e) {
e.printStackTrace();
fail(null, true);
fail(new AriaSFTPException(TAG, "", e), true);
} catch (JSchException e) {
e.printStackTrace();
fail(null, false);
fail(new AriaSFTPException(TAG, "jsch 错误", e), false);
} finally {
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.upload.UTaskWrapper;
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.jcraft.jsch.SftpATTRS;
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);
}
});

@ -18,7 +18,7 @@ package com.arialyy.aria.sftp.upload;
import com.arialyy.aria.core.common.SubThreadConfig;
import com.arialyy.aria.core.task.AbsThreadTaskAdapter;
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.util.ALog;
import com.arialyy.aria.util.BufferedRandomAccessFile;
@ -50,7 +50,7 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter {
@Override protected void handlerThreadTask() {
if (session == null) {
fail(new AriaException(TAG, "session 为空"), false);
fail(new AriaSFTPException(TAG, "session 为空"), false);
return;
}
try {
@ -74,19 +74,14 @@ final class SFtpUThreadTaskAdapter extends AbsThreadTaskAdapter {
}
channelSftp.cd(remotePath);
upload(remotePath);
} catch (JSchException e) {
e.printStackTrace();
fail(null, false);
} catch (SftpException e) {
fail(new AriaSFTPException(TAG, "sftp错误,错误类型:" + e.id, e), false);
} catch (UnsupportedEncodingException e) {
e.printStackTrace();
fail(null, false);
fail(new AriaSFTPException(TAG, "字符编码错误", e), false);
} catch (IOException e) {
e.printStackTrace();
fail(null, true);
} catch (SftpException e) {
e.printStackTrace();
fail(null, false);
ALog.d(TAG, "错误类型:" + e.id);
fail(new AriaSFTPException(TAG, "", e), true);
} catch (JSchException e) {
fail(new AriaSFTPException(TAG, "jsch 错误", e), false);
} finally {
channelSftp.disconnect();
}

@ -17,22 +17,21 @@ package com.arialyy.simple.core.download.group;
import android.os.Bundle;
import android.os.Environment;
import android.util.Log;
import android.view.View;
import com.arialyy.annotations.DownloadGroup;
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.processor.IHttpFileLenAdapter;
import com.arialyy.aria.core.download.DownloadEntity;
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.util.ALog;
import com.arialyy.frame.util.show.L;
import com.arialyy.frame.util.show.T;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityDownloadGroupBinding;
import com.arialyy.simple.widget.ProgressLayout;
import com.arialyy.simple.widget.SubStateLinearLayout;
import java.util.List;
import java.util.Map;
@ -57,42 +56,20 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
if (entity != null) {
mTaskId = entity.getId();
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,
"size = " + entity.getSubEntities().size() + "; len = " + entity.getConvertFileSize());
}else {
entity = new DownloadGroupEntity();
}
getBinding().pl.setInfo(entity);
mChildList.setOnItemClickListener(new SubStateLinearLayout.OnItemClickListener() {
@Override public void onItemClick(int position, View view) {
showPopupWindow(position);
}
});
}
private void showPopupWindow(int position) {
ChildHandleDialog dialog =
new ChildHandleDialog(this, mUrls, mChildList.getSubData().get(position));
dialog.show(getSupportFragmentManager(), "sub_dialog");
}
@Override protected int setLayoutId() {
return R.layout.activity_download_group;
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.start:
if (mTaskId == -1) {
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
@Override public void create(View v, AbsEntity entity) {
mTaskId = Aria.download(this)
.loadGroup(mUrls)
.setDirPath(
@ -105,22 +82,31 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
//.setFileSize(114981416)
//.updateUrls(temp)
.create();
getBinding().setStateStr(getString(R.string.stop));
break;
}
if (Aria.download(this).loadGroup(mTaskId).isRunning()) {
@Override public void stop(View v, AbsEntity entity) {
Aria.download(this).loadGroup(mTaskId).stop();
getBinding().setStateStr(getString(R.string.resume));
} else {
}
@Override public void resume(View v, AbsEntity entity) {
Aria.download(this).loadGroup(mTaskId).resume();
getBinding().setStateStr(getString(R.string.stop));
}
break;
case R.id.cancel:
@Override public void cancel(View v, AbsEntity entity) {
Aria.download(this).loadGroup(mTaskId).cancel(true);
mTaskId = -1;
break;
}
});
}
private void showPopupWindow(int position) {
ChildHandleDialog dialog =
new ChildHandleDialog(this, mUrls, mChildList.getSubData().get(position));
dialog.show(getSupportFragmentManager(), "sub_dialog");
}
@Override protected int setLayoutId() {
return R.layout.activity_download_group;
}
private HttpOption getHttpOption() {
@ -130,70 +116,62 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
}
@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) {
L.d(TAG, "group pre, p = " + task.getPercent());
ALog.d(TAG, "group pre, p = " + task.getPercent());
}
@DownloadGroup.onTaskPre() protected void onTaskPre(DownloadGroupTask task) {
L.d(TAG, "group task pre, p = " + task.getPercent());
getBinding().setFileSize(task.getConvertFileSize());
ALog.d(TAG, "group task pre, p = " + task.getPercent());
if (mChildList.getSubData().size() <= 0) {
mChildList.addData(task.getEntity().getSubEntities());
}
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskStart() void taskStart(DownloadGroupTask task) {
getBinding().setFileSize(task.getConvertFileSize());
L.d(TAG, "group task create, p = " + task.getPercent());
ALog.d(TAG, "group task create, p = " + task.getPercent());
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskRunning() protected void running(DownloadGroupTask task) {
Log.d(TAG, "group running, p = "
ALog.d(TAG, "group running, p = "
+ task.getPercent()
+ ", speed = "
+ task.getConvertSpeed()
+ ", current_p = "
+ task.getCurrentProgress());
getBinding().setProgress(task.getPercent());
getBinding().setSpeed(task.getConvertSpeed());
getBinding().setTimeLeft(task.getConvertTimeLeft());
getBinding().pl.setInfo(task.getEntity());
//Log.d(TAG, "sub_len = " + task.getEntity().getSubEntities().size());
mChildList.updateChildProgress(task.getEntity().getSubEntities());
}
@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) {
L.d(TAG, "group task stop");
getBinding().setSpeed("");
getBinding().setStateStr(getString(R.string.start));
ALog.d(TAG, "group task stop");
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
L.d(TAG, "group task cancel");
getBinding().setSpeed("");
getBinding().setProgress(0);
getBinding().setStateStr(getString(R.string.start));
ALog.d(TAG, "group task cancel");
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskFail() void taskFail(DownloadGroupTask task) {
L.d(TAG, "group task fail");
getBinding().setStateStr(getString(R.string.resume));
getBinding().setSpeed("");
ALog.d(TAG, "group task fail");
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) {
getBinding().setProgress(100);
getBinding().setSpeed("");
mChildList.updateChildProgress(task.getEntity().getSubEntities());
T.showShort(this, "任务组下载完成");
L.d(TAG, "任务组下载完成");
getBinding().setStateStr(getString(R.string.start));
ALog.d(TAG, "任务组下载完成");
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onSubTaskRunning void onSubTaskRunning(DownloadGroupTask groupTask,

@ -20,18 +20,17 @@ import android.os.Environment;
import android.view.View;
import com.arialyy.annotations.DownloadGroup;
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.download.DownloadGroupEntity;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.task.DownloadGroupTask;
import com.arialyy.aria.util.ALog;
import com.arialyy.frame.util.show.L;
import com.arialyy.frame.util.show.T;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityDownloadGroupBinding;
import com.arialyy.simple.widget.ProgressLayout;
import com.arialyy.simple.widget.SubStateLinearLayout;
import java.security.AlgorithmConstraints;
/**
* Created by lyy on 2017/7/6.
@ -52,29 +51,10 @@ public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBi
if (entity != null) {
mTaskId = entity.getId();
mChildList.addData(entity.getSubEntities());
getBinding().setFileSize(entity.getConvertFileSize());
if (entity.getState() == IEntity.STATE_RUNNING) {
getBinding().setStateStr(getString(R.string.stop));
} else {
getBinding().setStateStr(getString(R.string.start));
getBinding().pl.setInfo(entity);
}
if (entity.getFileSize() == 0) {
getBinding().setProgress(0);
} else {
getBinding().setProgress(entity.isComplete() ? 100
: (int) (entity.getCurrentProgress() * 100 / entity.getFileSize()));
}
}
}
@Override protected int setLayoutId() {
return R.layout.activity_download_group;
}
public void onClick(View view) {
switch (view.getId()) {
case R.id.start:
if (mTaskId == -1) {
getBinding().pl.setBtListener(new ProgressLayout.OnProgressLayoutBtListener() {
@Override public void create(View v, AbsEntity entity) {
mTaskId = Aria.download(this)
.loadFtpDir(dir)
.setDirPath(
@ -83,25 +63,28 @@ public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBi
.option(getFtpOption())
.ignoreFilePathOccupy()
.create();
getBinding().setStateStr(getString(R.string.stop));
break;
}
if (Aria.download(this).loadFtpDir(mTaskId).isRunning()) {
@Override public void stop(View v, AbsEntity entity) {
Aria.download(this).loadFtpDir(mTaskId).stop();
getBinding().setStateStr(getString(R.string.resume));
} else {
}
@Override public void resume(View v, AbsEntity entity) {
Aria.download(this)
.loadFtpDir(mTaskId)
.option(getFtpOption())
.resume();
getBinding().setStateStr(getString(R.string.stop));
}
break;
case R.id.cancel:
@Override public void cancel(View v, AbsEntity entity) {
Aria.download(this).loadFtpDir(mTaskId).cancel();
mTaskId = -1;
break;
}
});
}
@Override protected int setLayoutId() {
return R.layout.activity_download_group;
}
private FtpOption getFtpOption() {
@ -110,52 +93,53 @@ public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBi
return option;
}
@DownloadGroup.onPre() protected void onPre(DownloadGroupTask task) {
L.d(TAG, "group pre");
@DownloadGroup.onPre protected void onPre(DownloadGroupTask task) {
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) {
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());
getBinding().setProgress(task.getPercent());
getBinding().setSpeed(task.getConvertSpeed());
getBinding().pl.setInfo(task.getEntity());
mChildList.updateChildProgress(task.getEntity().getSubEntities());
}
@DownloadGroup.onTaskResume() void taskResume(DownloadGroupTask task) {
@DownloadGroup.onTaskResume void taskResume(DownloadGroupTask task) {
ALog.d(TAG, "ftp dir resume");
}
@DownloadGroup.onTaskStop() void taskStop(DownloadGroupTask task) {
getBinding().setSpeed("");
getBinding().setStateStr(getString(R.string.start));
@DownloadGroup.onTaskStop void taskStop(DownloadGroupTask task) {
ALog.d(TAG, "ftp dir stop");
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskCancel() void taskCancel(DownloadGroupTask task) {
getBinding().setSpeed("");
getBinding().setProgress(0);
getBinding().setStateStr(getString(R.string.start));
@DownloadGroup.onTaskCancel void taskCancel(DownloadGroupTask task) {
ALog.d(TAG, "ftp dir cancel");
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskFail() void taskFail(DownloadGroupTask task) {
L.d(TAG, "group task fail");
@DownloadGroup.onTaskFail void taskFail(DownloadGroupTask task) {
ALog.d(TAG, "group task fail");
getBinding().pl.setInfo(task.getEntity());
}
@DownloadGroup.onTaskComplete() void taskComplete(DownloadGroupTask task) {
getBinding().setProgress(100);
@DownloadGroup.onTaskComplete void taskComplete(DownloadGroupTask task) {
mChildList.updateChildProgress(task.getEntity().getSubEntities());
getBinding().setStateStr(getString(R.string.re_start));
getBinding().setSpeed("");
getBinding().pl.setInfo(task.getEntity());
T.showShort(this, "任务组下载完成");
L.d(TAG, "任务组下载完成");
ALog.d(TAG, "任务组下载完成");
}
}

@ -1,30 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<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>
<layout xmlns:android="http://schemas.android.com/apk/res/android">
<RelativeLayout
android:layout_width="match_parent"
@ -34,24 +9,19 @@
<include layout="@layout/layout_bar" />
<include
layout="@layout/layout_content_single"
android:id="@+id/content"
android:layout_width="wrap_content"
<com.arialyy.simple.widget.ProgressLayout
android:id="@+id/pl"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_below="@+id/toolbar"
bind:fileSize="@{fileSize}"
bind:progress="@{progress}"
bind:speed="@{speed}"
bind:stateStr="@{stateStr}"
bind:timeLeft="@{timeLeft}"
android:layout_margin="16dp"
/>
<com.arialyy.simple.widget.SubStateLinearLayout
android:id="@+id/child_list"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:layout_below="@+id/content"
android:layout_below="@+id/pl"
android:paddingLeft="16dp"
android:paddingRight="16dp"
/>

@ -53,6 +53,7 @@
android:layout_alignTop="@+id/speed_or_state"
android:layout_alignParentEnd="true"
android:layout_alignParentRight="true"
android:text="-/-"
android:textSize="@dimen/text_size_smallest"
tools:ignore="RelativeOverlap"
/>

Loading…
Cancel
Save