Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
a6ecaadea4 | ||
|
|
c1b1cc1390 | ||
|
|
e8c5a9f08b | ||
|
|
d6993eb159 | ||
|
|
25485538e6 |
@@ -401,7 +401,7 @@ import java.util.concurrent.ConcurrentHashMap;
|
|||||||
return false;
|
return false;
|
||||||
} else {
|
} else {
|
||||||
String parentName = parentClass.getName();
|
String parentName = parentClass.getName();
|
||||||
if (mFragmentClassName.contains(parentName)) {
|
if (mDialogFragmentClassName.contains(parentName)) {
|
||||||
return true;
|
return true;
|
||||||
} else {
|
} else {
|
||||||
return isDialogFragment(parentClass);
|
return isDialogFragment(parentClass);
|
||||||
|
|||||||
11
DEV_LOG.md
11
DEV_LOG.md
@@ -1,5 +1,12 @@
|
|||||||
## 开发日志
|
## 开发日志
|
||||||
+ v_3.7
|
+ v_3.7.4 (2019/11/2)
|
||||||
|
- 修复一个class被莫名改变的问题
|
||||||
|
- 修复非分块模式下导致的一个下载失败问题
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/493
|
||||||
|
+ v_3.7.3 (2019/10/31)
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/495
|
||||||
|
- fix bug https://github.com/AriaLyy/Aria/issues/496
|
||||||
|
+ v_3.7.2 (2019/10/28)
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/450
|
- fix bug https://github.com/AriaLyy/Aria/issues/450
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/466
|
- fix bug https://github.com/AriaLyy/Aria/issues/466
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/454
|
- fix bug https://github.com/AriaLyy/Aria/issues/454
|
||||||
@@ -10,7 +17,7 @@
|
|||||||
- fix bug https://github.com/AriaLyy/Aria/issues/482
|
- fix bug https://github.com/AriaLyy/Aria/issues/482
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/473
|
- fix bug https://github.com/AriaLyy/Aria/issues/473
|
||||||
- 移除隐藏api的反射 https://github.com/AriaLyy/Aria/issues/456
|
- 移除隐藏api的反射 https://github.com/AriaLyy/Aria/issues/456
|
||||||
- 新增ftp免证书登陆功能h ttps://github.com/AriaLyy/Aria/issues/455
|
- 新增ftp免证书登陆功能 https://github.com/AriaLyy/Aria/issues/455
|
||||||
- 适配androidX
|
- 适配androidX
|
||||||
- 修复组合任务,恢复下载,会出现进度显示为0的问题
|
- 修复组合任务,恢复下载,会出现进度显示为0的问题
|
||||||
- m3u8点播下载新增创建ts索引功能
|
- m3u8点播下载新增创建ts索引功能
|
||||||
|
|||||||
@@ -27,7 +27,6 @@ dependencies {
|
|||||||
|
|
||||||
implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}"
|
implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}"
|
||||||
|
|
||||||
// implementation project(path: ':AriaFtpPlug')
|
|
||||||
implementation project(path: ':PublicComponent')
|
implementation project(path: ':PublicComponent')
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -53,7 +53,7 @@ import javax.net.ssl.SSLContext;
|
|||||||
public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>>
|
public abstract class AbsFtpInfoThread<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>>
|
||||||
implements Runnable {
|
implements Runnable {
|
||||||
|
|
||||||
private final String TAG = "AbsFtpInfoThread";
|
private final String TAG = CommonUtil.getClassName(getClass());
|
||||||
protected ENTITY mEntity;
|
protected ENTITY mEntity;
|
||||||
protected TASK_WRAPPER mTaskWrapper;
|
protected TASK_WRAPPER mTaskWrapper;
|
||||||
protected FtpTaskOption mTaskOption;
|
protected FtpTaskOption mTaskOption;
|
||||||
|
|||||||
@@ -21,9 +21,8 @@ import com.arialyy.aria.core.common.AbsRecordHandlerAdapter;
|
|||||||
import com.arialyy.aria.core.common.RecordHelper;
|
import com.arialyy.aria.core.common.RecordHelper;
|
||||||
import com.arialyy.aria.core.config.Configuration;
|
import com.arialyy.aria.core.config.Configuration;
|
||||||
import com.arialyy.aria.core.download.DownloadEntity;
|
import com.arialyy.aria.core.download.DownloadEntity;
|
||||||
import com.arialyy.aria.core.common.AbsNormalEntity;
|
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
|
||||||
import com.arialyy.aria.core.inf.IRecordHandler;
|
import com.arialyy.aria.core.inf.IRecordHandler;
|
||||||
|
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.util.RecordUtil;
|
import com.arialyy.aria.util.RecordUtil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -40,8 +39,12 @@ public class FtpRecordAdapter extends AbsRecordHandlerAdapter {
|
|||||||
|
|
||||||
@Override public void handlerTaskRecord(TaskRecord record) {
|
@Override public void handlerTaskRecord(TaskRecord record) {
|
||||||
RecordHelper helper = new RecordHelper(getWrapper(), record);
|
RecordHelper helper = new RecordHelper(getWrapper(), record);
|
||||||
if (record.isBlock) {
|
if (getWrapper().isSupportBP()) {
|
||||||
helper.handleBlockRecord();
|
if (record.isBlock) {
|
||||||
|
helper.handleBlockRecord();
|
||||||
|
} else {
|
||||||
|
helper.handleMutilRecord();
|
||||||
|
}
|
||||||
} else if (record.threadNum == 1) {
|
} else if (record.threadNum == 1) {
|
||||||
helper.handleSingleThreadRecord();
|
helper.handleSingleThreadRecord();
|
||||||
}
|
}
|
||||||
@@ -104,6 +107,4 @@ public class FtpRecordAdapter extends AbsRecordHandlerAdapter {
|
|||||||
return 1;
|
return 1;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">AriaFtpComponent</string>
|
|
||||||
</resources>
|
|
||||||
@@ -38,15 +38,19 @@ public class HttpRecordAdapter extends AbsRecordHandlerAdapter {
|
|||||||
|
|
||||||
@Override public void onPre() {
|
@Override public void onPre() {
|
||||||
super.onPre();
|
super.onPre();
|
||||||
if (getWrapper().getRequestType() == ITaskWrapper.U_HTTP){
|
if (getWrapper().getRequestType() == ITaskWrapper.U_HTTP) {
|
||||||
RecordUtil.delTaskRecord(getEntity().getFilePath(), IRecordHandler.TYPE_UPLOAD);
|
RecordUtil.delTaskRecord(getEntity().getFilePath(), IRecordHandler.TYPE_UPLOAD);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public void handlerTaskRecord(TaskRecord record) {
|
@Override public void handlerTaskRecord(TaskRecord record) {
|
||||||
RecordHelper helper = new RecordHelper(getWrapper(), record);
|
RecordHelper helper = new RecordHelper(getWrapper(), record);
|
||||||
if (record.isBlock) {
|
if (getWrapper().isSupportBP()) {
|
||||||
helper.handleBlockRecord();
|
if (record.isBlock) {
|
||||||
|
helper.handleBlockRecord();
|
||||||
|
} else {
|
||||||
|
helper.handleMutilRecord();
|
||||||
|
}
|
||||||
} else if (!getWrapper().isSupportBP()) {
|
} else if (!getWrapper().isSupportBP()) {
|
||||||
helper.handleNoSupportBPRecord();
|
helper.handleNoSupportBPRecord();
|
||||||
} else {
|
} else {
|
||||||
@@ -81,7 +85,8 @@ public class HttpRecordAdapter extends AbsRecordHandlerAdapter {
|
|||||||
record.threadNum = threadNum;
|
record.threadNum = threadNum;
|
||||||
|
|
||||||
int requestType = getWrapper().getRequestType();
|
int requestType = getWrapper().getRequestType();
|
||||||
if (requestType == ITaskWrapper.D_FTP || requestType == ITaskWrapper.D_FTP_DIR) {
|
if (requestType == ITaskWrapper.D_FTP || requestType == ITaskWrapper.D_FTP_DIR
|
||||||
|
|| requestType == ITaskWrapper.D_HTTP || requestType == ITaskWrapper.DG_HTTP) {
|
||||||
record.isBlock = threadNum > 1 && Configuration.getInstance().downloadCfg.isUseBlock();
|
record.isBlock = threadNum > 1 && Configuration.getInstance().downloadCfg.isUseBlock();
|
||||||
// 线程数为1,或者使用了分块,则认为是使用动态长度文件
|
// 线程数为1,或者使用了分块,则认为是使用动态长度文件
|
||||||
record.isOpenDynamicFile = threadNum == 1 || record.isBlock;
|
record.isOpenDynamicFile = threadNum == 1 || record.isBlock;
|
||||||
|
|||||||
@@ -28,6 +28,7 @@ import com.arialyy.aria.core.wrapper.ITaskWrapper;
|
|||||||
import com.arialyy.aria.http.HttpRecordAdapter;
|
import com.arialyy.aria.http.HttpRecordAdapter;
|
||||||
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.FileUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
|
|
||||||
@@ -43,16 +44,15 @@ final class HttpDLoaderAdapter extends AbsNormalLoaderAdapter {
|
|||||||
@Override public boolean handleNewTask(TaskRecord record, int totalThreadNum) {
|
@Override public boolean handleNewTask(TaskRecord record, int totalThreadNum) {
|
||||||
if (!record.isBlock) {
|
if (!record.isBlock) {
|
||||||
if (getTempFile().exists()) {
|
if (getTempFile().exists()) {
|
||||||
getTempFile().delete();
|
FileUtil.deleteFile(getTempFile());
|
||||||
}
|
}
|
||||||
//CommonUtil.createFile(mTempFile.getPath());
|
|
||||||
} else {
|
} else {
|
||||||
for (int i = 0; i < totalThreadNum; i++) {
|
for (int i = 0; i < totalThreadNum; i++) {
|
||||||
File blockFile =
|
File blockFile =
|
||||||
new File(String.format(IRecordHandler.SUB_PATH, getTempFile().getPath(), i));
|
new File(String.format(IRecordHandler.SUB_PATH, getTempFile().getPath(), i));
|
||||||
if (blockFile.exists()) {
|
if (blockFile.exists()) {
|
||||||
ALog.d(TAG, String.format("分块【%s】已经存在,将删除该分块", i));
|
ALog.d(TAG, String.format("分块【%s】已经存在,将删除该分块", i));
|
||||||
blockFile.delete();
|
FileUtil.deleteFile(blockFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -15,13 +15,13 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.http.download;
|
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.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.AriaIOException;
|
||||||
import com.arialyy.aria.exception.TaskException;
|
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.core.common.RequestEnum;
|
|
||||||
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 java.io.BufferedInputStream;
|
import java.io.BufferedInputStream;
|
||||||
@@ -123,6 +123,10 @@ final class HttpDThreadTaskAdapter extends BaseHttpThreadTaskAdapter {
|
|||||||
fail(new TaskException(TAG,
|
fail(new TaskException(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) {
|
||||||
|
fail(new TaskException(TAG,
|
||||||
|
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||||
|
getEntity().getFilePath(), getEntity().getUrl()), e), false);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
fail(new TaskException(TAG,
|
fail(new TaskException(TAG,
|
||||||
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
String.format("任务【%s】下载失败,filePath: %s, url: %s", getFileName(),
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">HttpComponent</string>
|
|
||||||
</resources>
|
|
||||||
@@ -355,7 +355,7 @@ final public class M3U8InfoThread implements Runnable {
|
|||||||
File keyF = new File(info.keyPath);
|
File keyF = new File(info.keyPath);
|
||||||
if (!keyF.exists()) {
|
if (!keyF.exists()) {
|
||||||
ALog.d(TAG, "密钥不存在,下载密钥");
|
ALog.d(TAG, "密钥不存在,下载密钥");
|
||||||
FileUtil.createFile(keyF.getPath());
|
FileUtil.createFile(keyF);
|
||||||
} else {
|
} else {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -150,7 +150,7 @@ public class M3U8LiveLoader extends BaseM3U8Loader {
|
|||||||
config.stateHandler = mStateHandler;
|
config.stateHandler = mStateHandler;
|
||||||
|
|
||||||
if (!config.tempFile.exists()) {
|
if (!config.tempFile.exists()) {
|
||||||
FileUtil.createFile(config.tempFile.getPath());
|
FileUtil.createFile(config.tempFile);
|
||||||
}
|
}
|
||||||
ThreadTask threadTask = new ThreadTask(config);
|
ThreadTask threadTask = new ThreadTask(config);
|
||||||
M3U8ThreadTaskAdapter adapter = new M3U8ThreadTaskAdapter(config);
|
M3U8ThreadTaskAdapter adapter = new M3U8ThreadTaskAdapter(config);
|
||||||
|
|||||||
@@ -434,7 +434,7 @@ public class M3U8VodLoader extends BaseM3U8Loader {
|
|||||||
config.stateHandler = mStateHandler;
|
config.stateHandler = mStateHandler;
|
||||||
config.peerIndex = index;
|
config.peerIndex = index;
|
||||||
if (!config.tempFile.exists()) {
|
if (!config.tempFile.exists()) {
|
||||||
FileUtil.createFile(config.tempFile.getPath());
|
FileUtil.createFile(config.tempFile);
|
||||||
}
|
}
|
||||||
ThreadTask threadTask = new ThreadTask(config);
|
ThreadTask threadTask = new ThreadTask(config);
|
||||||
M3U8ThreadTaskAdapter adapter = new M3U8ThreadTaskAdapter(config);
|
M3U8ThreadTaskAdapter adapter = new M3U8ThreadTaskAdapter(config);
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">M3U8Component</string>
|
|
||||||
</resources>
|
|
||||||
@@ -43,6 +43,8 @@ public class AriaConfig {
|
|||||||
|
|
||||||
public static final String DOWNLOAD_TEMP_DIR = "/Aria/temp/download/";
|
public static final String DOWNLOAD_TEMP_DIR = "/Aria/temp/download/";
|
||||||
public static final String UPLOAD_TEMP_DIR = "/Aria/temp/upload/";
|
public static final String UPLOAD_TEMP_DIR = "/Aria/temp/upload/";
|
||||||
|
public static final String IGNORE_CLASS_KLASS = "shadow$_klass_";
|
||||||
|
public static final String IGNORE_CLASS_MONITOR = "shadow$_monitor_";
|
||||||
|
|
||||||
private static volatile AriaConfig Instance;
|
private static volatile AriaConfig Instance;
|
||||||
private static Context APP;
|
private static Context APP;
|
||||||
|
|||||||
@@ -86,8 +86,8 @@ public class RecordHandler implements IRecordHandler {
|
|||||||
mTaskRecord.threadNum = mAdapter.initTaskThreadNum();
|
mTaskRecord.threadNum = mAdapter.initTaskThreadNum();
|
||||||
initRecord(false);
|
initRecord(false);
|
||||||
}
|
}
|
||||||
mAdapter.handlerTaskRecord(mTaskRecord);
|
|
||||||
}
|
}
|
||||||
|
mAdapter.handlerTaskRecord(mTaskRecord);
|
||||||
}
|
}
|
||||||
saveRecord();
|
saveRecord();
|
||||||
return mTaskRecord;
|
return mTaskRecord;
|
||||||
@@ -145,7 +145,7 @@ public class RecordHandler implements IRecordHandler {
|
|||||||
}
|
}
|
||||||
mTaskRecord.threadRecords.add(tRecord);
|
mTaskRecord.threadRecords.add(tRecord);
|
||||||
}
|
}
|
||||||
mConfigFile.delete();
|
FileUtil.deleteFile(mConfigFile);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -20,7 +20,10 @@ import com.arialyy.aria.core.ThreadRecord;
|
|||||||
import com.arialyy.aria.core.inf.IRecordHandler;
|
import com.arialyy.aria.core.inf.IRecordHandler;
|
||||||
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
|
import com.arialyy.aria.util.BufferedRandomAccessFile;
|
||||||
|
import com.arialyy.aria.util.FileUtil;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 任务记录帮助类,用于处理统一的逻辑
|
* 任务记录帮助类,用于处理统一的逻辑
|
||||||
@@ -39,6 +42,44 @@ public class RecordHelper {
|
|||||||
mTaskRecord = record;
|
mTaskRecord = record;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 处理非分块的,多线程任务
|
||||||
|
*/
|
||||||
|
public void handleMutilRecord() {
|
||||||
|
// 默认线程分块长度
|
||||||
|
long blockSize = mWrapper.getEntity().getFileSize() / mTaskRecord.threadRecords.size();
|
||||||
|
File temp = new File(mTaskRecord.filePath);
|
||||||
|
boolean fileExists = false;
|
||||||
|
if (!temp.exists()) {
|
||||||
|
BufferedRandomAccessFile tempFile = null;
|
||||||
|
try {
|
||||||
|
tempFile = new BufferedRandomAccessFile(temp, "rw");
|
||||||
|
tempFile.setLength(mWrapper.getEntity().getFileSize());
|
||||||
|
} catch (IOException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
} else {
|
||||||
|
fileExists = true;
|
||||||
|
}
|
||||||
|
// 处理文件被删除的情况
|
||||||
|
if (fileExists) {
|
||||||
|
for (int i = 0; i < mTaskRecord.threadNum; i++) {
|
||||||
|
long startL = i * blockSize, endL = (i + 1) * blockSize;
|
||||||
|
ThreadRecord tr = mTaskRecord.threadRecords.get(i);
|
||||||
|
tr.startLocation = startL;
|
||||||
|
tr.isComplete = false;
|
||||||
|
|
||||||
|
//最后一个线程的结束位置即为文件的总长度
|
||||||
|
if (tr.threadId == (mTaskRecord.threadNum - 1)) {
|
||||||
|
endL = mWrapper.getEntity().getFileSize();
|
||||||
|
}
|
||||||
|
tr.endLocation = endL;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
mWrapper.setNewTask(false);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 处理分块任务的记录,分块文件(blockFileLen)长度必须需要小于等于线程区间(threadRectLen)的长度
|
* 处理分块任务的记录,分块文件(blockFileLen)长度必须需要小于等于线程区间(threadRectLen)的长度
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -48,7 +48,7 @@ public class ThreadTaskManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private ThreadTaskManager() {
|
private ThreadTaskManager() {
|
||||||
mExePool = Executors.newFixedThreadPool(Runtime.getRuntime().availableProcessors());
|
mExePool = Executors.newCachedThreadPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -367,8 +367,8 @@ public class ThreadTask implements IThreadTask, IThreadTaskObserver {
|
|||||||
|| isNotNetRetry) && !isBreak()) {
|
|| isNotNetRetry) && !isBreak()) {
|
||||||
ALog.w(TAG, String.format("ts切片【%s】正在重试", getFileName()));
|
ALog.w(TAG, String.format("ts切片【%s】正在重试", getFileName()));
|
||||||
mFailTimes++;
|
mFailTimes++;
|
||||||
mConfig.tempFile.delete();
|
FileUtil.deleteFile(mConfig.tempFile);
|
||||||
FileUtil.createFile(mConfig.tempFile.getPath());
|
FileUtil.createFile(mConfig.tempFile);
|
||||||
ThreadTaskManager.getInstance().retryThread(this);
|
ThreadTaskManager.getInstance().retryThread(this);
|
||||||
} else {
|
} else {
|
||||||
sendFailMsg(null);
|
sendFailMsg(null);
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package com.arialyy.aria.orm;
|
package com.arialyy.aria.orm;
|
||||||
|
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
|
import com.arialyy.aria.core.AriaConfig;
|
||||||
import com.arialyy.aria.orm.annotation.Default;
|
import com.arialyy.aria.orm.annotation.Default;
|
||||||
import com.arialyy.aria.orm.annotation.Foreign;
|
import com.arialyy.aria.orm.annotation.Foreign;
|
||||||
import com.arialyy.aria.orm.annotation.Ignore;
|
import com.arialyy.aria.orm.annotation.Ignore;
|
||||||
@@ -178,7 +179,8 @@ final class SqlUtil {
|
|||||||
int modifiers = field.getModifiers();
|
int modifiers = field.getModifiers();
|
||||||
String fieldName = field.getName();
|
String fieldName = field.getName();
|
||||||
return (ignore != null && ignore.value()) || fieldName.equals("rowID") || fieldName.equals(
|
return (ignore != null && ignore.value()) || fieldName.equals("rowID") || fieldName.equals(
|
||||||
"shadow$_klass_") || fieldName.equals("shadow$_monitor_") || field.isSynthetic() || Modifier
|
AriaConfig.IGNORE_CLASS_KLASS) || fieldName.equals(AriaConfig.IGNORE_CLASS_MONITOR)
|
||||||
|
|| field.isSynthetic() || Modifier
|
||||||
.isStatic(modifiers) || Modifier.isFinal(modifiers);
|
.isStatic(modifiers) || Modifier.isFinal(modifiers);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -626,6 +626,16 @@ public class CommonUtil {
|
|||||||
Collections.addAll(fields, personClazz.getDeclaredFields());
|
Collections.addAll(fields, personClazz.getDeclaredFields());
|
||||||
}
|
}
|
||||||
Collections.addAll(fields, clazz.getDeclaredFields());
|
Collections.addAll(fields, clazz.getDeclaredFields());
|
||||||
|
List<Field> ignore = new ArrayList<>();
|
||||||
|
for (Field field : fields) {
|
||||||
|
if (field.getName().equals(AriaConfig.IGNORE_CLASS_KLASS) || field.getName()
|
||||||
|
.equals(AriaConfig.IGNORE_CLASS_MONITOR)) {
|
||||||
|
ignore.add(field);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!ignore.isEmpty()){
|
||||||
|
fields.removeAll(ignore);
|
||||||
|
}
|
||||||
return fields;
|
return fields;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -79,7 +79,7 @@ public class ErrorHelp {
|
|||||||
try {
|
try {
|
||||||
File file = new File(getLogPath());
|
File file = new File(getLogPath());
|
||||||
if (!file.exists()) {
|
if (!file.exists()) {
|
||||||
FileUtil.createFile(file.getPath());
|
FileUtil.createFile(file);
|
||||||
}
|
}
|
||||||
writer = new PrintWriter(new FileWriter(file.getPath(), true));
|
writer = new PrintWriter(new FileWriter(file.getPath(), true));
|
||||||
writer.append(stringBuffer);
|
writer.append(stringBuffer);
|
||||||
|
|||||||
@@ -86,22 +86,23 @@ public class FileUtil {
|
|||||||
ALog.e(TAG, "文件路径不能为null");
|
ALog.e(TAG, "文件路径不能为null");
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
File file = new File(path);
|
return createFile(new File(path));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建文件 当文件不存在的时候就创建一个文件。 如果文件存在,先删除原文件,然后重新创建一个新文件
|
||||||
|
*
|
||||||
|
* @return {@code true} 创建成功、{@code false} 创建失败
|
||||||
|
*/
|
||||||
|
public static boolean createFile(File file) {
|
||||||
if (file.getParentFile() == null || !file.getParentFile().exists()) {
|
if (file.getParentFile() == null || !file.getParentFile().exists()) {
|
||||||
ALog.d(TAG, "目标文件所在路径不存在,准备创建……");
|
ALog.d(TAG, "目标文件所在路径不存在,准备创建……");
|
||||||
if (!createDir(file.getParent())) {
|
if (!createDir(file.getParent())) {
|
||||||
ALog.d(TAG, "创建目录文件所在的目录失败!文件路径【" + path + "】");
|
ALog.d(TAG, "创建目录文件所在的目录失败!文件路径【" + file.getPath() + "】");
|
||||||
}
|
|
||||||
}
|
|
||||||
// 创建目标文件
|
|
||||||
if (file.exists()) {
|
|
||||||
final File to = new File(file.getAbsolutePath() + System.currentTimeMillis());
|
|
||||||
if (file.renameTo(to)) {
|
|
||||||
to.delete();
|
|
||||||
} else {
|
|
||||||
file.delete();
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
// 文件存在,删除文件
|
||||||
|
deleteFile(file);
|
||||||
try {
|
try {
|
||||||
if (file.createNewFile()) {
|
if (file.createNewFile()) {
|
||||||
//ALog.d(TAG, "创建文件成功:" + file.getAbsolutePath());
|
//ALog.d(TAG, "创建文件成功:" + file.getAbsolutePath());
|
||||||
@@ -327,7 +328,7 @@ public class FileUtil {
|
|||||||
ALog.d(TAG, String.format("block = %s", block));
|
ALog.d(TAG, String.format("block = %s", block));
|
||||||
File subFile = new File(subPath);
|
File subFile = new File(subPath);
|
||||||
if (!subFile.exists()) {
|
if (!subFile.exists()) {
|
||||||
subFile.createNewFile();
|
createFile(subFile);
|
||||||
}
|
}
|
||||||
FileOutputStream fos = new FileOutputStream(subFile);
|
FileOutputStream fos = new FileOutputStream(subFile);
|
||||||
FileChannel sfoc = fos.getChannel();
|
FileChannel sfoc = fos.getChannel();
|
||||||
|
|||||||
@@ -1,3 +0,0 @@
|
|||||||
<resources>
|
|
||||||
<string name="app_name">PublicComponent</string>
|
|
||||||
</resources>
|
|
||||||
39
README.md
39
README.md
@@ -44,18 +44,18 @@ Aria有以下特点:
|
|||||||
|
|
||||||
## 引入库
|
## 引入库
|
||||||
[](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
|
[](https://github.com/AriaLyy/Aria/blob/master/LICENSE)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
[](https://github.com/AriaLyy/Aria)
|
[](https://github.com/AriaLyy/Aria)
|
||||||
|
|
||||||
```java
|
```java
|
||||||
implementation 'com.arialyy.aria:core:3.7.2'
|
implementation 'com.arialyy.aria:core:3.7.4'
|
||||||
annotationProcessor 'com.arialyy.aria:compiler:3.7.2'
|
annotationProcessor 'com.arialyy.aria:compiler:3.7.4'
|
||||||
implementation 'com.arialyy.aria:ftpComponent:3.7.2' # 如果需要使用ftp,请增加该组件
|
implementation 'com.arialyy.aria:ftpComponent:3.7.4' # 如果需要使用ftp,请增加该组件
|
||||||
implementation 'com.arialyy.aria:m3u8Component:3.7.2' # 如果需要使用m3u8下载功能,请增加该组件
|
implementation 'com.arialyy.aria:m3u8Component:3.7.4' # 如果需要使用m3u8下载功能,请增加该组件
|
||||||
```
|
```
|
||||||
如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:aria-core:<last-version>'`替换为
|
如果出现android support依赖错误,请将 `compile 'com.arialyy.aria:core:<last-version>'`替换为
|
||||||
```
|
```
|
||||||
api('com.arialyy.aria:aria-core:<last-version>'){
|
api('com.arialyy.aria:aria-core:<last-version>'){
|
||||||
exclude group: 'androidx.appcompat.app'
|
exclude group: 'androidx.appcompat.app'
|
||||||
@@ -137,23 +137,10 @@ protected void onCreate(Bundle savedInstanceState) {
|
|||||||
|
|
||||||
|
|
||||||
### 版本日志
|
### 版本日志
|
||||||
+ v_3.7
|
+ v_3.7.4 (2019/11/2)
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/450
|
- 修复一个class被莫名改变的问题
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/466
|
- 修复非分块模式下导致的一个下载失败问题
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/454
|
- fix bug https://github.com/AriaLyy/Aria/issues/493
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/467
|
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/459
|
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/487
|
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/483
|
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/482
|
|
||||||
- fix bug https://github.com/AriaLyy/Aria/issues/473
|
|
||||||
- 移除隐藏api的反射 https://github.com/AriaLyy/Aria/issues/456
|
|
||||||
- 新增ftp免证书登陆功能h ttps://github.com/AriaLyy/Aria/issues/455
|
|
||||||
- 适配androidX
|
|
||||||
- 修复组合任务,恢复下载,会出现进度显示为0的问题
|
|
||||||
- m3u8点播下载新增创建ts索引功能
|
|
||||||
- 修复多任务的m3u8点播下载时,一个任务调用`jumpIndex`,其它m3u8任务也会自动调用`jumpIndex`的问题
|
|
||||||
- 添加权限检查
|
|
||||||
|
|
||||||
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
||||||
|
|
||||||
|
|||||||
1
SFtpComponent/.gitignore
vendored
Normal file
1
SFtpComponent/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
|||||||
|
/build
|
||||||
33
SFtpComponent/build.gradle
Normal file
33
SFtpComponent/build.gradle
Normal file
@@ -0,0 +1,33 @@
|
|||||||
|
apply plugin: 'com.android.library'
|
||||||
|
|
||||||
|
android {
|
||||||
|
compileSdkVersion rootProject.ext.compileSdkVersion
|
||||||
|
buildToolsVersion rootProject.ext.buildToolsVersion
|
||||||
|
|
||||||
|
defaultConfig {
|
||||||
|
minSdkVersion rootProject.ext.minSdkVersion
|
||||||
|
targetSdkVersion rootProject.ext.targetSdkVersion
|
||||||
|
versionCode rootProject.ext.versionCode
|
||||||
|
versionName rootProject.ext.versionName
|
||||||
|
|
||||||
|
testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner"
|
||||||
|
consumerProguardFiles 'consumer-rules.pro'
|
||||||
|
}
|
||||||
|
|
||||||
|
buildTypes {
|
||||||
|
release {
|
||||||
|
minifyEnabled false
|
||||||
|
proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
dependencies {
|
||||||
|
implementation fileTree(dir: 'libs', include: ['*.jar'])
|
||||||
|
|
||||||
|
implementation "androidx.appcompat:appcompat:${rootProject.ext.XAppcompatVersion}"
|
||||||
|
implementation "com.jcraft:jsch:0.1.55"
|
||||||
|
implementation "com.jcraft:jzlib:1.1.3"
|
||||||
|
implementation project(path: ':FtpComponent')
|
||||||
|
compile project(path: ':PublicComponent')
|
||||||
|
}
|
||||||
0
SFtpComponent/consumer-rules.pro
Normal file
0
SFtpComponent/consumer-rules.pro
Normal file
21
SFtpComponent/proguard-rules.pro
vendored
Normal file
21
SFtpComponent/proguard-rules.pro
vendored
Normal file
@@ -0,0 +1,21 @@
|
|||||||
|
# Add project specific ProGuard rules here.
|
||||||
|
# You can control the set of applied configuration files using the
|
||||||
|
# proguardFiles setting in build.gradle.
|
||||||
|
#
|
||||||
|
# For more details, see
|
||||||
|
# http://developer.android.com/guide/developing/tools/proguard.html
|
||||||
|
|
||||||
|
# If your project uses WebView with JS, uncomment the following
|
||||||
|
# and specify the fully qualified class name to the JavaScript interface
|
||||||
|
# class:
|
||||||
|
#-keepclassmembers class fqcn.of.javascript.interface.for.webview {
|
||||||
|
# public *;
|
||||||
|
#}
|
||||||
|
|
||||||
|
# Uncomment this to preserve the line number information for
|
||||||
|
# debugging stack traces.
|
||||||
|
#-keepattributes SourceFile,LineNumberTable
|
||||||
|
|
||||||
|
# If you keep the line number information, uncomment this to
|
||||||
|
# hide the original source file name.
|
||||||
|
#-renamesourcefileattribute SourceFile
|
||||||
2
SFtpComponent/src/main/AndroidManifest.xml
Normal file
2
SFtpComponent/src/main/AndroidManifest.xml
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
|
||||||
|
package="com.arialyy.aria.sftp" />
|
||||||
@@ -0,0 +1,58 @@
|
|||||||
|
/*
|
||||||
|
* 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.sftp;
|
||||||
|
|
||||||
|
import com.arialyy.aria.core.AriaConfig;
|
||||||
|
import com.arialyy.aria.core.common.AbsEntity;
|
||||||
|
import com.arialyy.aria.core.inf.OnFileInfoCallback;
|
||||||
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
|
import com.arialyy.aria.core.wrapper.AbsTaskWrapper;
|
||||||
|
import com.arialyy.aria.ftp.FtpTaskOption;
|
||||||
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* https://cloud.tencent.com/developer/article/1354612
|
||||||
|
* @author lyy
|
||||||
|
*/
|
||||||
|
public class AbsSFtpInfoThread<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>>
|
||||||
|
implements Runnable {
|
||||||
|
|
||||||
|
private final String TAG = CommonUtil.getClassName(getClass());
|
||||||
|
protected ENTITY mEntity;
|
||||||
|
protected TASK_WRAPPER mTaskWrapper;
|
||||||
|
protected FtpTaskOption mTaskOption;
|
||||||
|
private int mConnectTimeOut;
|
||||||
|
protected OnFileInfoCallback mCallback;
|
||||||
|
protected long mSize = 0;
|
||||||
|
protected String charSet = "UTF-8";
|
||||||
|
private boolean isUpload = false;
|
||||||
|
|
||||||
|
public AbsSFtpInfoThread(TASK_WRAPPER taskWrapper, OnFileInfoCallback callback) {
|
||||||
|
mTaskWrapper = taskWrapper;
|
||||||
|
mEntity = taskWrapper.getEntity();
|
||||||
|
mTaskOption = (FtpTaskOption) taskWrapper.getTaskOption();
|
||||||
|
mConnectTimeOut = AriaConfig.getInstance().getDConfig().getConnectTimeOut();
|
||||||
|
mCallback = callback;
|
||||||
|
if (mEntity instanceof UploadEntity) {
|
||||||
|
isUpload = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public void run() {
|
||||||
|
|
||||||
|
}
|
||||||
|
}
|
||||||
125
SFtpComponent/src/main/java/com/arialyy/aria/sftp/SFtpLogin.java
Normal file
125
SFtpComponent/src/main/java/com/arialyy/aria/sftp/SFtpLogin.java
Normal file
@@ -0,0 +1,125 @@
|
|||||||
|
/*
|
||||||
|
* 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.sftp;
|
||||||
|
|
||||||
|
import android.text.TextUtils;
|
||||||
|
import com.jcraft.jsch.JSch;
|
||||||
|
import com.jcraft.jsch.JSchException;
|
||||||
|
import com.jcraft.jsch.Session;
|
||||||
|
import java.util.Properties;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* sftp登录
|
||||||
|
*
|
||||||
|
* @author lyy
|
||||||
|
*/
|
||||||
|
public class SFtpLogin {
|
||||||
|
|
||||||
|
private String ip, userName, password;
|
||||||
|
private int port;
|
||||||
|
private Session session;
|
||||||
|
private boolean isLogin = false;
|
||||||
|
|
||||||
|
private SFtpLogin() {
|
||||||
|
createClient();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 创建客户端
|
||||||
|
*/
|
||||||
|
private void createClient() {
|
||||||
|
JSch jSch = new JSch();
|
||||||
|
try {
|
||||||
|
if (TextUtils.isEmpty(userName)) {
|
||||||
|
session = jSch.getSession(userName, ip, port);
|
||||||
|
} else {
|
||||||
|
session = jSch.getSession(ip);
|
||||||
|
}
|
||||||
|
if (!TextUtils.isEmpty(password)) {
|
||||||
|
session.setPassword(password);
|
||||||
|
}
|
||||||
|
Properties config = new Properties();
|
||||||
|
config.put("StrictHostKeyChecking", "no");
|
||||||
|
session.setConfig(config);// 为Session对象设置properties
|
||||||
|
session.setTimeout(3000);// 设置超时
|
||||||
|
isLogin = true;
|
||||||
|
} catch (JSchException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 执行登录
|
||||||
|
*/
|
||||||
|
public Session login() {
|
||||||
|
try {
|
||||||
|
session.connect(); // 通过Session建立连接
|
||||||
|
} catch (JSchException e) {
|
||||||
|
e.printStackTrace();
|
||||||
|
}
|
||||||
|
return session;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 登出
|
||||||
|
*/
|
||||||
|
public void logout() {
|
||||||
|
if (session != null) {
|
||||||
|
session.disconnect();
|
||||||
|
}
|
||||||
|
isLogin = false;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static class Builder {
|
||||||
|
private String ip, userName, password;
|
||||||
|
private int port = 22;
|
||||||
|
|
||||||
|
public Builder setIp(String ip) {
|
||||||
|
this.ip = ip;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setUserName(String userName) {
|
||||||
|
this.userName = userName;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setPassword(String password) {
|
||||||
|
this.password = password;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Builder setPort(int port) {
|
||||||
|
this.port = port;
|
||||||
|
return this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public SFtpLogin build() {
|
||||||
|
SFtpLogin login = new SFtpLogin();
|
||||||
|
login.ip = ip;
|
||||||
|
login.userName = userName;
|
||||||
|
login.password = password;
|
||||||
|
login.port = port;
|
||||||
|
if (TextUtils.isEmpty(ip)) {
|
||||||
|
throw new IllegalArgumentException("ip不能为空");
|
||||||
|
}
|
||||||
|
if (port < 0 || port > 65534) {
|
||||||
|
throw new IllegalArgumentException("端口错误");
|
||||||
|
}
|
||||||
|
return login;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -32,7 +32,7 @@
|
|||||||
3、只对新的多线程下载任务有效
|
3、只对新的多线程下载任务有效
|
||||||
4、只对多线程的任务有效
|
4、只对多线程的任务有效
|
||||||
-->
|
-->
|
||||||
<useBlock value="false"/>
|
<useBlock value="true"/>
|
||||||
|
|
||||||
<!--设置下载线程数,下载线程数不能小于1
|
<!--设置下载线程数,下载线程数不能小于1
|
||||||
注意:
|
注意:
|
||||||
|
|||||||
@@ -38,7 +38,7 @@ public class HttpDownloadModule extends BaseViewModule {
|
|||||||
//"http://202.98.201.103:7000/vrs/TPK/ZTC440402001Z.tpk";
|
//"http://202.98.201.103:7000/vrs/TPK/ZTC440402001Z.tpk";
|
||||||
private final String defFilePath =
|
private final String defFilePath =
|
||||||
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
|
Environment.getExternalStoragePublicDirectory(Environment.DIRECTORY_DOWNLOADS).getPath()
|
||||||
+ "/ZTC440402001Z.tpk";
|
+ "/TOTWOO-v3.5.6.apk";
|
||||||
|
|
||||||
private MutableLiveData<DownloadEntity> liveData = new MutableLiveData<>();
|
private MutableLiveData<DownloadEntity> liveData = new MutableLiveData<>();
|
||||||
private DownloadEntity singDownloadInfo;
|
private DownloadEntity singDownloadInfo;
|
||||||
@@ -47,9 +47,10 @@ public class HttpDownloadModule extends BaseViewModule {
|
|||||||
* 单任务下载的信息
|
* 单任务下载的信息
|
||||||
*/
|
*/
|
||||||
LiveData<DownloadEntity> getHttpDownloadInfo(Context context) {
|
LiveData<DownloadEntity> getHttpDownloadInfo(Context context) {
|
||||||
String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl);
|
//String url = AppUtil.getConfigValue(context, HTTP_URL_KEY, defUrl);
|
||||||
//String url =
|
//String url =
|
||||||
// "http://sdkdown.muzhiwan.com/openfile/2019/05/21/com.netease.tom.mzw_5ce3ef8754d05.apk";
|
// "http://sdkdown.muzhiwan.com/openfile/2019/05/21/com.netease.tom.mzw_5ce3ef8754d05.apk";
|
||||||
|
String url = "http://image.totwoo.com/totwoo-TOTWOO-v3.5.6.apk";
|
||||||
String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);
|
String filePath = AppUtil.getConfigValue(context, HTTP_PATH_KEY, defFilePath);
|
||||||
|
|
||||||
singDownloadInfo = Aria.download(context).getFirstDownloadEntity(url);
|
singDownloadInfo = Aria.download(context).getFirstDownloadEntity(url);
|
||||||
|
|||||||
@@ -289,8 +289,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
private void startD() {
|
private void startD() {
|
||||||
HttpOption option = new HttpOption();
|
HttpOption option = new HttpOption();
|
||||||
option.addHeader("1", "@")
|
option.addHeader("1", "@")
|
||||||
.setFileLenAdapter(new FileLenAdapter())
|
.useServerFileName(true)
|
||||||
.useServerFileName(true);
|
.setFileLenAdapter(new FileLenAdapter());
|
||||||
mTaskId = Aria.download(SingleTaskActivity.this)
|
mTaskId = Aria.download(SingleTaskActivity.this)
|
||||||
.load(mUrl)
|
.load(mUrl)
|
||||||
.setFilePath(mFilePath, true)
|
.setFilePath(mFilePath, true)
|
||||||
|
|||||||
@@ -257,7 +257,11 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
|||||||
case IEntity.STATE_STOP:
|
case IEntity.STATE_STOP:
|
||||||
case IEntity.STATE_PRE:
|
case IEntity.STATE_PRE:
|
||||||
case IEntity.STATE_POST_PRE:
|
case IEntity.STATE_POST_PRE:
|
||||||
start(entity);
|
if (entity.getId() < 0){
|
||||||
|
start(entity);
|
||||||
|
}else {
|
||||||
|
resume(entity);
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case IEntity.STATE_RUNNING:
|
case IEntity.STATE_RUNNING:
|
||||||
stop(entity);
|
stop(entity);
|
||||||
@@ -291,6 +295,24 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void resume(AbsEntity entity){
|
||||||
|
switch (entity.getTaskType()) {
|
||||||
|
case AbsTaskWrapper.D_FTP:
|
||||||
|
//Aria.download(getContext()).loadFtp((DownloadEntity) entity).login("lao", "123456").create();
|
||||||
|
Aria.download(getContext()).loadFtp(entity.getId()).resume();
|
||||||
|
break;
|
||||||
|
case AbsTaskWrapper.D_FTP_DIR:
|
||||||
|
Aria.download(getContext()).loadFtpDir(entity.getId()).resume();
|
||||||
|
break;
|
||||||
|
case AbsTaskWrapper.D_HTTP:
|
||||||
|
Aria.download(getContext()).load(entity.getId()).resume();
|
||||||
|
break;
|
||||||
|
case AbsTaskWrapper.DG_HTTP:
|
||||||
|
Aria.download(getContext()).loadGroup(entity.getId()).resume();
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void start(AbsEntity entity) {
|
private void start(AbsEntity entity) {
|
||||||
switch (entity.getTaskType()) {
|
switch (entity.getTaskType()) {
|
||||||
case AbsTaskWrapper.D_FTP:
|
case AbsTaskWrapper.D_FTP:
|
||||||
|
|||||||
@@ -103,6 +103,9 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskFail void taskFail(DownloadTask task) {
|
@Download.onTaskFail void taskFail(DownloadTask task) {
|
||||||
|
if (task == null || task.getEntity() == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
mAdapter.updateState(task.getEntity());
|
mAdapter.updateState(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -101,6 +101,9 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Download.onTaskFail void taskFail(DownloadTask task) {
|
@Download.onTaskFail void taskFail(DownloadTask task) {
|
||||||
|
if (task == null || task.getEntity() == null){
|
||||||
|
return;
|
||||||
|
}
|
||||||
mAdapter.updateBtState(task.getKey(), true);
|
mAdapter.updateBtState(task.getKey(), true);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -52,7 +52,7 @@ public class AppUtil {
|
|||||||
String path = String.format("%s/code/%s", context.getFilesDir().getPath(), fileName);
|
String path = String.format("%s/code/%s", context.getFilesDir().getPath(), fileName);
|
||||||
File ftpCode = new File(path);
|
File ftpCode = new File(path);
|
||||||
if (!ftpCode.exists()) {
|
if (!ftpCode.exists()) {
|
||||||
FileUtil.createFile(path);
|
FileUtil.createFile(ftpCode);
|
||||||
CommonUtil.createFileFormInputStream(context.getAssets()
|
CommonUtil.createFileFormInputStream(context.getAssets()
|
||||||
.open(String.format("help_code/%s", fileName)),
|
.open(String.format("help_code/%s", fileName)),
|
||||||
path);
|
path);
|
||||||
|
|||||||
@@ -44,8 +44,8 @@ task clean(type: Delete) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
ext {
|
ext {
|
||||||
versionCode = 372
|
versionCode = 374
|
||||||
versionName = '3.7.2'
|
versionName = '3.7.4'
|
||||||
userOrg = 'arialyy'
|
userOrg = 'arialyy'
|
||||||
groupId = 'com.arialyy.aria'
|
groupId = 'com.arialyy.aria'
|
||||||
publishVersion = versionName
|
publishVersion = versionName
|
||||||
|
|||||||
@@ -1,2 +1,2 @@
|
|||||||
include ':app', ':Aria', ':AriaAnnotations', ':AriaCompiler', ':AriaFtpPlug', ':AppFrame', ':HttpComponent', ':M3U8Component',
|
include ':app', ':Aria', ':AriaAnnotations', ':AriaCompiler', ':AriaFtpPlug', ':AppFrame', ':HttpComponent', ':M3U8Component', ':SFtpComponent',
|
||||||
':FtpComponent', ':PublicComponent'
|
':FtpComponent', ':PublicComponent'
|
||||||
|
|||||||
Reference in New Issue
Block a user