修复数据错乱的bug
This commit is contained in:
@ -27,16 +27,14 @@ import com.arialyy.aria.util.CheckUtil;
|
||||
* AM 接收器
|
||||
*/
|
||||
public class AMReceiver {
|
||||
String targetName;
|
||||
String targetName;
|
||||
OnSchedulerListener listener;
|
||||
DownloadEntity entity;
|
||||
Object obj;
|
||||
Object obj;
|
||||
|
||||
/**
|
||||
* {@link #load(String)},请使用该方法
|
||||
*/
|
||||
@Deprecated public AMTarget load(DownloadEntity entity) {
|
||||
this.entity = entity;
|
||||
return new AMTarget(entity, targetName);
|
||||
}
|
||||
|
||||
@ -45,9 +43,8 @@ public class AMReceiver {
|
||||
*/
|
||||
public AMTarget load(@NonNull String downloadUrl) {
|
||||
CheckUtil.checkDownloadUrl(downloadUrl);
|
||||
if (entity == null) {
|
||||
entity = DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
|
||||
}
|
||||
DownloadEntity entity =
|
||||
DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
|
||||
if (entity == null) {
|
||||
entity = new DownloadEntity();
|
||||
}
|
||||
|
@ -67,17 +67,24 @@ public class Task {
|
||||
/**
|
||||
* 获取文件大小
|
||||
*/
|
||||
public long getFileSize(){
|
||||
public long getFileSize() {
|
||||
return mEntity.getFileSize();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前下载进度
|
||||
*/
|
||||
public long getCurrentProgress(){
|
||||
public long getCurrentProgress() {
|
||||
return mEntity.getCurrentProgress();
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取当前下载任务的下载地址
|
||||
*/
|
||||
public String getDownloadUrl() {
|
||||
return mEntity.getDownloadUrl();
|
||||
}
|
||||
|
||||
/**
|
||||
* 开始下载
|
||||
*/
|
||||
@ -202,6 +209,7 @@ public class Task {
|
||||
public Task build() {
|
||||
Task task = new Task(context, downloadEntity, outHandler);
|
||||
task.setTargetName(targetName);
|
||||
//Log.w(TAG, "downloadEntity hashcode ==> " + downloadEntity.hashCode());
|
||||
downloadEntity.save();
|
||||
return task;
|
||||
}
|
||||
|
Reference in New Issue
Block a user