laoyuyu 5 years ago
parent fdb607e10f
commit 062f124cae
  1. 9
      Aria/src/main/java/com/arialyy/aria/core/command/CommandManager.java
  2. 14
      Aria/src/main/java/com/arialyy/aria/core/common/BaseListener.java
  3. 8
      Aria/src/main/java/com/arialyy/aria/core/common/RecordHandler.java
  4. 2
      Aria/src/main/java/com/arialyy/aria/core/common/RecordWrapper.java
  5. 2
      Aria/src/main/java/com/arialyy/aria/core/common/ThreadRecord.java
  6. 10
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java
  7. 2
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8InfoThread.java
  8. 2
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8LiveLoader.java
  9. 4
      Aria/src/main/java/com/arialyy/aria/core/download/m3u8/M3U8LiveUtil.java
  10. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/FtpFileInfoThread.java
  11. 2
      Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java
  12. 79
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  13. 33
      Aria/src/main/java/com/arialyy/aria/util/RecordUtil.java
  14. 2
      app/src/main/assets/aria_config.xml
  15. 2
      app/src/main/java/com/arialyy/simple/core/download/m3u8/M3U8VodDLoadActivity.java
  16. 2
      app/src/main/java/com/arialyy/simple/core/download/m3u8/VideoPlayerFragment.java
  17. 6
      app/src/main/java/com/arialyy/simple/core/download/multi_download/DownloadAdapter.java
  18. 10
      app/src/main/java/com/arialyy/simple/core/download/multi_download/MultiTaskActivity.java
  19. 35
      app/src/main/res/values/strings.xml

@ -59,17 +59,11 @@ public class CommandManager {
@Event @Event
public void stop(StopCmd cmd) { public void stop(StopCmd cmd) {
if (CommonUtil.isFastDoubleClick()){
return;
}
cmd.executeCmd(); cmd.executeCmd();
} }
@Event @Event
public void cancel(CancelCmd cmd) { public void cancel(CancelCmd cmd) {
if (CommonUtil.isFastDoubleClick()){
return;
}
cmd.executeCmd(); cmd.executeCmd();
} }
@ -123,9 +117,6 @@ public class CommandManager {
@Event @Event
public void subStop(DGSubStopCmd cmd) { public void subStop(DGSubStopCmd cmd) {
if (CommonUtil.isFastDoubleClick()){
return;
}
cmd.executeCmd(); cmd.executeCmd();
} }
} }

