AriaLyy 7 years ago
parent 8e541a8b2a
commit 48429fbfe9
  1. 14
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
  2. 5
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTaskEntity.java
  3. 2
      Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java
  4. 4
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java

@ -56,16 +56,22 @@ public class DownloadTarget
}
private void initTask(DownloadEntity entity) {
mTaskEntity = DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false'",
entity.getDownloadPath());
mTaskEntity =
DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false' and url=?",
entity.getDownloadPath(), entity.getUrl());
if (mTaskEntity == null) {
mTaskEntity = new DownloadTaskEntity();
mTaskEntity.url = entity.getUrl();
mTaskEntity.key = entity.getDownloadPath();
mTaskEntity.entity = entity;
mTaskEntity.save();
}
if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getUrl())) {
} else if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getUrl())) {
mTaskEntity.entity = entity;
mTaskEntity.save();
} else if (!mTaskEntity.entity.getUrl().equals(entity.getUrl())) { //处理地址切换而保存路径不变
mTaskEntity.entity.deleteData();
mTaskEntity.entity = entity;
entity.save();
mTaskEntity.save();
}

@ -27,6 +27,11 @@ public class DownloadTaskEntity extends AbsTaskEntity<DownloadEntity> {
@OneToOne(table = DownloadEntity.class, key = "downloadPath") public DownloadEntity entity;
/**
* 任务的url
*/
public String url = "";
/**
* 所属的任务组组名如果不属于任务组则为null
*/

@ -33,7 +33,7 @@ import java.util.Map;
class DBConfig {
static Map<String, Class> mapping = new HashMap<>();
static String DB_NAME;
static int VERSION = 13;
static int VERSION = 14;
static {
if (TextUtils.isEmpty(DB_NAME)) {

@ -45,7 +45,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
private static final String DOWNLOAD_URL =
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
//"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
//"http://120.25.196.56:8000/filereq?id=15692406294&ipncid=105635&client=android&filename=20170819185541.avi";
//"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt";
@ -56,6 +55,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//不支持断点的链接
//"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-";
//"http://172.18.104.50:8080/download/_302turn";
//"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk";
@Bind(R.id.start) Button mStart;
@Bind(R.id.stop) Button mStop;
@Bind(R.id.cancel) Button mCancel;
@ -196,7 +196,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
Aria.download(SingleTaskActivity.this)
.load(DOWNLOAD_URL, true)
.addHeader("groupName", "value")
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/gggg.apk")
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk")
.start();
break;

Loading…
Cancel
Save