fix bug fix bug https://github.com/AriaLyy/Aria/issues/272
This commit is contained in:
@@ -34,8 +34,8 @@ import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Properties;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by AriaL on 2017/7/1.
|
||||
@@ -67,7 +67,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
private int mCompleteThreadNum;
|
||||
private SparseArray<AbsThreadTask> mTask = new SparseArray<>();
|
||||
|
||||
private Timer mTimer;
|
||||
private ScheduledThreadPoolExecutor mTimer;
|
||||
@Deprecated private File mConfigFile;
|
||||
/**
|
||||
* 进度刷新间隔
|
||||
@@ -190,8 +190,8 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
* 启动进度获取定时器
|
||||
*/
|
||||
private synchronized void startTimer() {
|
||||
mTimer = new Timer(true);
|
||||
mTimer.schedule(new TimerTask() {
|
||||
mTimer = new ScheduledThreadPoolExecutor(1);
|
||||
mTimer.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override public void run() {
|
||||
if (mConstance.isComplete()
|
||||
|| mConstance.isStop()
|
||||
@@ -202,14 +202,12 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
mListener.onProgress(mConstance.CURRENT_LOCATION);
|
||||
}
|
||||
}
|
||||
}, 0, mUpdateInterval);
|
||||
}, 0, mUpdateInterval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
protected synchronized void closeTimer() {
|
||||
if (mTimer != null) {
|
||||
mTimer.purge();
|
||||
mTimer.cancel();
|
||||
mTimer = null;
|
||||
if (mTimer != null && !mTimer.isShutdown()) {
|
||||
mTimer.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -37,12 +37,12 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
private static final String TAG = "BaseDListener";
|
||||
WeakReference<Handler> outHandler;
|
||||
private int RUN_SAVE_INTERVAL = 5 * 1000; //5s保存一次下载中的进度
|
||||
private long mLastLen = 0; //上一次发送长度
|
||||
private long mLastLen; //上一次发送长度
|
||||
private boolean isFirst = true;
|
||||
protected ENTITY mEntity;
|
||||
protected TASK_ENTITY mTaskEntity;
|
||||
private TASK mTask;
|
||||
private boolean isConvertSpeed = false;
|
||||
private boolean isConvertSpeed;
|
||||
private long mLastSaveTime;
|
||||
private long mUpdateInterval;
|
||||
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.arialyy.aria.core.download;
|
||||
import android.os.Handler;
|
||||
import android.os.Looper;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.download.downloader.DownloadGroupUtil;
|
||||
import com.arialyy.aria.core.download.downloader.FtpDirDownloadUtil;
|
||||
@@ -26,7 +25,6 @@ import com.arialyy.aria.core.download.downloader.IDownloadGroupListener;
|
||||
import com.arialyy.aria.core.inf.AbsGroupTask;
|
||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.scheduler.ISchedulers;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CheckUtil;
|
||||
|
||||
/**
|
||||
@@ -74,12 +72,7 @@ public class DownloadGroupTask extends AbsGroupTask<DownloadGroupEntity, Downloa
|
||||
* @param schedulers {@link ISchedulers}
|
||||
*/
|
||||
public DownloadGroupTask.Builder setOutHandler(ISchedulers schedulers) {
|
||||
try {
|
||||
outHandler = new Handler(schedulers);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
outHandler = new Handler(Looper.getMainLooper(), schedulers);
|
||||
}
|
||||
outHandler = new Handler(Looper.getMainLooper(), schedulers);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -94,12 +94,7 @@ public class DownloadTask extends AbsNormalTask<DownloadEntity, DownloadTaskEnti
|
||||
* @param schedulers {@link ISchedulers}
|
||||
*/
|
||||
public Builder setOutHandler(ISchedulers schedulers) {
|
||||
try {
|
||||
outHandler = new Handler(schedulers);
|
||||
} catch (Exception e) {
|
||||
ALog.w(TAG, ALog.getExceptionString(e));
|
||||
outHandler = new Handler(Looper.getMainLooper(), schedulers);
|
||||
}
|
||||
outHandler = new Handler(Looper.getMainLooper(), schedulers);
|
||||
return this;
|
||||
}
|
||||
|
||||
|
||||
@@ -28,9 +28,9 @@ import com.arialyy.aria.util.NetUtils;
|
||||
import java.io.File;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.Timer;
|
||||
import java.util.TimerTask;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
import java.util.concurrent.ScheduledThreadPoolExecutor;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Created by AriaL on 2017/6/30.
|
||||
@@ -56,7 +56,7 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
protected IDownloadGroupListener mListener;
|
||||
DownloadGroupTaskEntity mGTEntity;
|
||||
private boolean isRunning = false;
|
||||
private Timer mTimer;
|
||||
private ScheduledThreadPoolExecutor mTimer;
|
||||
/**
|
||||
* 保存所有没有下载完成的任务,key为下载地址
|
||||
*/
|
||||
@@ -320,14 +320,9 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
mFailMap.clear();
|
||||
}
|
||||
|
||||
void closeTimer() {
|
||||
synchronized (LOCK) {
|
||||
isRunning = false;
|
||||
if (mTimer != null) {
|
||||
mTimer.purge();
|
||||
mTimer.cancel();
|
||||
mTimer = null;
|
||||
}
|
||||
synchronized void closeTimer() {
|
||||
if (mTimer != null && !mTimer.isShutdown()) {
|
||||
mTimer.shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -345,10 +340,10 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
startTimer();
|
||||
}
|
||||
|
||||
private void startTimer() {
|
||||
private synchronized void startTimer() {
|
||||
isRunning = true;
|
||||
mTimer = new Timer(true);
|
||||
mTimer.schedule(new TimerTask() {
|
||||
mTimer = new ScheduledThreadPoolExecutor(1);
|
||||
mTimer.scheduleWithFixedDelay(new Runnable() {
|
||||
@Override public void run() {
|
||||
if (!isRunning) {
|
||||
closeTimer();
|
||||
@@ -365,7 +360,7 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
mListener.onProgress(t);
|
||||
}
|
||||
}
|
||||
}, 0, mUpdateInterval);
|
||||
}, 0, mUpdateInterval, TimeUnit.MILLISECONDS);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -398,9 +393,9 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
private DownloadEntity subEntity;
|
||||
private int RUN_SAVE_INTERVAL = 5 * 1000; //5s保存一次下载中的进度
|
||||
private long lastSaveTime;
|
||||
private long lastLen = 0;
|
||||
private Timer timer;
|
||||
private boolean isNotNetRetry = false;
|
||||
private long lastLen;
|
||||
private ScheduledThreadPoolExecutor timer;
|
||||
private boolean isNotNetRetry;
|
||||
|
||||
ChildDownloadListener(DownloadTaskEntity entity) {
|
||||
subTaskEntity = entity;
|
||||
@@ -523,18 +518,16 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
||||
}
|
||||
|
||||
private void reStartTask(final Downloader dt) {
|
||||
if (timer != null) {
|
||||
timer.purge();
|
||||
timer.cancel();
|
||||
if (timer == null || timer.isShutdown()) {
|
||||
timer = new ScheduledThreadPoolExecutor(1);
|
||||
}
|
||||
timer = new Timer();
|
||||
timer.schedule(new TimerTask() {
|
||||
timer.schedule(new Runnable() {
|
||||
@Override public void run() {
|
||||
if (dt != null) {
|
||||
dt.retryTask();
|
||||
}
|
||||
}
|
||||
}, 5000);
|
||||
}, 5, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
private void handleSpeed(long speed) {
|
||||
|
||||
@@ -1,8 +1,11 @@
|
||||
## 开发日志
|
||||
+ v_3.4.17
|
||||
+ v_3.5
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/302
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/283
|
||||
- 现在,停止所有任务,未开始的任务状态将变为停止
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/305
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/306
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/272 (现在,停止所有任务,未开始的任务状态将变为停止)
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/277
|
||||
- 优化停止任务的速度
|
||||
+ v_3.4.12
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/286
|
||||
|
||||
@@ -17,9 +17,9 @@
|
||||
<!--android:name=".test.AnyRunActivity"-->
|
||||
<!--android:name=".test.TestFTPActivity"-->
|
||||
<!--android:name=".download.group.DownloadGroupActivity"-->
|
||||
<!--android:name=".MainActivity"-->
|
||||
<!--android:name=".download.SingleTaskActivity"-->
|
||||
<activity
|
||||
android:name=".download.SingleTaskActivity"
|
||||
android:name=".MainActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
@@ -29,7 +29,7 @@
|
||||
</activity>
|
||||
|
||||
<activity android:name=".download.DownloadActivity"/>
|
||||
<!--<activity android:name=".download.SingleTaskActivity"/>-->
|
||||
<activity android:name=".download.SingleTaskActivity"/>
|
||||
<activity android:name=".download.multi_download.MultiTaskActivity"/>
|
||||
<activity android:name=".download.fragment_download.FragmentActivity"/>
|
||||
<activity android:name=".download.multi_download.MultiDownloadActivity"/>
|
||||
|
||||
@@ -21,7 +21,6 @@ import com.arialyy.aria.core.inf.AbsNormalTask;
|
||||
import com.arialyy.aria.core.inf.IUploadListener;
|
||||
import com.arialyy.aria.core.scheduler.ISchedulers;
|
||||
import com.arialyy.aria.core.upload.uploader.SimpleUploadUtil;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/2/23.
|
||||
@@ -53,12 +52,7 @@ public class UploadTask extends AbsNormalTask<UploadEntity, UploadTaskEntity> {
|
||||
private UploadTaskEntity mTaskEntity;
|
||||
|
||||
public void setOutHandler(ISchedulers outHandler) {
|
||||
try {
|
||||
mOutHandler = new Handler(outHandler);
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
mOutHandler = new Handler(Looper.getMainLooper(), outHandler);
|
||||
}
|
||||
mOutHandler = new Handler(Looper.getMainLooper(), outHandler);
|
||||
}
|
||||
|
||||
public void setUploadTaskEntity(UploadTaskEntity taskEntity) {
|
||||
|
||||
@@ -39,7 +39,7 @@ task clean(type: Delete) {
|
||||
ext {
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = '3.4.16'
|
||||
publishVersion = '3.5_dev1'
|
||||
// publishVersion = '1.0.3' //FTP插件
|
||||
repoName='maven'
|
||||
desc = 'android 下载框架'
|
||||
|
||||
Reference in New Issue
Block a user