@ -16,8 +16,6 @@
package com.arialyy.aria.core.common; package com.arialyy.aria.core.common;
import android.os.Handler; import android.os.Handler;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupEntity;
import com.arialyy.aria.core.inf.AbsEntity; import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.AbsTask;
import com.arialyy.aria.core.inf.AbsTaskWrapper; import com.arialyy.aria.core.inf.AbsTaskWrapper;
@ -26,12 +24,10 @@ import com.arialyy.aria.core.inf.IEventListener;
import com.arialyy.aria.core.inf.ITaskWrapper; import com.arialyy.aria.core.inf.ITaskWrapper;
import com.arialyy.aria.core.inf.TaskSchedulerType; import com.arialyy.aria.core.inf.TaskSchedulerType;
import com.arialyy.aria.core.scheduler.ISchedulers; import com.arialyy.aria.core.scheduler.ISchedulers;
import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.exception.BaseException; import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.ErrorHelp; import com.arialyy.aria.util.ErrorHelp;
import com.arialyy.aria.util.RecordUtil;
import java.lang.ref.WeakReference; import java.lang.ref.WeakReference;
public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>, public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>,
@ -156,16 +152,6 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
mEntity.setCurrentProgress(mEntity.getFileSize()); mEntity.setCurrentProgress(mEntity.getFileSize());
mEntity.setPercent(100); mEntity.setPercent(100);
handleSpeed(0); handleSpeed(0);
ALog.i(TAG, String.format("任务【%s】完成,将删除任务任务记录", mEntity.getKey()));
if (mEntity instanceof DownloadGroupEntity) {
RecordUtil.delGroupTaskRecord((DownloadGroupEntity) mEntity, false, false);
} else if (mEntity instanceof DownloadEntity) {
RecordUtil.delTaskRecord(((DownloadEntity) mEntity).getFilePath(),
RecordHandler.TYPE_DOWNLOAD, false, false);
} else if (mEntity instanceof UploadEntity) {
RecordUtil.delTaskRecord(((UploadEntity) mEntity).getFilePath(), RecordHandler.TYPE_UPLOAD,
false, false);
}
} }
/** /**

@ -152,7 +152,7 @@ public class RecordHandler {
ThreadRecord tr = mTaskRecord.threadRecords.get(0); ThreadRecord tr = mTaskRecord.threadRecords.get(0);
tr.startLocation = 0; tr.startLocation = 0;
tr.endLocation = mEntity.getFileSize(); tr.endLocation = mEntity.getFileSize();
tr.key = mTaskRecord.filePath; tr.taskKey = mTaskRecord.filePath;
tr.blockLen = tr.endLocation; tr.blockLen = tr.endLocation;
tr.isComplete = false; tr.isComplete = false;
} }
@ -164,7 +164,7 @@ public class RecordHandler {
File file = new File(mTaskRecord.filePath); File file = new File(mTaskRecord.filePath);
if (!file.exists()) { if (!file.exists()) {
ALog.w(TAG, String.format("文件【%s】不存在,重新分配线程区间", mTaskRecord.filePath)); ALog.w(TAG, String.format("文件【%s】不存在,重新分配线程区间", mTaskRecord.filePath));
DbEntity.deleteData(ThreadRecord.class, "key=?", mTaskRecord.filePath); DbEntity.deleteData(ThreadRecord.class, "taskKey=?", mTaskRecord.filePath);
initRecord(false); initRecord(false);
} }
} }
@ -290,7 +290,7 @@ public class RecordHandler {
File tempFile = new File(getFilePath()); File tempFile = new File(getFilePath());
for (int i = 0; i < threadNum; i++) { for (int i = 0; i < threadNum; i++) {
ThreadRecord tRecord = new ThreadRecord(); ThreadRecord tRecord = new ThreadRecord();
tRecord.key = mTaskRecord.filePath; tRecord.taskKey = mTaskRecord.filePath;
Object state = pro.getProperty(tempFile.getName() + STATE + i); Object state = pro.getProperty(tempFile.getName() + STATE + i);
Object record = pro.getProperty(tempFile.getName() + RECORD + i); Object record = pro.getProperty(tempFile.getName() + RECORD + i);
if (state != null && Integer.parseInt(String.valueOf(state)) == 1) { if (state != null && Integer.parseInt(String.valueOf(state)) == 1) {
@ -329,7 +329,7 @@ public class RecordHandler {
long startL = i * blockSize, endL = (i + 1) * blockSize; long startL = i * blockSize, endL = (i + 1) * blockSize;
ThreadRecord tr; ThreadRecord tr;
tr = new ThreadRecord(); tr = new ThreadRecord();
tr.key = mTaskRecord.filePath; tr.taskKey = mTaskRecord.filePath;
tr.threadId = i; tr.threadId = i;
tr.startLocation = startL; tr.startLocation = startL;
tr.isComplete = false; tr.isComplete = false;

@ -32,7 +32,7 @@ public class RecordWrapper extends AbsDbWrapper {
@One @One
public TaskRecord taskRecord; public TaskRecord taskRecord;
@Many(parentColumn = "filePath", entityColumn = "key") @Many(parentColumn = "filePath", entityColumn = "taskKey")
public List<ThreadRecord> threadRecords; public List<ThreadRecord> threadRecords;
@Override protected void handleConvert() { @Override protected void handleConvert() {

@ -26,7 +26,7 @@ public class ThreadRecord extends DbEntity {
/** /**
* 任务的文件路径不是当前线程记录的的分块文件路径 * 任务的文件路径不是当前线程记录的的分块文件路径
*/ */
public String key; public String taskKey;
/** /**
* 开始位置 * 开始位置

@ -22,9 +22,9 @@ import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.common.CompleteInfo; import com.arialyy.aria.core.common.CompleteInfo;
import com.arialyy.aria.core.common.OnFileInfoCallback; import com.arialyy.aria.core.common.OnFileInfoCallback;
import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.common.http.HttpTaskConfig;
import com.arialyy.aria.core.download.DTaskWrapper; import com.arialyy.aria.core.download.DTaskWrapper;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.common.http.HttpTaskConfig;
import com.arialyy.aria.core.inf.IHttpFileLenAdapter; import com.arialyy.aria.core.inf.IHttpFileLenAdapter;
import com.arialyy.aria.exception.AriaIOException; import com.arialyy.aria.exception.AriaIOException;
import com.arialyy.aria.exception.BaseException; import com.arialyy.aria.exception.BaseException;
@ -54,7 +54,7 @@ import java.util.UUID;
* 下载文件信息获取 * 下载文件信息获取
*/ */
public class HttpFileInfoThread implements Runnable { public class HttpFileInfoThread implements Runnable {
private final String TAG = "HttpFileInfoThread"; private static final String TAG = "HttpFileInfoThread";
private DownloadEntity mEntity; private DownloadEntity mEntity;
private DTaskWrapper mTaskWrapper; private DTaskWrapper mTaskWrapper;
private int mConnectTimeOut; private int mConnectTimeOut;
@ -119,7 +119,7 @@ public class HttpFileInfoThread implements Runnable {
} }
long len = lenAdapter.handleFileLen(conn.getHeaderFields()); long len = lenAdapter.handleFileLen(conn.getHeaderFields());
if (!CommonUtil.checkSDMemorySpace(mEntity.getDownloadPath(), len)) { if (!CommonUtil.checkSDMemorySpace(mEntity.getFilePath(), len)) {
failDownload(new TaskException(TAG, failDownload(new TaskException(TAG,
String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getDownloadPath(), String.format("下载失败,内存空间不足;filePath: %s, url: %s", mEntity.getDownloadPath(),
mEntity.getUrl())), false); mEntity.getUrl())), false);
@ -334,6 +334,10 @@ public class HttpFileInfoThread implements Runnable {
private static class FileLenAdapter implements IHttpFileLenAdapter { private static class FileLenAdapter implements IHttpFileLenAdapter {
@Override public long handleFileLen(Map<String, List<String>> headers) { @Override public long handleFileLen(Map<String, List<String>> headers) {
if (headers == null || headers.isEmpty()) {
ALog.e(TAG, "header为空,获取文件长度失败");
return -1;
}
List<String> sLength = headers.get("Content-Length"); List<String> sLength = headers.get("Content-Length");
if (sLength == null || sLength.isEmpty()) { if (sLength == null || sLength.isEmpty()) {
return -1; return -1;

@ -53,7 +53,7 @@ import java.util.regex.Pattern;
* https://blog.csdn.net/Guofengpu/article/details/54922865 * https://blog.csdn.net/Guofengpu/article/details/54922865
*/ */
final class M3U8InfoThread implements Runnable { final class M3U8InfoThread implements Runnable {
private final String TAG = "M3U8FileInfoThread"; private final String TAG = "M3U8InfoThread";
private DownloadEntity mEntity; private DownloadEntity mEntity;
private DTaskWrapper mTaskWrapper; private DTaskWrapper mTaskWrapper;
private int mConnectTimeOut; private int mConnectTimeOut;

@ -127,7 +127,7 @@ public class M3U8LiveLoader extends BaseM3U8Loader {
*/ */
private M3U8ThreadTask createThreadTask(String cacheDir, int indexId, String tsUrl) { private M3U8ThreadTask createThreadTask(String cacheDir, int indexId, String tsUrl) {
ThreadRecord record = new ThreadRecord(); ThreadRecord record = new ThreadRecord();
record.key = mRecord.filePath; record.taskKey = mRecord.filePath;
record.isComplete = false; record.isComplete = false;
record.tsUrl = tsUrl; record.tsUrl = tsUrl;
record.threadType = TaskRecord.TYPE_M3U8_LIVE; record.threadType = TaskRecord.TYPE_M3U8_LIVE;

@ -95,11 +95,15 @@ public class M3U8LiveUtil implements IUtil {
if (mInfoThread != null) { if (mInfoThread != null) {
mInfoThread.setStop(true); mInfoThread.setStop(true);
closeTimer(); closeTimer();
if (mWrapper.asM3U8().isMergeFile()) {
if (mLoader.mergeFile()) { if (mLoader.mergeFile()) {
mListener.onComplete(); mListener.onComplete();
} else { } else {
mListener.onFail(false, new M3U8Exception(TAG, "合并文件失败")); mListener.onFail(false, new M3U8Exception(TAG, "合并文件失败"));
} }
} else {
mListener.onComplete();
}
} }
} }

@ -144,7 +144,7 @@ class FtpFileInfoThread extends AbsFtpInfoThread<UploadEntity, UTaskWrapper> {
ThreadRecord threadRecord; ThreadRecord threadRecord;
if (record.threadRecords == null || record.threadRecords.isEmpty()) { if (record.threadRecords == null || record.threadRecords.isEmpty()) {
threadRecord = new ThreadRecord(); threadRecord = new ThreadRecord();
threadRecord.key = record.filePath; threadRecord.taskKey = record.filePath;
} else { } else {
threadRecord = record.threadRecords.get(0); threadRecord = record.threadRecords.get(0);
} }

@ -38,7 +38,7 @@ class DBConfig {
static boolean DEBUG = false; static boolean DEBUG = false;
static Map<String, Class> mapping = new LinkedHashMap<>(); static Map<String, Class> mapping = new LinkedHashMap<>();
static String DB_NAME; static String DB_NAME;
static int VERSION = 51; static int VERSION = 52;
/** /**
* 是否将数据库保存在Sd卡{@code true} * 是否将数据库保存在Sd卡{@code true}

@ -100,6 +100,8 @@ final class SqlHelper extends SQLiteOpenHelper {
handle360AriaUpdate(db); handle360AriaUpdate(db);
} else if (oldVersion < 51) { } else if (oldVersion < 51) {
handle365Update(db); handle365Update(db);
} else if (oldVersion < 52) {
handle366Update(db);
} else { } else {
handleDbUpdate(db, null, null); handleDbUpdate(db, null, null);
} }
@ -239,23 +241,43 @@ final class SqlHelper extends SQLiteOpenHelper {
*/ */
private void delRepeatThreadRecord(SQLiteDatabase db) { private void delRepeatThreadRecord(SQLiteDatabase db) {
String repeatSql = String repeatSql =
"DELETE FROM ThreadRecord WHERE (key, threadId, endLocation) " "DELETE FROM ThreadRecord WHERE (taskKey, threadId, endLocation) "
+ "IN (SELECT key, threadId, endLocation FROM ThreadRecord GROUP BY key, threadId, endLocation " + "IN (SELECT taskKey, threadId, endLocation FROM ThreadRecord GROUP BY taskKey, threadId, endLocation "
+ "HAVING COUNT(*) > 1) AND rowid " + "HAVING COUNT(*) > 1) AND rowid "
+ "NOT IN (SELECT MIN(rowid) FROM ThreadRecord GROUP BY key, threadId, endLocation " + "NOT IN (SELECT MIN(rowid) FROM ThreadRecord GROUP BY taskKey, threadId, endLocation "
+ "HAVING COUNT(*)> 1)"; + "HAVING COUNT(*)> 1)";
ALog.d(TAG, repeatSql); ALog.d(TAG, repeatSql);
db.execSQL(repeatSql); db.execSQL(repeatSql);
} }
/**
* 处理366版本以下的升级
*/
private void handle366Update(SQLiteDatabase db) {
Map<String, Map<String, String>> modifyMap = new HashMap<>();
// 处理ThreadRecord的key字段名修改
Map<String, String> threadRecordModify = new HashMap<>();
threadRecordModify.put("key", "taskKey");
modifyMap.put("ThreadRecord", threadRecordModify);
// 执行升级操作
handleDbUpdate(db, modifyMap, null);
}
/** /**
* 处理365版本以下的升级 * 处理365版本以下的升级
*/ */
private void handle365Update(SQLiteDatabase db) { private void handle365Update(SQLiteDatabase db) {
db.execSQL("UPDATE ThreadRecord SET threadId=0 WHERE threadId=-1"); db.execSQL("UPDATE ThreadRecord SET threadId=0 WHERE threadId=-1");
Map<String, Map<String, String>> modifyMap = new HashMap<>();
// 处理ThreadRecord的key字段名修改
Map<String, String> threadRecordModify = new HashMap<>();
threadRecordModify.put("key", "taskKey");
modifyMap.put("ThreadRecord", threadRecordModify);
// 执行升级操作 // 执行升级操作
handleDbUpdate(db, null, null); handleDbUpdate(db, modifyMap, null);
delRepeatThreadRecord(db); delRepeatThreadRecord(db);
} }
@ -271,19 +293,25 @@ final class SqlHelper extends SQLiteOpenHelper {
} }
} }
Map<String, Map<String, String>> columnMap = new HashMap<>(); Map<String, Map<String, String>> modifyMap = new HashMap<>();
// 处理DownloadEntity、DownloadGroupEntity的 groupName字段名的修改 // 处理DownloadEntity、DownloadGroupEntity的 groupName字段名的修改
Map<String, String> groupNameModify = new HashMap<>(); Map<String, String> entityModify = new HashMap<>();
groupNameModify.put("groupName", "groupHash"); entityModify.put("groupName", "groupHash");
columnMap.put("DownloadEntity", groupNameModify); modifyMap.put("DownloadEntity", entityModify);
columnMap.put("DownloadGroupEntity", groupNameModify); modifyMap.put("DownloadGroupEntity", entityModify);
// 处理TaskRecord的dGroupName字段名的修改 // 处理TaskRecord的dGroupName字段名的修改
Map<String, String> dGroupNameModify = new HashMap<>(); Map<String, String> taskRecordModify = new HashMap<>();
dGroupNameModify.put("dGroupName", "dGroupHash"); taskRecordModify.put("dGroupName", "dGroupHash");
columnMap.put("TaskRecord", dGroupNameModify); modifyMap.put("TaskRecord", taskRecordModify);
// 处理ThreadRecord的key字段名修改
Map<String, String> threadRecordModify = new HashMap<>();
threadRecordModify.put("key", "taskKey");
modifyMap.put("ThreadRecord", threadRecordModify);
// 执行升级操作 // 执行升级操作
handleDbUpdate(db, columnMap, null); handleDbUpdate(db, modifyMap, null);
delRepeatThreadRecord(db); delRepeatThreadRecord(db);
} }
@ -324,18 +352,19 @@ final class SqlHelper extends SQLiteOpenHelper {
i++; i++;
} }
Map<String, Map<String, String>> modifyColumnMap = new HashMap<>();
Map<String, String> dMap = new HashMap<>();
dMap.put("groupName", "groupHash");
// 处理数据库版本小于3的字段改变 // 处理数据库版本小于3的字段改变
dMap.put("downloadUrl", "url"); Map<String, Map<String, String>> modifyMap = new HashMap<>();
dMap.put("isDownloadComplete", "isComplete"); Map<String, String> dEntityModifyMap = new HashMap<>();
modifyColumnMap.put("DownloadEntity", dMap); dEntityModifyMap.put("groupName", "groupHash");
dEntityModifyMap.put("downloadUrl", "url");
Map<String, String> dGMap = new HashMap<>(); dEntityModifyMap.put("isDownloadComplete", "isComplete");
dGMap.put("groupName", "groupHash"); modifyMap.put("DownloadEntity", dEntityModifyMap);
modifyColumnMap.put("DownloadGroupEntity", dGMap);
Map<String, String> dGEntityModifyMap = new HashMap<>();
dGEntityModifyMap.put("groupName", "groupHash");
modifyMap.put("DownloadGroupEntity", dGEntityModifyMap);
// 删除字段
Map<String, List<String>> delColumnMap = new HashMap<>(); Map<String, List<String>> delColumnMap = new HashMap<>();
List<String> dEntityDel = new ArrayList<>(); List<String> dEntityDel = new ArrayList<>();
dEntityDel.add("taskKey"); dEntityDel.add("taskKey");
@ -344,6 +373,6 @@ final class SqlHelper extends SQLiteOpenHelper {
dgEntityDel.add("subtask"); dgEntityDel.add("subtask");
delColumnMap.put("DownloadGroupEntity", dgEntityDel); delColumnMap.put("DownloadGroupEntity", dgEntityDel);
handleDbUpdate(db, modifyColumnMap, delColumnMap); handleDbUpdate(db, modifyMap, delColumnMap);
} }
} }

@ -83,7 +83,7 @@ public class RecordUtil {
} }
} }
} }
DbEntity.deleteData(ThreadRecord.class, "key=?", record.taskRecord.filePath); DbEntity.deleteData(ThreadRecord.class, "taskKey=?", record.taskRecord.filePath);
record.taskRecord.deleteData(); record.taskRecord.deleteData();
} }
} }
@ -148,15 +148,14 @@ public class RecordUtil {
*/ */
if (!entity.isComplete()) { if (!entity.isComplete()) {
if (record.taskType == TaskRecord.TYPE_M3U8_VOD) { // 删除ts分片文件 if (record.taskType == TaskRecord.TYPE_M3U8_VOD) { // 删除ts分片文件
String cacheDir = null; removeTsCache(targetFile, record.bandWidth);
if (!targetFile.isDirectory()) {
cacheDir = targetFile.getParent() + "/." + targetFile.getName();
}
removeTsCache(cacheDir);
} else if (record.isBlock) { // 删除分块文件 } else if (record.isBlock) { // 删除分块文件
removeBlockFile(record); removeBlockFile(record);
} }
} else if (removeFile) { // 处理任务完成情况 } else if (removeFile) { // 处理任务完成情况
if (record.taskType == TaskRecord.TYPE_M3U8_VOD) {
removeTsCache(targetFile, record.bandWidth);
}
removeTargetFile(targetFile); removeTargetFile(targetFile);
} }
@ -209,16 +208,14 @@ public class RecordUtil {
*/ */
if (!entity.isComplete()) { if (!entity.isComplete()) {
if (record.taskType == TaskRecord.TYPE_M3U8_VOD) { // 删除ts分片文件 if (record.taskType == TaskRecord.TYPE_M3U8_VOD) { // 删除ts分片文件
String cacheDir = null; removeTsCache(targetFile, record.bandWidth);
if (!targetFile.isDirectory()) {
cacheDir = String.format("%s/.%s_%s", targetFile.getParent(), targetFile.getName(),
record.bandWidth);
}
removeTsCache(cacheDir);
} else if (record.isBlock) { // 删除分块文件 } else if (record.isBlock) { // 删除分块文件
removeBlockFile(record); removeBlockFile(record);
} }
} else if (removeFile) { // 处理任务完成情况 } else if (removeFile) { // 处理任务完成情况
if (record.taskType == TaskRecord.TYPE_M3U8_VOD) {
removeTsCache(targetFile, record.bandWidth);
}
removeTargetFile(targetFile); removeTargetFile(targetFile);
} }
@ -238,7 +235,7 @@ public class RecordUtil {
private static void removeRecord(String filePath) { private static void removeRecord(String filePath) {
ALog.i(TAG, "删除任务记录"); ALog.i(TAG, "删除任务记录");
DbEntity.deleteData(ThreadRecord.class, "key=?", filePath); DbEntity.deleteData(ThreadRecord.class, "taskKey=?", filePath);
DbEntity.deleteData(TaskRecord.class, "filePath=?", filePath); DbEntity.deleteData(TaskRecord.class, "filePath=?", filePath);
} }
@ -287,7 +284,13 @@ public class RecordUtil {
/** /**
* 删除ts文件 * 删除ts文件
*/ */
private static void removeTsCache(String cacheDir) { private static void removeTsCache(File targetFile, long bandWidth) {
String cacheDir = null;
if (!targetFile.isDirectory()) {
cacheDir =
String.format("%s/.%s_%s", targetFile.getParent(), targetFile.getName(), bandWidth);
}
if (!TextUtils.isEmpty(cacheDir)) { if (!TextUtils.isEmpty(cacheDir)) {
File cacheDirF = new File(cacheDir); File cacheDirF = new File(cacheDir);
@ -348,7 +351,7 @@ public class RecordUtil {
// 修改线程记录 // 修改线程记录
if (record.threadRecords != null && !record.threadRecords.isEmpty()) { if (record.threadRecords != null && !record.threadRecords.isEmpty()) {
for (ThreadRecord tr : record.threadRecords) { for (ThreadRecord tr : record.threadRecords) {
tr.key = newPath; tr.taskKey = newPath;
File blockFile = new File(String.format(RecordHandler.SUB_PATH, oldPath, tr.threadId)); File blockFile = new File(String.format(RecordHandler.SUB_PATH, oldPath, tr.threadId));
if (blockFile.exists()) { if (blockFile.exists()) {
blockFile.renameTo(new File(String.format(RecordHandler.SUB_PATH, newPath, tr.threadId))); blockFile.renameTo(new File(String.format(RecordHandler.SUB_PATH, newPath, tr.threadId)));

@ -44,7 +44,7 @@
<threadNum value="3"/> <threadNum value="3"/>
<!--设置下载队列最大任务数, 默认为2--> <!--设置下载队列最大任务数, 默认为2-->
<maxTaskNum value="1"/> <maxTaskNum value="3"/>
<!--设置下载失败,重试次数,默认为10--> <!--设置下载失败,重试次数,默认为10-->
<reTryNum value="1"/> <reTryNum value="1"/>

@ -309,9 +309,11 @@ public class M3U8VodDLoadActivity extends BaseActivity<ActivityM3u8VodBinding> {
}) })
.setMergeHandler(new ITsMergeHandler() { .setMergeHandler(new ITsMergeHandler() {
@Override public boolean merge(@Nullable M3U8KeyInfo keyInfo, List<String> tsPath) { @Override public boolean merge(@Nullable M3U8KeyInfo keyInfo, List<String> tsPath) {
ALog.d(TAG, "合并TS....");
return false; return false;
} }
}) })
.merge(true)
//.asVod().setPeerIndex(50) //.asVod().setPeerIndex(50)
.start(); .start();
} }

@ -55,7 +55,7 @@ public class VideoPlayerFragment extends BaseFragment<FragmentVideoPlayerBinding
getBinding().surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() { getBinding().surfaceView.getHolder().addCallback(new SurfaceHolder.Callback() {
@Override public void surfaceCreated(SurfaceHolder holder) { @Override public void surfaceCreated(SurfaceHolder holder) {
mSurfaceHolder = holder; mSurfaceHolder = holder;
startNewPlayer(mPlayers.valueAt(0)); //startNewPlayer(mPlayers.valueAt(0));
} }
@Override @Override

@ -206,10 +206,10 @@ public class DownloadAdapter extends AbsRVAdapter<AbsEntity, DownloadAdapter.Sim
//删除按钮事件 //删除按钮事件
holder.cancel.setOnClickListener(new View.OnClickListener() { holder.cancel.setOnClickListener(new View.OnClickListener() {
@Override public void onClick(View v) { @Override public void onClick(View v) {
// mData.remove(entity); mData.remove(entity);
notifyDataSetChanged(); notifyDataSetChanged();
// cancel(entity); cancel(entity);
stop(entity); //stop(entity);
} }
}); });
//if (holder instanceof GroupHolder){ //if (holder instanceof GroupHolder){

@ -26,6 +26,7 @@ import android.view.View;
import com.arialyy.annotations.Download; import com.arialyy.annotations.Download;
import com.arialyy.annotations.DownloadGroup; import com.arialyy.annotations.DownloadGroup;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.ALog;
@ -71,8 +72,13 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
dialog.show(getSupportFragmentManager(), "download_num"); dialog.show(getSupportFragmentManager(), "download_num");
break; break;
case R.id.stop_all: case R.id.stop_all:
Aria.download(this).stopAllTask(); List<DownloadEntity> entities = Aria.download(this).getTaskList();
//Aria.download(this).removeAllTask(false); for (DownloadEntity entity: entities){
Aria.download(this).load(entity.getUrl()).cancel(true);
ALog.d(TAG, "exist ==" + Aria.download(this).load(entity.getUrl()).taskExists());
}
//Aria.download(this).stopAllTask();
//Aria.download(this).removeAllTask(true);
break; break;
case R.id.turn: case R.id.turn:
startActivity(new Intent(this, MultiDownloadActivity.class)); startActivity(new Intent(this, MultiDownloadActivity.class));

@ -64,26 +64,16 @@
<string-array name="test_apk_download_url"> <string-array name="test_apk_download_url">
<item>http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk</item> <!--300M的文件-->
<item>http://static.gaoshouyou.com/d/21/e8/61218d78d0e8b79df68dbc18dd484c97.apk</item>
<item>http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk</item>
<item>http://static.gaoshouyou.com/d/d4/4f/d6d48db3794fb9ecf47e83c346570881.apk</item> <item>http://static.gaoshouyou.com/d/d4/4f/d6d48db3794fb9ecf47e83c346570881.apk</item>
<!--<item>http://static.gaoshouyou.com/d/18/cf/ba18113bc6cf56c1c5863e761e717003.apk</item>-->
<!--<item>http://static.gaoshouyou.com/d/60/17/2460921367173ea7145f11194a6f2587.apk</item>-->
<!--<item>http://static.gaoshouyou.com/d/32/e0/1a32123ecbe0ee010d35479df248f90f.apk</item>-->
<!--<item>http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk</item>-->
<!--<item>http://static.gaoshouyou.com/d/e6/f5/4de6329f9cf5dc3a1d1e6bbcca0d003c.apk</item>-->
<!--<item>http://static.gaoshouyou.com/d/6e/e5/ff6ecaaf45e532e6d07747af82357472.apk</item>-->
<!--<item>http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk</item>-->
</string-array> </string-array>
<string-array name="file_nams"> <string-array name="file_nams">
<item>阴阳师</item> <item>王者荣耀</item>
<item>奇迹暖暖</item> <item>植物大战僵尸</item>
<item>幻影纹章</item> <item>部落冲突</item>
<item>史上最坑爹的游戏10</item> <item>瘟疫公司</item>
<item>鲜果消消乐</item> <item>水上公园大战</item>
<item>航海奇迹</item> <item>死亡之雨</item>
<item>test_1</item> <item>test_1</item>
<item>test_2</item> <item>test_2</item>
@ -91,13 +81,12 @@
</string-array> </string-array>
<string-array name="download_url"> <string-array name="download_url">
<item>https://g37.gdl.netease.com/onmyoji_netease_10_1.0.20.apk</item> <item>https://downs.muzhiwan.com/2019/06/28/com.tencent.tmgp.sgame5d15f9df3bb4d.gpk</item>
<item>http://static.gaoshouyou.com/d/eb/f2/dfeba30541f209ab8a50d847fc1661ce.apk</item> <item>https://downs.muzhiwan.com/2017/03/15/com.ea.game.pvz2_row58c8bfc00eea8.gpk</item>
<item>http://rs.0.gaoshouyou.com/d/51/46/58514d126c46b8a3f27fc8c7db3b09ec.apk</item> <item>https://downs.muzhiwan.com/2019/07/04/com.supercell.clashofclans.ewan.mzw_5d1da09397884.apk</item>
<item>http://rs.0.gaoshouyou.com/d/23/69/07238f952669727878d7a0e180534c8b.apk</item> <item>https://downs.muzhiwan.com/2019/02/28/com.miniclip.plagueinc_5c77596c79179.apk</item>
<item>http://rs.0.gaoshouyou.com/d/e7/3d/73e716d3353de5b479fcf7da8d36a5ef.apk</item> <item>https://downs.muzhiwan.com/2019/06/03/com.aqua.slide_5cf4b69e90e6a.apk</item>
<item>http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk</item> <item>https://downs.muzhiwan.com/2019/05/07/com.tinydevbox.deadrain2_g_5cd14a8aedb2f.apk</item>
<item>http://dby-resource-android.duobeiyun.com/jz22a8508b4265466b9fb4bb29082eaa2d.zip</item> <item>http://dby-resource-android.duobeiyun.com/jz22a8508b4265466b9fb4bb29082eaa2d.zip</item>
<item>http://dby-resource-android.duobeiyun.com/jz05fa8faf068145fcb25c93c8091297ad.zip</item> <item>http://dby-resource-android.duobeiyun.com/jz05fa8faf068145fcb25c93c8091297ad.zip</item>
<item>http://dby-resource-android.duobeiyun.com/jz684e1b4c2f6b4576979e60fd95edebad.zip</item> <item>http://dby-resource-android.duobeiyun.com/jz684e1b4c2f6b4576979e60fd95edebad.zip</item>

Loading…
Cancel
Save