AriaLyy 7 years ago
parent ce886921a6
commit c2ab04b67b
  1. 9
      Aria/src/main/java/com/arialyy/aria/core/command/normal/CancelAllCmd.java
  2. 26
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java
  3. 26
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  4. 43
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java
  5. 5
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java
  6. 2
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java
  7. 30
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadReceiver.java
  8. 31
      Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java
  9. 4
      Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
  10. 14
      Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java
  11. 2
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  12. 22
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  13. 9
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java

@ -20,6 +20,7 @@ import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity;
import com.arialyy.aria.orm.DbEntity; import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.util.List; import java.util.List;
@ -49,8 +50,8 @@ final class CancelAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
* 处理上传的删除 * 处理上传的删除
*/ */
private void handleUploadRemove() { private void handleUploadRemove() {
List<UploadEntity> allEntity = DbEntity.findAllData(UploadEntity.class); List<UploadTaskEntity> allEntity = DbEntity.findAllData(UploadTaskEntity.class);
for (UploadEntity entity : allEntity) { for (UploadTaskEntity entity : allEntity) {
CommonUtil.delUploadTaskConfig(mTaskEntity.removeFile, entity); CommonUtil.delUploadTaskConfig(mTaskEntity.removeFile, entity);
} }
} }
@ -59,8 +60,8 @@ final class CancelAllCmd<T extends AbsTaskEntity> extends AbsNormalCmd<T> {
* 处理下载的删除 * 处理下载的删除
*/ */
private void handleDownloadRemove() { private void handleDownloadRemove() {
List<DownloadEntity> allEntity = DbEntity.findAllData(DownloadEntity.class); List<DownloadTaskEntity> allEntity = DbEntity.findAllData(DownloadTaskEntity.class);
for (DownloadEntity entity : allEntity) { for (DownloadTaskEntity entity : allEntity) {
CommonUtil.delDownloadTaskConfig(mTaskEntity.removeFile, entity); CommonUtil.delDownloadTaskConfig(mTaskEntity.removeFile, entity);
} }
} }

@ -17,7 +17,9 @@ package com.arialyy.aria.core.download;
import com.arialyy.aria.core.inf.AbsGroupTarget; import com.arialyy.aria.core.inf.AbsGroupTarget;
import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import java.io.File; import java.io.File;
import java.util.List; import java.util.List;
@ -28,12 +30,28 @@ public class DownloadGroupTarget
extends AbsGroupTarget<DownloadGroupTarget, DownloadGroupEntity, DownloadGroupTaskEntity> { extends AbsGroupTarget<DownloadGroupTarget, DownloadGroupEntity, DownloadGroupTaskEntity> {
private List<String> mUrls; private List<String> mUrls;
DownloadGroupTarget(DownloadGroupEntity entity, String targetName, List<String> urls) { DownloadGroupTarget(List<String> urls, String targetName) {
this.mEntity = entity;
this.mTargetName = targetName; this.mTargetName = targetName;
this.mUrls = urls; this.mUrls = urls;
mTaskEntity = new DownloadGroupTaskEntity(); mTaskEntity =
mTaskEntity.entity = entity; DbEntity.findData(DownloadGroupTaskEntity.class, "key=?", CommonUtil.getMd5Code(urls));
if (mTaskEntity == null) {
mTaskEntity = new DownloadGroupTaskEntity();
mTaskEntity.entity = new DownloadGroupEntity();
}
if (mTaskEntity.entity == null) {
mTaskEntity.entity = getDownloadGroupEntity(urls);
}
mEntity = mTaskEntity.entity;
}
private DownloadGroupEntity getDownloadGroupEntity(List<String> urls) {
DownloadGroupEntity entity =
DbEntity.findData(DownloadGroupEntity.class, "urlHash=?", CommonUtil.getMd5Code(urls));
if (entity == null) {
entity = new DownloadGroupEntity();
}
return entity;
} }
/** /**

@ -60,17 +60,7 @@ public class DownloadReceiver extends AbsReceiver<DownloadEntity> {
*/ */
public DownloadTarget load(@NonNull String downloadUrl) { public DownloadTarget load(@NonNull String downloadUrl) {
CheckUtil.checkDownloadUrl(downloadUrl); CheckUtil.checkDownloadUrl(downloadUrl);
DownloadEntity entity = return new DownloadTarget(downloadUrl, targetName);
DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
if (entity == null) {
entity = new DownloadEntity();
}
File file = new File(entity.getDownloadPath());
if (!file.exists()) {
entity.setState(IEntity.STATE_WAIT);
}
entity.setDownloadUrl(downloadUrl);
return new DownloadTarget(entity, targetName);
} }
/** /**
@ -78,13 +68,7 @@ public class DownloadReceiver extends AbsReceiver<DownloadEntity> {
*/ */
public DownloadGroupTarget load(List<String> urls) { public DownloadGroupTarget load(List<String> urls) {
CheckUtil.checkDownloadUrls(urls); CheckUtil.checkDownloadUrls(urls);
DownloadGroupEntity entity = return new DownloadGroupTarget(urls, targetName);
DbEntity.findData(DownloadGroupEntity.class, "urlHash=?", CommonUtil.getMd5Code(urls));
if (entity == null) {
entity = new DownloadGroupEntity();
}
return new DownloadGroupTarget(entity, targetName, urls);
} }
/** /**
@ -179,10 +163,8 @@ public class DownloadReceiver extends AbsReceiver<DownloadEntity> {
*/ */
@Override public void removeAllTask(boolean removeFile) { @Override public void removeAllTask(boolean removeFile) {
final AriaManager ariaManager = AriaManager.getInstance(AriaManager.APP); final AriaManager ariaManager = AriaManager.getInstance(AriaManager.APP);
AriaManager.getInstance(AriaManager.APP) ariaManager.setCmd(CommonUtil.createCmd(targetName, new DownloadTaskEntity(),
.setCmd(CommonUtil.createCmd(targetName, new DownloadTaskEntity(), NormalCmdFactory.TASK_CANCEL_ALL)).exe();
NormalCmdFactory.TASK_CANCEL_ALL))
.exe();
Set<String> keys = ariaManager.getReceiver().keySet(); Set<String> keys = ariaManager.getReceiver().keySet();
for (String key : keys) { for (String key : keys) {

@ -18,21 +18,52 @@ package com.arialyy.aria.core.download;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import android.text.TextUtils; import android.text.TextUtils;
import com.arialyy.aria.core.inf.AbsNormalTarget; import com.arialyy.aria.core.inf.AbsNormalTarget;
import com.arialyy.aria.core.inf.IEntity;
import com.arialyy.aria.core.queue.DownloadTaskQueue; import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.orm.DbEntity;
import java.io.File; import java.io.File;
/** /**
* Created by lyy on 2016/12/5. * Created by lyy on 2016/12/5.
* https://github.com/AriaLyy/Aria * https://github.com/AriaLyy/Aria
*/ */
public class DownloadTarget extends public class DownloadTarget
AbsNormalTarget<DownloadTarget, DownloadEntity, DownloadTaskEntity> { extends AbsNormalTarget<DownloadTarget, DownloadEntity, DownloadTaskEntity> {
DownloadTarget(DownloadEntity entity, String targetName) { DownloadTarget(DownloadEntity entity, String targetName) {
mEntity = entity; this(entity.getDownloadUrl(), targetName);
}
DownloadTarget(String url, String targetName) {
mTargetName = targetName; mTargetName = targetName;
mTaskEntity = new DownloadTaskEntity(); mTaskEntity = DbEntity.findData(DownloadTaskEntity.class, "key=?", url);
mTaskEntity.entity = mEntity; if (mTaskEntity == null) {
mTaskEntity = new DownloadTaskEntity();
mTaskEntity.entity = new DownloadEntity();
}
if (mTaskEntity.entity == null) {
mTaskEntity.entity = getEntity(url);
}
mEntity = mTaskEntity.entity;
}
/**
* 如果任务存在但是下载实体不存在则通过下载地址获取下载实体
*
* @param downloadUrl 下载地址
*/
private DownloadEntity getEntity(String downloadUrl) {
DownloadEntity entity =
DownloadEntity.findData(DownloadEntity.class, "downloadUrl=?", downloadUrl);
if (entity == null) {
entity = new DownloadEntity();
}
File file = new File(entity.getDownloadPath());
if (!file.exists()) {
entity.setState(IEntity.STATE_WAIT);
}
entity.setDownloadUrl(downloadUrl);
return entity;
} }
/** /**
@ -56,7 +87,6 @@ public class DownloadTarget extends
return this; return this;
} }
/** /**
* 下载任务是否存在 * 下载任务是否存在
*/ */
@ -64,7 +94,6 @@ public class DownloadTarget extends
return DownloadTaskQueue.getInstance().getTask(mEntity.getDownloadUrl()) != null; return DownloadTaskQueue.getInstance().getTask(mEntity.getDownloadUrl()) != null;
} }
/** /**
* 设置文件存储路径 * 设置文件存储路径
*/ */

@ -17,7 +17,6 @@
package com.arialyy.aria.core.download; package com.arialyy.aria.core.download;
import android.content.Context; import android.content.Context;
import android.content.Intent;
import android.os.Handler; import android.os.Handler;
import android.util.Log; import android.util.Log;
import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.AriaManager;
@ -138,7 +137,7 @@ public class DownloadTask extends AbsNormalTask<DownloadEntity> {
mUtil.stopDownload(); mUtil.stopDownload();
} else { } else {
mEntity.setState(isWait ? IEntity.STATE_WAIT : IEntity.STATE_STOP); mEntity.setState(isWait ? IEntity.STATE_WAIT : IEntity.STATE_STOP);
mEntity.save(); mEntity.update();
if (mOutHandler != null) { if (mOutHandler != null) {
mOutHandler.obtainMessage(ISchedulers.STOP, this).sendToTarget(); mOutHandler.obtainMessage(ISchedulers.STOP, this).sendToTarget();
} }
@ -184,6 +183,7 @@ public class DownloadTask extends AbsNormalTask<DownloadEntity> {
DownloadTask task = new DownloadTask(taskEntity, outHandler); DownloadTask task = new DownloadTask(taskEntity, outHandler);
task.setTargetName(targetName); task.setTargetName(targetName);
taskEntity.getEntity().save(); taskEntity.getEntity().save();
taskEntity.save();
return task; return task;
} }
} }
@ -305,6 +305,7 @@ public class DownloadTask extends AbsNormalTask<DownloadEntity> {
entity.setDownloadComplete(state == IEntity.STATE_COMPLETE); entity.setDownloadComplete(state == IEntity.STATE_COMPLETE);
entity.setCurrentProgress(location); entity.setCurrentProgress(location);
entity.update(); entity.update();
} }
} }
} }

