This commit is contained in:
laoyuyu committed 2019-09-05 19:10:21 +08:00
1 parent 22c81369b5
commit 1e2f52daca
22 files changed
+129 -51

No files matched your search

@@ -200,7 +200,7 @@ import org.xml.sax.SAXException;
Class[] clazzs = new Class[] {
DownloadEntity.class, UploadEntity.class, DownloadGroupEntity.class
};
String sql = "UPDATE %s SET state=2 WHERE state IN (3,4,5,6)";
String sql = "UPDATE %s SET state=2 WHERE state IN (4,5,6)";
for (Class clazz : clazzs) {
if (!mDbWrapper.tableExists(clazz)) {
continue;
@@ -5,6 +5,7 @@ import com.arialyy.aria.core.download.DGTaskWrapper;
import com.arialyy.aria.core.download.DTaskWrapper;
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.AbsTask;
import com.arialyy.aria.core.inf.AbsTaskWrapper;
import com.arialyy.aria.core.inf.IEntity;
@@ -104,7 +105,11 @@ final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
*/
private void resumeWaitTask() {
int maxTaskNum = mQueue.getMaxTaskNum();
if (mWaitList == null || mWaitList.isEmpty()) return;
if (mWaitList == null || mWaitList.isEmpty()) {
return;
}
List<AbsEntity> resumeEntities = new ArrayList<>();
for (AbsTaskWrapper te : mWaitList) {
if (te instanceof DTaskWrapper) {
mQueue = DownloadTaskQueue.getInstance();
@@ -119,7 +124,11 @@ final class ResumeAllCmd<T extends AbsTaskWrapper> extends AbsNormalCmd<T> {
te.getEntity().setState(IEntity.STATE_WAIT);
AbsTask task = createTask(te);
sendWaitState(task);
resumeEntities.add(te.getEntity());
}
}
if (!resumeEntities.isEmpty()) {
DbEntity.updateManyData(resumeEntities);
}
}
}
@@ -145,10 +145,10 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_WRAPPER ext
|| mStateManager.isFail()
|| !isRunning()
|| isBreak()) {
ALog.d(TAG, "isComplete = " + mStateManager.isComplete()
+ "; isFail = " + mStateManager.isFail()
+ "; isRunning = " + isRunning()
+ "; isBreak = " + isBreak());
//ALog.d(TAG, "isComplete = " + mStateManager.isComplete()
// + "; isFail = " + mStateManager.isFail()
// + "; isRunning = " + isRunning()
// + "; isBreak = " + isBreak());
ThreadTaskManager.getInstance().removeTaskThread(mTaskWrapper.getKey());
closeTimer();
onDestroy();
@@ -28,6 +28,7 @@ import com.arialyy.aria.exception.BaseException;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.util.ErrorHelp;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extends AbsTaskWrapper<ENTITY>,
@@ -35,7 +36,7 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
implements IEventListener {
protected static String TAG;
protected static final int RUN_SAVE_INTERVAL = 5 * 1000; //5s保存一次下载中的进度
protected WeakReference<Handler> outHandler;
protected SoftReference<Handler> outHandler;
private long mLastLen; //上一次发送长度
private boolean isFirst = true;
private TASK mTask;
@@ -46,7 +47,7 @@ public abstract class BaseListener<ENTITY extends AbsEntity, TASK_WRAPPER extend
private long mUpdateInterval;
protected BaseListener(TASK task, Handler outHandler) {
this.outHandler = new WeakReference<>(outHandler);
this.outHandler = new SoftReference<>(outHandler);
mTask = new WeakReference<>(task).get();
mEntity = mTask.getTaskWrapper().getEntity();
mTaskWrapper = mTask.getTaskWrapper();
@@ -18,7 +18,7 @@ package com.arialyy.aria.core.common.ftp;
import aria.apache.commons.net.ftp.FTPClientConfig;
import com.arialyy.aria.core.FtpUrlEntity;
import com.arialyy.aria.core.inf.ITaskConfig;
import java.lang.ref.WeakReference;
import java.lang.ref.SoftReference;
import java.net.Proxy;
/**
@@ -41,7 +41,7 @@ public class FtpTaskConfig implements ITaskConfig {
/**
* 上传拦截器
*/
private WeakReference<IFtpUploadInterceptor> uploadInterceptor;
private SoftReference<IFtpUploadInterceptor> uploadInterceptor;
/**
* 上传到服务器文件的新文件名{@link FtpInterceptHandler#getNewFileName()}
@@ -74,7 +74,7 @@ public class FtpTaskConfig implements ITaskConfig {
}
public void setUploadInterceptor(IFtpUploadInterceptor uploadInterceptor) {
this.uploadInterceptor = new WeakReference<>(uploadInterceptor);
this.uploadInterceptor = new SoftReference<>(uploadInterceptor);
}
public FtpUrlEntity getUrlEntity() {
@@ -19,7 +19,7 @@ package com.arialyy.aria.core.common.http;
import com.arialyy.aria.core.common.RequestEnum;
import com.arialyy.aria.core.inf.IHttpFileLenAdapter;
import com.arialyy.aria.core.inf.ITaskConfig;
import java.lang.ref.WeakReference;
import java.lang.ref.SoftReference;
import java.net.CookieManager;
import java.net.Proxy;
import java.util.HashMap;
@@ -78,7 +78,7 @@ public class HttpTaskConfig implements ITaskConfig {
*/
private Map<String, String> formFields = new HashMap<>();
private WeakReference<IHttpFileLenAdapter> fileLenAdapter;
private SoftReference<IHttpFileLenAdapter> fileLenAdapter;
public IHttpFileLenAdapter getFileLenAdapter() {
return fileLenAdapter == null ? null : fileLenAdapter.get();
@@ -88,7 +88,7 @@ public class HttpTaskConfig implements ITaskConfig {
* 如果是匿名内部类,完成后需要将adapter设置为空,否则会出现内存泄漏
*/
public void setFileLenAdapter(IHttpFileLenAdapter fileLenAdapter) {
this.fileLenAdapter = new WeakReference<>(fileLenAdapter);
this.fileLenAdapter = new SoftReference<>(fileLenAdapter);
}
public Map<String, String> getFormFields() {
@@ -133,7 +133,7 @@ final class M3U8InfoThread implements Runnable {
if (line.startsWith("#EXT-X-ENDLIST")) {
break;
}
//ALog.d(TAG, line);
ALog.d(TAG, line);
if (line.startsWith("#EXTINF")) {
String info = reader.readLine();
mInfos.add(info);
@@ -16,7 +16,6 @@
package com.arialyy.aria.core.download.m3u8;
import java.lang.ref.SoftReference;
import java.lang.ref.WeakReference;
import java.util.List;
/**
@@ -67,7 +66,7 @@ public class M3U8TaskConfig {
/**
* 码率url转换器
*/
private WeakReference<IBandWidthUrlConverter> bandWidthUrlConverter;
private SoftReference<IBandWidthUrlConverter> bandWidthUrlConverter;
/**
* 码率地址
@@ -77,7 +76,7 @@ public class M3U8TaskConfig {
/**
* 直播下载,ts url转换器
*/
private WeakReference<ILiveTsUrlConverter> liveTsUrlConverter;
private SoftReference<ILiveTsUrlConverter> liveTsUrlConverter;
/**
* 直播的m3u8文件更新间隔
@@ -136,7 +135,7 @@ public class M3U8TaskConfig {
}
public void setLiveTsUrlConverter(ILiveTsUrlConverter liveTsUrlConverter) {
this.liveTsUrlConverter = new WeakReference<>(liveTsUrlConverter);
this.liveTsUrlConverter = new SoftReference<>(liveTsUrlConverter);
}
public String getBandWidthUrl() {
@@ -152,7 +151,7 @@ public class M3U8TaskConfig {
}
public void setBandWidthUrlConverter(IBandWidthUrlConverter bandWidthUrlConverter) {
this.bandWidthUrlConverter = new WeakReference<>(bandWidthUrlConverter);
this.bandWidthUrlConverter = new SoftReference<>(bandWidthUrlConverter);
}
public int getBandWidth() {