This commit is contained in:
@@ -56,17 +56,23 @@ public class DownloadTarget
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void initTask(DownloadEntity entity) {
|
private void initTask(DownloadEntity entity) {
|
||||||
mTaskEntity = DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false'",
|
mTaskEntity =
|
||||||
entity.getDownloadPath());
|
DbEntity.findFirst(DownloadTaskEntity.class, "key=? and isGroupTask='false' and url=?",
|
||||||
|
entity.getDownloadPath(), entity.getUrl());
|
||||||
if (mTaskEntity == null) {
|
if (mTaskEntity == null) {
|
||||||
mTaskEntity = new DownloadTaskEntity();
|
mTaskEntity = new DownloadTaskEntity();
|
||||||
|
mTaskEntity.url = entity.getUrl();
|
||||||
mTaskEntity.key = entity.getDownloadPath();
|
mTaskEntity.key = entity.getDownloadPath();
|
||||||
mTaskEntity.entity = entity;
|
mTaskEntity.entity = entity;
|
||||||
mTaskEntity.save();
|
mTaskEntity.save();
|
||||||
}
|
} else if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getUrl())) {
|
||||||
if (mTaskEntity.entity == null || TextUtils.isEmpty(mTaskEntity.entity.getUrl())) {
|
|
||||||
mTaskEntity.entity = entity;
|
mTaskEntity.entity = entity;
|
||||||
mTaskEntity.save();
|
mTaskEntity.save();
|
||||||
|
} else if (!mTaskEntity.entity.getUrl().equals(entity.getUrl())) { //处理地址切换而保存路径不变
|
||||||
|
mTaskEntity.entity.deleteData();
|
||||||
|
mTaskEntity.entity = entity;
|
||||||
|
entity.save();
|
||||||
|
mTaskEntity.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
mEntity = mTaskEntity.entity;
|
mEntity = mTaskEntity.entity;
|
||||||
|
@@ -27,6 +27,11 @@ public class DownloadTaskEntity extends AbsTaskEntity<DownloadEntity> {
|
|||||||
|
|
||||||
@OneToOne(table = DownloadEntity.class, key = "downloadPath") public DownloadEntity entity;
|
@OneToOne(table = DownloadEntity.class, key = "downloadPath") public DownloadEntity entity;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务的url
|
||||||
|
*/
|
||||||
|
public String url = "";
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 所属的任务组组名,如果不属于任务组,则为null
|
* 所属的任务组组名,如果不属于任务组,则为null
|
||||||
*/
|
*/
|
||||||
|
@@ -33,7 +33,7 @@ import java.util.Map;
|
|||||||
class DBConfig {
|
class DBConfig {
|
||||||
static Map<String, Class> mapping = new HashMap<>();
|
static Map<String, Class> mapping = new HashMap<>();
|
||||||
static String DB_NAME;
|
static String DB_NAME;
|
||||||
static int VERSION = 13;
|
static int VERSION = 14;
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (TextUtils.isEmpty(DB_NAME)) {
|
if (TextUtils.isEmpty(DB_NAME)) {
|
||||||
|
@@ -45,7 +45,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
private static final String DOWNLOAD_URL =
|
private static final String DOWNLOAD_URL =
|
||||||
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
//"http://kotlinlang.org/docs/kotlin-docs.pdf";
|
||||||
//"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe";
|
//"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://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://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";
|
//"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://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://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.start) Button mStart;
|
||||||
@Bind(R.id.stop) Button mStop;
|
@Bind(R.id.stop) Button mStop;
|
||||||
@Bind(R.id.cancel) Button mCancel;
|
@Bind(R.id.cancel) Button mCancel;
|
||||||
@@ -196,7 +196,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
Aria.download(SingleTaskActivity.this)
|
Aria.download(SingleTaskActivity.this)
|
||||||
.load(DOWNLOAD_URL, true)
|
.load(DOWNLOAD_URL, true)
|
||||||
.addHeader("groupName", "value")
|
.addHeader("groupName", "value")
|
||||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/gggg.apk")
|
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk")
|
||||||
.start();
|
.start();
|
||||||
|
|
||||||
break;
|
break;
|
||||||
|
Reference in New Issue
Block a user