@ -82,7 +82,7 @@ class Downloader implements Runnable, IDownloadUtil {
/** /**
* 开始下载流程 * 开始下载流程
*/ */
private void startFlow(){ private void startFlow() {
checkTask(); checkTask();
mConstance.cleanState(); mConstance.cleanState();
mConstance.isDownloading = true; mConstance.isDownloading = true;

@ -48,17 +48,7 @@ public class UploadReceiver extends AbsReceiver<UploadEntity> {
*/ */
public UploadTarget load(@NonNull String filePath) { public UploadTarget load(@NonNull String filePath) {
CheckUtil.checkUploadPath(filePath); CheckUtil.checkUploadPath(filePath);
UploadEntity entity = UploadEntity.findData(UploadEntity.class, "filePath=?", filePath); return new UploadTarget(filePath, targetName);
if (entity == null) {
entity = new UploadEntity();
}
String regex = "[/|\\\\|//]";
Pattern p = Pattern.compile(regex);
String[] strs = p.split(filePath);
String fileName = strs[strs.length - 1];
entity.setFileName(fileName);
entity.setFilePath(filePath);
return new UploadTarget(entity, targetName);
} }
/** /**
@ -81,15 +71,10 @@ public class UploadReceiver extends AbsReceiver<UploadEntity> {
} }
@Override public void stopAllTask() { @Override public void stopAllTask() {
List<UploadEntity> allEntity = DbEntity.findAllData(UploadEntity.class); AriaManager.getInstance(AriaManager.APP)
List<AbsNormalCmd> stopCmds = new ArrayList<>(); .setCmd(NormalCmdFactory.getInstance()
for (UploadEntity entity : allEntity) { .createCmd(targetName, new UploadTaskEntity(), NormalCmdFactory.TASK_STOP_ALL))
if (entity.getState() == IEntity.STATE_RUNNING) { .exe();
stopCmds.add(
CommonUtil.createCmd(targetName, new UploadTaskEntity(), NormalCmdFactory.TASK_STOP));
}
}
AriaManager.getInstance(AriaManager.APP).setCmds(stopCmds).exe();
} }
/** /**
@ -101,9 +86,8 @@ public class UploadReceiver extends AbsReceiver<UploadEntity> {
@Override public void removeAllTask(boolean removeFile) { @Override public void removeAllTask(boolean removeFile) {
final AriaManager am = AriaManager.getInstance(AriaManager.APP); final AriaManager am = AriaManager.getInstance(AriaManager.APP);
AriaManager.getInstance(AriaManager.APP) am.setCmd(CommonUtil.createCmd(targetName, new DownloadTaskEntity(),
.setCmd( NormalCmdFactory.TASK_CANCEL_ALL))
CommonUtil.createCmd(targetName, new DownloadTaskEntity(), NormalCmdFactory.TASK_CANCEL_ALL))
.exe(); .exe();
Set<String> keys = am.getReceiver().keySet(); Set<String> keys = am.getReceiver().keySet();

@ -18,17 +18,39 @@ package com.arialyy.aria.core.upload;
import android.support.annotation.NonNull; import android.support.annotation.NonNull;
import com.arialyy.aria.core.inf.AbsNormalTarget; import com.arialyy.aria.core.inf.AbsNormalTarget;
import com.arialyy.aria.core.queue.UploadTaskQueue; import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.orm.DbEntity;
import java.util.regex.Pattern;
/** /**
* Created by lyy on 2017/2/28. * Created by lyy on 2017/2/28.
*/ */
public class UploadTarget extends AbsNormalTarget<UploadTarget, UploadEntity, UploadTaskEntity> { public class UploadTarget extends AbsNormalTarget<UploadTarget, UploadEntity, UploadTaskEntity> {
UploadTarget(UploadEntity entity, String targetName) { UploadTarget(String filePath, String targetName) {
this.mEntity = entity;
this.mTargetName = targetName; this.mTargetName = targetName;
mTaskEntity = new UploadTaskEntity(); mTaskEntity = DbEntity.findData(UploadTaskEntity.class, "key=?", filePath);
mTaskEntity.entity = entity; if (mTaskEntity == null) {
mTaskEntity = new UploadTaskEntity();
mTaskEntity.entity = new UploadEntity();
}
if (mTaskEntity.entity == null) {
mTaskEntity.entity = getUploadEntity(filePath);
}
mEntity = mTaskEntity.entity;
}
private UploadEntity getUploadEntity(String filePath) {
UploadEntity entity = UploadEntity.findData(UploadEntity.class, "filePath=?", filePath);
if (entity == null) {
entity = new UploadEntity();
}
String regex = "[/|\\\\|//]";
Pattern p = Pattern.compile(regex);
String[] strs = p.split(filePath);
String fileName = strs[strs.length - 1];
entity.setFileName(fileName);
entity.setFilePath(filePath);
return entity;
} }
/** /**
@ -91,5 +113,4 @@ public class UploadTarget extends AbsNormalTarget<UploadTarget, UploadEntity, Up
UploadTask task = UploadTaskQueue.getInstance().getTask(mEntity); UploadTask task = UploadTaskQueue.getInstance().getTask(mEntity);
return task != null && task.isRunning(); return task != null && task.isRunning();
} }
} }

@ -99,7 +99,6 @@ public class DbEntity {
* 删除当前数据 * 删除当前数据
*/ */
public void deleteData() { public void deleteData() {
//mUtil.delData(getClass(), new Object[] { "rowid" }, new Object[] { rowID });
deleteData(getClass(), "rowid=?", rowID + ""); deleteData(getClass(), "rowid=?", rowID + "");
} }
@ -138,7 +137,8 @@ public class DbEntity {
* 查找数据在表中是否存在 * 查找数据在表中是否存在
*/ */
private boolean thisIsExist() { private boolean thisIsExist() {
return findData(getClass(), "rowid=?", rowID + "") != null; DbUtil util = DbUtil.getInstance();
return util.isExist(getClass(), rowID);
} }
/** /**

@ -97,6 +97,18 @@ public class DbUtil {
return SqlHelper.findData(mDb, clazz, expression); return SqlHelper.findData(mDb, clazz, expression);
} }
/**
* 通过rowId判断数据是否存在
*/
synchronized <T extends DbEntity> boolean isExist(Class<T> clazz, int rowId) {
checkDb();
String sql = "SELECT rowid FROM " + CommonUtil.getClassName(clazz) + " WHERE rowid=" + rowId;
Cursor cursor = mDb.rawQuery(sql, null);
boolean isExist = cursor.getCount() > 0;
cursor.close();
return isExist;
}
/** /**
* 条件查寻数据 * 条件查寻数据
*/ */
@ -127,7 +139,7 @@ public class DbUtil {
SqlHelper.createTable(mDb, clazz, tableName); SqlHelper.createTable(mDb, clazz, tableName);
} }
private void checkDb(){ private void checkDb() {
if (mDb == null || !mDb.isOpen()) { if (mDb == null || !mDb.isOpen()) {
mDb = mHelper.getReadableDatabase(); mDb = mHelper.getReadableDatabase();
} }

@ -613,7 +613,7 @@ final class SqlHelper extends SQLiteOpenHelper {
String primaryData = cursor.getString(kc); String primaryData = cursor.getString(kc);
if (TextUtils.isEmpty(primaryData) || primaryData.equalsIgnoreCase("null")) continue; if (TextUtils.isEmpty(primaryData) || primaryData.equalsIgnoreCase("null")) continue;
List<T> list = findForeignData(db, primaryData, params); List<T> list = findForeignData(db, primaryData, params);
if (list != null && list.size() > 1) { if (list != null && list.size() > 0) {
field.set(entity, list.get(0)); field.set(entity, list.get(0));
} }
} }

@ -26,8 +26,10 @@ import com.arialyy.aria.core.AriaManager;
import com.arialyy.aria.core.command.normal.NormalCmdFactory; import com.arialyy.aria.core.command.normal.NormalCmdFactory;
import com.arialyy.aria.core.command.normal.AbsNormalCmd; import com.arialyy.aria.core.command.normal.AbsNormalCmd;
import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.download.DownloadTaskEntity;
import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.inf.AbsTaskEntity;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity;
import java.io.File; import java.io.File;
import java.io.FileFilter; import java.io.FileFilter;
import java.io.FileInputStream; import java.io.FileInputStream;
@ -134,19 +136,21 @@ public class CommonUtil {
* @param removeFile {@code true} 删除已经上传完成的任务不仅删除上传记录还会删除已经上传完成的文件{@code false} * @param removeFile {@code true} 删除已经上传完成的任务不仅删除上传记录还会删除已经上传完成的文件{@code false}
* 如果文件已经上传完成只删除上传记录 * 如果文件已经上传完成只删除上传记录
*/ */
public static void delUploadTaskConfig(boolean removeFile, UploadEntity entity) { public static void delUploadTaskConfig(boolean removeFile, UploadTaskEntity tEntity) {
UploadEntity uEntity = tEntity.getEntity();
if (removeFile) { if (removeFile) {
File file = new File(entity.getFilePath()); File file = new File(uEntity.getFilePath());
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
} }
} }
File config = new File( File config = new File(
AriaManager.APP.getFilesDir().getPath() + "/temp/" + entity.getFileName() + ".properties"); AriaManager.APP.getFilesDir().getPath() + "/temp/" + uEntity.getFileName() + ".properties");
if (config.exists()) { if (config.exists()) {
config.delete(); config.delete();
} }
entity.deleteData(); uEntity.deleteData();
tEntity.deleteData();
} }
/** /**
@ -155,19 +159,21 @@ public class CommonUtil {
* @param removeFile{@code true} 删除已经下载完成的任务不仅删除下载记录还会删除已经下载完成的文件{@code false} * @param removeFile{@code true} 删除已经下载完成的任务不仅删除下载记录还会删除已经下载完成的文件{@code false}
* 如果文件已经下载完成只删除下载记录 * 如果文件已经下载完成只删除下载记录
*/ */
public static void delDownloadTaskConfig(boolean removeFile, DownloadEntity entity) { public static void delDownloadTaskConfig(boolean removeFile, DownloadTaskEntity tEntity) {
DownloadEntity dEntity = tEntity.getEntity();
if (removeFile) { if (removeFile) {
File file = new File(entity.getDownloadPath()); File file = new File(dEntity.getDownloadPath());
if (file.exists()) { if (file.exists()) {
file.delete(); file.delete();
} }
} }
File config = new File( File config = new File(
AriaManager.APP.getFilesDir().getPath() + "/temp/" + entity.getFileName() + ".properties"); AriaManager.APP.getFilesDir().getPath() + "/temp/" + dEntity.getFileName() + ".properties");
if (config.exists()) { if (config.exists()) {
config.delete(); config.delete();
} }
entity.deleteData(); dEntity.deleteData();
tEntity.deleteData();
} }
/** /**

@ -62,10 +62,10 @@ 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://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";
//"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815"; //"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815";
//"http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk"; "http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk";
//"http://oqcpqqvuf.bkt.clouddn.com/ceshi.txt"; //"http://oqcpqqvuf.bkt.clouddn.com/ceshi.txt";
//"http://down8.androidgame-store.com/201706122321/97967927DD4E53D9905ECAA7874C8128/new/game1/19/45319/com.neuralprisma-2.5.2.174-2000174_1494784835.apk?f=web_1"; //"http://down8.androidgame-store.com/201706122321/97967927DD4E53D9905ECAA7874C8128/new/game1/19/45319/com.neuralprisma-2.5.2.174-2000174_1494784835.apk?f=web_1";
//不支持断点的链接 //不支持断点的链接
@ -209,10 +209,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
@Download.onTaskCancel(DOWNLOAD_URL) void taskCancel(DownloadTask task) { @Download.onTaskCancel(DOWNLOAD_URL) void taskCancel(DownloadTask task) {
mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL); mUpdateHandler.sendEmptyMessage(DOWNLOAD_CANCEL);
L.d(TAG, "task__cancel"); L.d(TAG, "task__cancel");
//Aria.download(this)
// .load(DOWNLOAD_URL)
// .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk")
// .add();
} }
@Download.onTaskFail(DOWNLOAD_URL) void taskFail(DownloadTask task) { @Download.onTaskFail(DOWNLOAD_URL) void taskFail(DownloadTask task) {
@ -255,6 +251,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
if (text.equals("重新开始?") || text.equals("开始")) { if (text.equals("重新开始?") || text.equals("开始")) {
Aria.download(this) Aria.download(this)
.load(DOWNLOAD_URL) .load(DOWNLOAD_URL)
.addHeader("key", "value")
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk") .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/test.apk")
.start(); .start();
} else if (text.equals("恢复")) { } else if (text.equals("恢复")) {

Loading…
Cancel
Save