fix bug https://github.com/AriaLyy/Aria/issues/259
This commit is contained in:
13
.github/ISSUE_TEMPLATE/Custom.md
vendored
13
.github/ISSUE_TEMPLATE/Custom.md
vendored
@@ -5,17 +5,16 @@ about: 描述你遇到的问题或bug
|
||||
---
|
||||
|
||||
## 版本号
|
||||
~
|
||||
|
||||
|
||||
## 什么问题
|
||||
~
|
||||
|
||||
|
||||
## 如何复现此问题
|
||||
~
|
||||
|
||||
|
||||
## 手机型号
|
||||
~
|
||||
|
||||
## 控制台日志
|
||||
(github的issues支持图片直接粘贴复制)
|
||||
~
|
||||
|
||||
## 控制台日志(越完整越好)
|
||||
|
||||
|
||||
@@ -86,6 +86,9 @@ import com.arialyy.aria.util.ALog;
|
||||
* @param obj 观察者对象,为本类对象,使用{@code this}
|
||||
*/
|
||||
public static DownloadReceiver download(Object obj) {
|
||||
if (AriaManager.getInstance() != null){
|
||||
return AriaManager.getInstance().download(obj);
|
||||
}
|
||||
return get(convertContext(obj)).download(obj);
|
||||
}
|
||||
|
||||
@@ -97,6 +100,9 @@ import com.arialyy.aria.util.ALog;
|
||||
* @param obj 观察者对象,为本类对象,使用{@code this}
|
||||
*/
|
||||
public static UploadReceiver upload(Object obj) {
|
||||
if (AriaManager.getInstance() != null){
|
||||
return AriaManager.getInstance().upload(obj);
|
||||
}
|
||||
return get(convertContext(obj)).upload(obj);
|
||||
}
|
||||
|
||||
@@ -105,7 +111,8 @@ import com.arialyy.aria.util.ALog;
|
||||
*/
|
||||
public static AriaManager get(Context context) {
|
||||
if (context == null) {
|
||||
throw new NullPointerException("context 无效,请使用 download(this) 或 upload(this);"
|
||||
throw new NullPointerException("context 无效,在非【Activity、Service、Application、DialogFragment、Fragment、PopupWindow、Dialog】,"
|
||||
+ "请参考【https://aria.laoyuyu.me/aria_doc/start/any_java.html】,参数请使用 download(this) 或 upload(this);"
|
||||
+ "不要使用 download(getContext()) 或 upload(getContext())");
|
||||
}
|
||||
return AriaManager.getInstance(context);
|
||||
|
||||
@@ -96,9 +96,9 @@ import org.xml.sax.SAXException;
|
||||
}
|
||||
|
||||
static AriaManager getInstance() {
|
||||
if (INSTANCE == null) {
|
||||
throw new NullPointerException("请在Application或Activity初始化时调用一次Aria.init(context)方法进行初始化操作");
|
||||
}
|
||||
//if (INSTANCE == null) {
|
||||
// throw new NullPointerException("请在Application或Activity初始化时调用一次Aria.init(context)方法进行初始化操作");
|
||||
//}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
@@ -27,6 +27,7 @@ import java.util.List;
|
||||
* 1.如果执行队列没有满,则开始下载任务,直到执行队列满
|
||||
* 2.如果队列执行队列已经满了,则将所有任务添加到等待队列中
|
||||
* 3.如果队列中只有等待状态的任务,如果执行队列没有满,则会启动等待状态的任务,如果执行队列已经满了,则会将所有等待状态的任务加载到缓存队列中
|
||||
* 4.恢复下载的任务规则是,停止时间越晚的任务启动越早,安装DESC来进行排序
|
||||
*/
|
||||
final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
|
||||
private List<AbsTaskEntity> mWaitList = new ArrayList<>();
|
||||
@@ -61,7 +62,7 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
|
||||
if (type == 1) {
|
||||
List<DownloadEntity> entities =
|
||||
DbEntity.findDatas(DownloadEntity.class,
|
||||
"isGroupChild=? and state!=?", "false", "1");
|
||||
"isGroupChild=? AND state!=? ORDER BY stopTime DESC", "false", "1");
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
for (DownloadEntity entity : entities) {
|
||||
resumeTask(TEManager.getInstance().getTEntity(DownloadTaskEntity.class, entity.getKey()));
|
||||
@@ -69,7 +70,7 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
|
||||
}
|
||||
} else if (type == 2) {
|
||||
List<DownloadGroupEntity> entities =
|
||||
DbEntity.findDatas(DownloadGroupEntity.class, "state!=?", "1");
|
||||
DbEntity.findDatas(DownloadGroupEntity.class, "state!=? ORDER BY stopTime DESC", "1");
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
for (DownloadGroupEntity entity : entities) {
|
||||
resumeTask(
|
||||
@@ -78,7 +79,7 @@ final class ResumeAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
|
||||
}
|
||||
} else if (type == 3) {
|
||||
List<UploadEntity> entities =
|
||||
DbEntity.findDatas(UploadEntity.class, "state!=?", "1");
|
||||
DbEntity.findDatas(UploadEntity.class, "state!=? ORDER BY stopTime DESC", "1");
|
||||
if (entities != null && !entities.isEmpty()) {
|
||||
for (UploadEntity entity : entities) {
|
||||
resumeTask(TEManager.getInstance().getTEntity(UploadTaskEntity.class, entity.getKey()));
|
||||
|
||||
@@ -509,6 +509,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
mConstance.isStop = false;
|
||||
mConstance.isCancel = false;
|
||||
mConstance.isRunning = true;
|
||||
startTimer();
|
||||
ALog.d(TAG, String.format("任务【%s】开始重试,线程__%s__【开始位置:%s,结束位置:%s】", mEntity.getFileName(),
|
||||
key, task.getConfig().START_LOCATION, task.getConfig().END_LOCATION));
|
||||
if (!mFixedThreadPool.isShutdown()) {
|
||||
|
||||
@@ -169,6 +169,8 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
}
|
||||
//mEntity.deleteData();
|
||||
return;
|
||||
} else if (state == IEntity.STATE_STOP) {
|
||||
mEntity.setStopTime(System.currentTimeMillis());
|
||||
} else if (mEntity.isComplete()) {
|
||||
mEntity.setCompleteTime(System.currentTimeMillis());
|
||||
mEntity.setCurrentProgress(mEntity.getFileSize());
|
||||
|
||||
@@ -176,7 +176,6 @@ public class DownloadTask extends AbsNormalTask<DownloadTaskEntity> {
|
||||
public DownloadTask build() {
|
||||
DownloadTask task = new DownloadTask(taskEntity, outHandler);
|
||||
task.setTargetName(targetName);
|
||||
taskEntity.save();
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.download.downloader;
|
||||
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.common.IUtil;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
@@ -259,7 +260,7 @@ public abstract class AbsGroupUtil implements IUtil {
|
||||
dt.stop();
|
||||
}
|
||||
}
|
||||
if (mDownloaderMap.size() == 0){
|
||||
if (mDownloaderMap.size() == 0) {
|
||||
mListener.onStop(mCurrentLocation);
|
||||
}
|
||||
}
|
||||
@@ -540,6 +541,8 @@ public abstract class AbsGroupUtil implements IUtil {
|
||||
if (state == IEntity.STATE_CANCEL) {
|
||||
subEntity.deleteData();
|
||||
return;
|
||||
} else if (state == IEntity.STATE_STOP) {
|
||||
subEntity.setStopTime(System.currentTimeMillis());
|
||||
} else if (subEntity.isComplete()) {
|
||||
subEntity.setCompleteTime(System.currentTimeMillis());
|
||||
subEntity.setCurrentProgress(subEntity.getFileSize());
|
||||
|
||||
@@ -70,6 +70,11 @@ public abstract class AbsEntity extends DbEntity implements IEntity, Parcelable
|
||||
|
||||
private boolean isComplete = false;
|
||||
|
||||
/**
|
||||
* 上一次停止时间
|
||||
*/
|
||||
private long stopTime = 0;
|
||||
|
||||
public boolean isComplete() {
|
||||
return isComplete;
|
||||
}
|
||||
@@ -158,6 +163,14 @@ public abstract class AbsEntity extends DbEntity implements IEntity, Parcelable
|
||||
this.percent = percent;
|
||||
}
|
||||
|
||||
public long getStopTime() {
|
||||
return stopTime;
|
||||
}
|
||||
|
||||
public void setStopTime(long stopTime) {
|
||||
this.stopTime = stopTime;
|
||||
}
|
||||
|
||||
/**
|
||||
* 实体唯一标识符
|
||||
*/
|
||||
@@ -188,8 +201,9 @@ public abstract class AbsEntity extends DbEntity implements IEntity, Parcelable
|
||||
dest.writeInt(this.state);
|
||||
dest.writeLong(this.currentProgress);
|
||||
dest.writeLong(this.completeTime);
|
||||
dest.writeByte(this.isComplete ? (byte) 1 : (byte) 0);
|
||||
dest.writeInt(this.percent);
|
||||
dest.writeByte(this.isComplete ? (byte) 1 : (byte) 0);
|
||||
dest.writeLong(this.stopTime);
|
||||
}
|
||||
|
||||
protected AbsEntity(Parcel in) {
|
||||
@@ -202,7 +216,8 @@ public abstract class AbsEntity extends DbEntity implements IEntity, Parcelable
|
||||
this.state = in.readInt();
|
||||
this.currentProgress = in.readLong();
|
||||
this.completeTime = in.readLong();
|
||||
this.isComplete = in.readByte() != 0;
|
||||
this.percent = in.readInt();
|
||||
this.isComplete = in.readByte() != 0;
|
||||
this.stopTime = in.readLong();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -19,8 +19,6 @@ import android.os.Handler;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.common.TaskRecord;
|
||||
import com.arialyy.aria.core.inf.AbsEntity;
|
||||
import com.arialyy.aria.core.inf.AbsGroupEntity;
|
||||
import com.arialyy.aria.core.inf.AbsNormalEntity;
|
||||
import com.arialyy.aria.core.inf.AbsTask;
|
||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IEntity;
|
||||
@@ -155,6 +153,8 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
// CommonUtil.delGroupTaskRecord(mTaskEntity.isRemoveFile(), ((AbsGroupEntity) mEntity));
|
||||
//}
|
||||
return;
|
||||
} else if (state == IEntity.STATE_STOP) {
|
||||
mEntity.setStopTime(System.currentTimeMillis());
|
||||
} else if (mEntity.isComplete()) {
|
||||
mEntity.setCompleteTime(System.currentTimeMillis());
|
||||
mEntity.setCurrentProgress(mEntity.getFileSize());
|
||||
|
||||
@@ -35,7 +35,7 @@ class DBConfig {
|
||||
/*adb pull /mnt/sdcard/Android/data/com.arialyy.simple/files/DB/AriaLyyDb d:/db*/
|
||||
static Map<String, Class> mapping = new HashMap<>();
|
||||
static String DB_NAME;
|
||||
static int VERSION = 33;
|
||||
static int VERSION = 34;
|
||||
|
||||
/**
|
||||
* 是否将数据库保存在Sd卡,{@code true} 是
|
||||
|
||||
@@ -51,6 +51,7 @@ public class NetUtils {
|
||||
|
||||
/**
|
||||
* 判断网络是否连接
|
||||
* @return {@code true} 网络已连接、{@code false}网络未连接
|
||||
*/
|
||||
public static boolean isConnected(Context context) {
|
||||
ConnectivityManager cm =
|
||||
|
||||
@@ -1,6 +1,8 @@
|
||||
## 开发日志
|
||||
+ v_3.4.3
|
||||
- 修复在activity 的onStop中取消注册导致的内存泄露问题
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/258
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/259
|
||||
+ v_3.4.2
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/248
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/247
|
||||
|
||||
17
README.md
17
README.md
@@ -30,8 +30,8 @@ Aria有以下特点:
|
||||
[](https://bintray.com/arialyy/maven/AriaApi/_latestVersion)
|
||||
[](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion)
|
||||
```java
|
||||
compile 'com.arialyy.aria:aria-core:3.4.2'
|
||||
annotationProcessor 'com.arialyy.aria:aria-compiler:3.4.2'
|
||||
compile 'com.arialyy.aria:aria-core:3.4.3'
|
||||
annotationProcessor 'com.arialyy.aria:aria-compiler:3.4.3'
|
||||
```
|
||||
如果出现android support,请将 `compile 'com.arialyy.aria:aria-core:<last-version>'`替换为
|
||||
```
|
||||
@@ -99,15 +99,10 @@ protected void onCreate(Bundle savedInstanceState) {
|
||||
|
||||
|
||||
### 版本日志
|
||||
+ v_3.4.2
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/248
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/247
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/250
|
||||
- 添加任务判断是否存在的api
|
||||
- 添加代理api
|
||||
- 修复删除所有没有进出等待的问题
|
||||
- 进度有时出错的问题
|
||||
- FTP添加超时处理
|
||||
+ v_3.4.3
|
||||
- 修复在activity 的onStop中取消注册导致的内存泄露问题
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/258
|
||||
- fix bug https://github.com/AriaLyy/Aria/issues/259
|
||||
|
||||
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
||||
|
||||
|
||||
@@ -14,12 +14,12 @@
|
||||
android:supportsRtl="true"
|
||||
android:theme="@style/AppTheme.NoActionBar">
|
||||
<!--android:name=".test.TestActivity"-->
|
||||
<!--android:name=".test.AnyRunActivity"-->
|
||||
<!--android:name=".test.TestGroupActivity"-->
|
||||
<!--android:name=".test.AnyRunActivity"-->
|
||||
<!--android:name=".download.group.DownloadGroupActivity"-->
|
||||
<!--android:name=".MainActivity"-->
|
||||
<activity
|
||||
android:name=".MainActivity"
|
||||
android:name=".test.AnyRunActivity"
|
||||
android:label="@string/app_name">
|
||||
<intent-filter>
|
||||
<action android:name="android.intent.action.MAIN"/>
|
||||
|
||||
@@ -89,7 +89,7 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
||||
.start();
|
||||
break;
|
||||
case R.id.stop:
|
||||
Aria.download(this).load(mUrls).stop();
|
||||
Aria.download(this).loadGroup(mUrls).stop();
|
||||
break;
|
||||
case R.id.cancel:
|
||||
//Aria.download(this).load(mUrls).cancel(true);
|
||||
@@ -133,7 +133,12 @@ public class DownloadGroupActivity extends BaseActivity<ActivityDownloadGroupBin
|
||||
}
|
||||
|
||||
@DownloadGroup.onTaskRunning() protected void running(DownloadGroupTask task) {
|
||||
Log.d(TAG, "group running");
|
||||
Log.d(TAG, "group running, p = "
|
||||
+ task.getPercent()
|
||||
+ ", speed = "
|
||||
+ task.getConvertSpeed()
|
||||
+ "current_p = "
|
||||
+ task.getCurrentProgress());
|
||||
getBinding().setProgress(task.getPercent());
|
||||
getBinding().setSpeed(task.getConvertSpeed());
|
||||
mChildList.updateChildProgress(task.getEntity().getSubEntities());
|
||||
|
||||
@@ -65,12 +65,17 @@ public class AnyRunnModule {
|
||||
|
||||
void start(String url) {
|
||||
mUrl = url;
|
||||
String path = Environment.getExternalStorageDirectory().getPath() + "/abcds.exe";
|
||||
File file = new File(path);
|
||||
if (file.exists()) {
|
||||
file.delete();
|
||||
}
|
||||
Aria.download(this)
|
||||
.load(url)
|
||||
//.addHeader("Accept-Encoding", "gzip")
|
||||
.setRequestMode(RequestEnum.GET)
|
||||
.setUrlProxy(Proxy.NO_PROXY)
|
||||
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/abcds.exe")
|
||||
.setFilePath(path)
|
||||
//.resetState()
|
||||
.start();
|
||||
//String[] urls = new String[] {
|
||||
|
||||
@@ -39,7 +39,7 @@ task clean(type: Delete) {
|
||||
ext {
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = '3.4.3_dev1'
|
||||
publishVersion = '3.4.3'
|
||||
// publishVersion = '1.0.3' //FTP插件
|
||||
repoName='maven'
|
||||
desc = 'android 下载框架'
|
||||
|
||||
Reference in New Issue
Block a user