修复了字符串中有特殊字符导致的路径冲突问题;修复ftp分块下载失败问题
This commit is contained in:
@@ -489,7 +489,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
}
|
||||
if (mConstance.CURRENT_LOCATION != 0
|
||||
&& mConstance.CURRENT_LOCATION != mEntity.getCurrentProgress()) {
|
||||
ALog.d(TAG, "进度修正");
|
||||
ALog.d(TAG, String.format("进度修正,当前进度:%s", mConstance.CURRENT_LOCATION));
|
||||
mEntity.setCurrentProgress(mConstance.CURRENT_LOCATION);
|
||||
}
|
||||
saveRecord();
|
||||
|
||||
@@ -49,6 +49,9 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
*/
|
||||
private final int RETRY_INTERVAL = 5000;
|
||||
private final String TAG = "AbsThreadTask";
|
||||
/**
|
||||
* 当前子线程的下载位置
|
||||
*/
|
||||
protected long mChildCurrentLocation = 0, mSleepTime = 0;
|
||||
protected int mBufSize;
|
||||
protected IEventListener mListener;
|
||||
@@ -185,6 +188,8 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
protected void progress(long len) {
|
||||
synchronized (AriaManager.LOCK) {
|
||||
if (STATE.CURRENT_LOCATION > mEntity.getFileSize()) {
|
||||
ALog.d(TAG, String.format("currentLocation=%s, fileSize=%s", STATE.CURRENT_LOCATION,
|
||||
mEntity.getFileSize()));
|
||||
taskBreak = true;
|
||||
fail(mChildCurrentLocation, "下载失败,下载长度超出文件大小", null, false);
|
||||
return;
|
||||
|
||||
@@ -60,7 +60,7 @@ public class StateConstance {
|
||||
ALog.d(TAG, String.format("fail_num=%s; start_thread_num=%s, complete_num=%s", FAIL_NUM,
|
||||
START_THREAD_NUM, COMPLETE_THREAD_NUM));
|
||||
return COMPLETE_THREAD_NUM != START_THREAD_NUM
|
||||
&& FAIL_NUM == START_THREAD_NUM;
|
||||
&& (FAIL_NUM == START_THREAD_NUM || FAIL_NUM + COMPLETE_THREAD_NUM == START_THREAD_NUM);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -37,12 +37,12 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
|
||||
/**
|
||||
* 通过地址初始化target
|
||||
*/
|
||||
void initTarget(String url, String targetName, boolean refreshInfo) {
|
||||
void initTarget(String url, String targetName) {
|
||||
this.url = url;
|
||||
mTargetName = targetName;
|
||||
mTaskEntity = TEManager.getInstance().getTEntity(DownloadTaskEntity.class, url);
|
||||
mEntity = mTaskEntity.getEntity();
|
||||
mTaskEntity.setRefreshInfo(refreshInfo);
|
||||
|
||||
if (mEntity != null) {
|
||||
mTempFilePath = mEntity.getDownloadPath();
|
||||
}
|
||||
@@ -63,6 +63,7 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
|
||||
return (TARGET) this;
|
||||
}
|
||||
this.newUrl = newUrl;
|
||||
mTaskEntity.setRefreshInfo(true);
|
||||
return (TARGET) this;
|
||||
}
|
||||
|
||||
@@ -199,6 +200,10 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
|
||||
ALog.e(TAG, "下载失败,url【" + url + "】不合法");
|
||||
return false;
|
||||
}
|
||||
if (!TextUtils.isEmpty(newUrl)){
|
||||
mEntity.setUrl(newUrl);
|
||||
mTaskEntity.setUrl(newUrl);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -18,7 +18,6 @@ package com.arialyy.aria.core.download;
|
||||
import android.support.annotation.CheckResult;
|
||||
import android.support.annotation.NonNull;
|
||||
import android.text.TextUtils;
|
||||
import android.util.Log;
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.command.ICmd;
|
||||
import com.arialyy.aria.core.command.normal.CancelAllCmd;
|
||||
@@ -27,7 +26,6 @@ import com.arialyy.aria.core.common.ProxyHelper;
|
||||
import com.arialyy.aria.core.download.wrapper.DGEWrapper;
|
||||
import com.arialyy.aria.core.inf.AbsEntity;
|
||||
import com.arialyy.aria.core.inf.AbsReceiver;
|
||||
import com.arialyy.aria.core.inf.AbsTarget;
|
||||
import com.arialyy.aria.core.inf.ReceiverType;
|
||||
import com.arialyy.aria.core.manager.TEManager;
|
||||
import com.arialyy.aria.core.scheduler.DownloadGroupSchedulers;
|
||||
@@ -64,28 +62,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
*/
|
||||
@CheckResult
|
||||
public DownloadTarget load(DownloadEntity entity) {
|
||||
return load(entity, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用下载实体执行下载操作
|
||||
*
|
||||
* @param refreshInfo 是否刷新下载信息
|
||||
* @deprecated 请使用 {@link AbsTarget#resetState()}
|
||||
* <pre>
|
||||
* <code>
|
||||
* Aria.download(this)
|
||||
* .load(URL)
|
||||
* .setDownloadPath(PATH)
|
||||
* .resetState()
|
||||
* .start();
|
||||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
@CheckResult
|
||||
@Deprecated public DownloadTarget load(DownloadEntity entity, boolean refreshInfo) {
|
||||
CheckUtil.checkDownloadEntity(entity);
|
||||
return new DownloadTarget(entity, targetName, refreshInfo);
|
||||
return new DownloadTarget(entity, targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -95,29 +72,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
*/
|
||||
@CheckResult
|
||||
public DownloadTarget load(@NonNull String url) {
|
||||
return load(url, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载Http、https单任务下载地址
|
||||
*
|
||||
* @param url 下载地址
|
||||
* @param refreshInfo 是否刷新下载信息,当下载地址改变而保存路径不变,则需要设置该参数为{@code true}
|
||||
* @deprecated 请使用 {@link AbsTarget#resetState()}
|
||||
* <pre>
|
||||
* <code>
|
||||
* Aria.download(this)
|
||||
* .load(URL)
|
||||
* .setDownloadPath(PATH)
|
||||
* .resetState()
|
||||
* .start();
|
||||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
@CheckResult
|
||||
@Deprecated public DownloadTarget load(@NonNull String url, boolean refreshInfo) {
|
||||
CheckUtil.checkUrlInvalidThrow(url);
|
||||
return new DownloadTarget(url, targetName, refreshInfo);
|
||||
return new DownloadTarget(url, targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,31 +103,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
*/
|
||||
@CheckResult
|
||||
public FtpDownloadTarget loadFtp(DownloadEntity entity) {
|
||||
return loadFtp(entity, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 使用下载实体执行下载操作
|
||||
*
|
||||
* @param refreshInfo 是否刷新下载信息,当下载地址改变而保存路径不变,则需要设置该参数为{@code true}
|
||||
* @deprecated 请使用 {@link AbsTarget#resetState()}
|
||||
* <pre>
|
||||
* <code>
|
||||
* Aria.download(this)
|
||||
* .load(URL)
|
||||
* .setDownloadPath(PATH)
|
||||
* .resetState()
|
||||
* .start();
|
||||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
@CheckResult
|
||||
@Deprecated public FtpDownloadTarget loadFtp(DownloadEntity entity, boolean refreshInfo) {
|
||||
CheckUtil.checkDownloadEntity(entity);
|
||||
if (!entity.getUrl().startsWith("ftp")) {
|
||||
throw new IllegalArgumentException("非FTP请求不能使用该方法");
|
||||
}
|
||||
return new FtpDownloadTarget(entity, targetName, refreshInfo);
|
||||
return new FtpDownloadTarget(entity, targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -180,18 +111,7 @@ public class DownloadReceiver extends AbsReceiver {
|
||||
*/
|
||||
@CheckResult
|
||||
public FtpDownloadTarget loadFtp(@NonNull String url) {
|
||||
return loadFtp(url, false);
|
||||
}
|
||||
|
||||
/**
|
||||
* 加载ftp单任务下载地址
|
||||
*
|
||||
* @param refreshInfo 是否刷新下载信息
|
||||
*/
|
||||
@CheckResult
|
||||
public FtpDownloadTarget loadFtp(@NonNull String url, boolean refreshInfo) {
|
||||
CheckUtil.checkUrlInvalidThrow(url);
|
||||
return new FtpDownloadTarget(url, targetName, refreshInfo);
|
||||
return new FtpDownloadTarget(url, targetName);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -31,20 +31,13 @@ public class DownloadTarget extends BaseNormalTarget<DownloadTarget>
|
||||
implements IHttpHeaderTarget<DownloadTarget> {
|
||||
private HttpHeaderDelegate<DownloadTarget, DownloadEntity, DownloadTaskEntity> mDelegate;
|
||||
|
||||
public DownloadTarget(DownloadEntity entity, String targetName) {
|
||||
this(entity, targetName, false);
|
||||
}
|
||||
|
||||
DownloadTarget(DownloadEntity entity, String targetName, boolean refreshInfo) {
|
||||
this(entity.getUrl(), targetName, refreshInfo);
|
||||
DownloadTarget(DownloadEntity entity, String targetName) {
|
||||
this(entity.getUrl(), targetName);
|
||||
}
|
||||
|
||||
DownloadTarget(String url, String targetName) {
|
||||
this(url, targetName, false);
|
||||
}
|
||||
|
||||
DownloadTarget(String url, String targetName, boolean refreshInfo) {
|
||||
initTarget(url, targetName, refreshInfo);
|
||||
initTarget(url, targetName);
|
||||
mDelegate = new HttpHeaderDelegate<>(this, mTaskEntity);
|
||||
}
|
||||
|
||||
|
||||
@@ -30,24 +30,19 @@ public class FtpDownloadTarget extends BaseNormalTarget<FtpDownloadTarget>
|
||||
implements IFtpTarget<FtpDownloadTarget> {
|
||||
private FtpDelegate<FtpDownloadTarget, DownloadEntity, DownloadTaskEntity> mDelegate;
|
||||
|
||||
public FtpDownloadTarget(DownloadEntity entity, String targetName, boolean refreshInfo) {
|
||||
this(entity.getUrl(), targetName, refreshInfo);
|
||||
public FtpDownloadTarget(DownloadEntity entity, String targetName) {
|
||||
this(entity.getUrl(), targetName);
|
||||
}
|
||||
|
||||
FtpDownloadTarget(String url, String targetName) {
|
||||
this(url, targetName, false);
|
||||
initTarget(url, targetName);
|
||||
init();
|
||||
}
|
||||
|
||||
FtpDownloadTarget(String url, String targetName, boolean refreshInfo) {
|
||||
initTarget(url, targetName, refreshInfo);
|
||||
init(refreshInfo);
|
||||
}
|
||||
|
||||
private void init(boolean refreshInfo) {
|
||||
private void init() {
|
||||
int lastIndex = url.lastIndexOf("/");
|
||||
mEntity.setFileName(url.substring(lastIndex + 1, url.length()));
|
||||
mTaskEntity.setUrlEntity(CommonUtil.getFtpUrlInfo(url));
|
||||
mTaskEntity.setRefreshInfo(refreshInfo);
|
||||
mTaskEntity.setRequestType(AbsTaskEntity.D_FTP);
|
||||
|
||||
mDelegate = new FtpDelegate<>(this, mTaskEntity);
|
||||
|
||||
@@ -61,7 +61,6 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
handleComplete();
|
||||
return;
|
||||
}
|
||||
//当前子线程的下载位置
|
||||
mChildCurrentLocation = mConfig.START_LOCATION;
|
||||
FTPClient client = null;
|
||||
InputStream is = null;
|
||||
@@ -172,10 +171,19 @@ class FtpThreadTask extends AbsFtpThreadTask<DownloadEntity, DownloadTaskEntity>
|
||||
if (mSleepTime > 0) {
|
||||
Thread.sleep(mSleepTime);
|
||||
}
|
||||
bf.flip();
|
||||
foc.write(bf);
|
||||
bf.compact();
|
||||
progress(len);
|
||||
if (mChildCurrentLocation + len >= mConfig.END_LOCATION) {
|
||||
len = (int) (mConfig.END_LOCATION - mChildCurrentLocation);
|
||||
bf.flip();
|
||||
fos.write(bf.array(), 0, len);
|
||||
bf.compact();
|
||||
progress(len);
|
||||
break;
|
||||
} else {
|
||||
bf.flip();
|
||||
foc.write(bf);
|
||||
bf.compact();
|
||||
progress(len);
|
||||
}
|
||||
}
|
||||
handleComplete();
|
||||
} catch (InterruptedException e) {
|
||||
|
||||
@@ -56,7 +56,7 @@ class HttpFileInfoThread implements Runnable {
|
||||
URL url = new URL(CommonUtil.convertUrl(mEntity.getUrl()));
|
||||
conn = ConnectionHelp.handleConnection(url, mTaskEntity);
|
||||
conn = ConnectionHelp.setConnectParam(mTaskEntity, conn);
|
||||
//conn.setRequestProperty("Range", "bytes=" + 0 + "-");
|
||||
conn.setRequestProperty("Range", "bytes=" + 0 + "-");
|
||||
conn.setConnectTimeout(mConnectTimeOut);
|
||||
//conn.setChunkedStreamingMode(0);
|
||||
conn.connect();
|
||||
|
||||
@@ -88,6 +88,17 @@ abstract class AbsDelegate {
|
||||
return dbEntity.getClass().getName() + "_" + dbEntity.rowID;
|
||||
}
|
||||
|
||||
/**
|
||||
* URL编码字符串
|
||||
*
|
||||
* @param str 原始字符串
|
||||
* @return 编码后的字符串
|
||||
*/
|
||||
String encodeStr(String str) {
|
||||
str = str.replaceAll("\\\\+", "%2B");
|
||||
return URLEncoder.encode(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* 检查list参数是否合法,list只能是{@code List<String>}
|
||||
*
|
||||
@@ -122,19 +133,6 @@ abstract class AbsDelegate {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 为了防止特殊字符串导致存储失败,需要使用URL编码保存的字符串
|
||||
*
|
||||
* @param value 需要保存的内容
|
||||
* @return 转换后的内容
|
||||
*/
|
||||
String convertValue(String value) {
|
||||
if (!TextUtils.isEmpty(value) && value.contains("'")) {
|
||||
return URLEncoder.encode(value);
|
||||
}
|
||||
return value;
|
||||
}
|
||||
|
||||
void closeCursor(Cursor cursor) {
|
||||
if (cursor != null && !cursor.isClosed()) {
|
||||
try {
|
||||
|
||||
@@ -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 = 35;
|
||||
static int VERSION = 39;
|
||||
|
||||
/**
|
||||
* 是否将数据库保存在Sd卡,{@code true} 是
|
||||
|
||||
@@ -76,7 +76,7 @@ class DelegateCommon extends AbsDelegate {
|
||||
Cursor cursor = null;
|
||||
try {
|
||||
String sql =
|
||||
String.format("SELECT name FROM sqlite_master WHERE type='table' AND name='%s'",
|
||||
String.format("SELECT COUNT(*) FROM sqlite_master WHERE type='table' AND name='%s'",
|
||||
tableName);
|
||||
print(TABLE_EXISTS, sql);
|
||||
cursor = db.rawQuery(sql, null);
|
||||
@@ -109,7 +109,7 @@ class DelegateCommon extends AbsDelegate {
|
||||
sql = sql.replace("?", "%s");
|
||||
Object[] params = new String[expression.length - 1];
|
||||
for (int i = 0, len = params.length; i < len; i++) {
|
||||
params[i] = "'" + expression[i + 1] + "'";
|
||||
params[i] = String.format("'%s'", encodeStr(expression[i + 1]));
|
||||
}
|
||||
sql = String.format(sql, params);
|
||||
print(FIND_DATA, sql);
|
||||
|
||||
@@ -169,7 +169,7 @@ class DelegateFind extends AbsDelegate {
|
||||
sql = sql.replace("?", "%s");
|
||||
Object[] params = new String[expression.length - 1];
|
||||
for (int i = 0, len = params.length; i < len; i++) {
|
||||
params[i] = "'" + convertValue(expression[i + 1]) + "'";
|
||||
params[i] = String.format("'%s'", encodeStr(expression[i + 1]));
|
||||
}
|
||||
sql = String.format(sql, params);
|
||||
} else {
|
||||
@@ -344,7 +344,7 @@ class DelegateFind extends AbsDelegate {
|
||||
sql = sql.replace("?", "%s");
|
||||
Object[] params = new String[expression.length - 1];
|
||||
for (int i = 0, len = params.length; i < len; i++) {
|
||||
params[i] = "'" + convertValue(expression[i + 1]) + "'";
|
||||
params[i] = String.format("'%s'", encodeStr(expression[i + 1]));
|
||||
}
|
||||
sql = String.format(sql, params);
|
||||
print(FIND_DATA, sql);
|
||||
|
||||
@@ -24,7 +24,6 @@ import com.arialyy.aria.util.CheckUtil;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import java.lang.reflect.Field;
|
||||
import java.lang.reflect.Type;
|
||||
import java.net.URLEncoder;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
@@ -91,7 +90,7 @@ class DelegateUpdate extends AbsDelegate {
|
||||
sql = sql.replace("?", "%s");
|
||||
Object[] params = new String[expression.length - 1];
|
||||
for (int i = 0, len = params.length; i < len; i++) {
|
||||
params[i] = "'" + expression[i + 1] + "'";
|
||||
params[i] = String.format("'%s'", encodeStr(expression[i + 1]));
|
||||
}
|
||||
sql = String.format(sql, params);
|
||||
print(DEL_DATA, sql);
|
||||
@@ -122,7 +121,7 @@ class DelegateUpdate extends AbsDelegate {
|
||||
value = SqlUtil.list2Str(dbEntity, field);
|
||||
} else {
|
||||
Object obj = field.get(dbEntity);
|
||||
value = obj == null ? "" : convertValue(obj.toString());
|
||||
value = obj == null ? "" : obj.toString();
|
||||
}
|
||||
values.put(field.getName(), encodeStr(value));
|
||||
}
|
||||
@@ -163,7 +162,7 @@ class DelegateUpdate extends AbsDelegate {
|
||||
} else {
|
||||
Object obj = field.get(dbEntity);
|
||||
if (obj != null) {
|
||||
value = convertValue(field.get(dbEntity).toString());
|
||||
value = field.get(dbEntity).toString();
|
||||
}
|
||||
}
|
||||
values.put(field.getName(), encodeStr(value));
|
||||
@@ -176,11 +175,6 @@ class DelegateUpdate extends AbsDelegate {
|
||||
close(db);
|
||||
}
|
||||
|
||||
private String encodeStr(String str) {
|
||||
str = str.replaceAll("\\\\+", "%2B");
|
||||
return URLEncoder.encode(str);
|
||||
}
|
||||
|
||||
/**
|
||||
* {@code true}自动增长的主键和需要忽略的字段
|
||||
*/
|
||||
|
||||
@@ -59,7 +59,7 @@ public class FtpDownloadActivity extends BaseActivity<ActivityFtpDownloadBinding
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.start:
|
||||
Aria.download(this).loadFtp(URL, true)
|
||||
Aria.download(this).loadFtp(URL)
|
||||
.login("sxf", "B34VdGsJ")
|
||||
//.login("lao", "123456")
|
||||
.login("lao", "123456")
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package com.arialyy.simple.test;
|
||||
|
||||
import android.os.Bundle;
|
||||
import android.os.Environment;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
@@ -26,10 +27,10 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
|
||||
//String URL = "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk";
|
||||
//private final String URL = "ftp://192.168.29.140:21/download/AriaPrj.rar";
|
||||
//String URL = "https://dl.genymotion.com/releases/genymotion-2.12.1/genymotion-2.12.1-vbox.exe";
|
||||
//String URL = "ftp://192.168.29.140:21/download/SDK_Demo-release.apk";
|
||||
String URL = "ftp://192.168.29.140:21/download/SDK_Demo-release.apk";
|
||||
//String URL = "ftp://z:z@dygod18.com:21211/[电影天堂www.dy2018.com]猩球崛起3:终极之战BD国英双语中英双字.mkv";
|
||||
//private String URL = "https://www.bilibili.com/bangumi/play/ep77693";
|
||||
private String URL = "http://cn-hbsjz-cmcc-v-03.acgvideo.com/upgcxcode/63/82/5108263/5108263-1-80.flv?expires=1530178500&platform=pc&ssig=vr7gLl0duyqWqSMnIpzaDA&oi=3746029570&nfa=BpfiWF+i4mNW8KzjZFHzBQ==&dynamic=1&hfa=2030547937&hfb=Yjk5ZmZjM2M1YzY4ZjAwYTMzMTIzYmIyNWY4ODJkNWI=&trid=3476be01a9254115b15f8cc7198600fe&nfc=1";
|
||||
//private String URL = "http://cn-hbsjz-cmcc-v-03.acgvideo.com/upgcxcode/63/82/5108263/5108263-1-80.flv?expires=1530178500&platform=pc&ssig=vr7gLl0duyqWqSMnIpzaDA&oi=3746029570&nfa=BpfiWF+i4mNW8KzjZFHzBQ==&dynamic=1&hfa=2030547937&hfb=Yjk5ZmZjM2M1YzY4ZjAwYTMzMTIzYmIyNWY4ODJkNWI=&trid=3476be01a9254115b15f8cc7198600fe&nfc=1";
|
||||
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_test;
|
||||
@@ -48,28 +49,21 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
|
||||
public void onClick(View view) {
|
||||
switch (view.getId()) {
|
||||
case R.id.start:
|
||||
//module.start();
|
||||
//if (index < urls.length) {
|
||||
// module.start(urls[index]);
|
||||
// index++;
|
||||
//}
|
||||
//for (int i = 0; i < 10; i++) {
|
||||
|
||||
//module.startFtp(URL);
|
||||
module.start(URL);
|
||||
//}
|
||||
//List<AbsEntity> list = Aria.download(this).getTotalTaskList();
|
||||
//ALog.d(TAG, "size ==> " + list.size());
|
||||
//module.start(URL);
|
||||
module.startFtp(URL);
|
||||
break;
|
||||
case R.id.stop:
|
||||
//List<AbsEntity> list = Aria.download(this).getTotalTaskList();
|
||||
//
|
||||
module.stop(URL);
|
||||
|
||||
break;
|
||||
case R.id.cancel:
|
||||
module.cancel(URL);
|
||||
//module.cancel();
|
||||
//String newUrl = "ftp://192.168.29.140:21/download/11SDK_Demo-release.apk";
|
||||
//Aria.download(this)
|
||||
// .loadFtp(URL)
|
||||
// .updateUrl(newUrl)
|
||||
// .login("lao", "123456")
|
||||
// .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/")
|
||||
// .start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -66,36 +66,12 @@ public class AnyRunnModule {
|
||||
void start(String url) {
|
||||
mUrl = url;
|
||||
String path = Environment.getExternalStorageDirectory().getPath() + "/aaas.apk";
|
||||
//File file = new File(path);
|
||||
//if (file.exists()) {
|
||||
// file.delete();
|
||||
//}
|
||||
Aria.download(this)
|
||||
.load(url)
|
||||
//.addHeader("Accept-Encoding", "gzip")
|
||||
.addHeader("Referer", "http://www.bilibili.com/")
|
||||
.addHeader("user-agent", "Mozilla/5.0 AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537.36")
|
||||
.setRequestMode(RequestEnum.GET)
|
||||
//.setUrlProxy(Proxy.NO_PROXY)
|
||||
.setFilePath(path)
|
||||
.resetState()
|
||||
.start();
|
||||
//String[] urls = new String[] {
|
||||
// "http://cdn-s1.touchfound.net/1526449199142_3617.png",
|
||||
// "http://cdn-s1.touchfound.net/mtVmResources/1526287158571.zip",
|
||||
// "http://cdn-s1.touchfound.net/1526450206960_2186.png",
|
||||
// "http://cdn-s1.touchfound.net/1526449199025_1476.png"
|
||||
//};
|
||||
//for (int i = 0, len = urls.length; i < len; i++){
|
||||
//
|
||||
// Aria.download(this)
|
||||
// .load(urls[i])
|
||||
// //.addHeader("Accept-Encoding", "gzip")
|
||||
// .setRequestMode(RequestEnum.GET)
|
||||
// .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg123456.apk" + i)
|
||||
// //.resetState()
|
||||
// .start();
|
||||
//}
|
||||
}
|
||||
|
||||
void startFtp(String url) {
|
||||
@@ -103,26 +79,8 @@ public class AnyRunnModule {
|
||||
Aria.download(this)
|
||||
.loadFtp(url)
|
||||
.login("lao", "123456")
|
||||
//.addHeader("Accept-Encoding", "gzip")
|
||||
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/")
|
||||
//.resetState()
|
||||
.start();
|
||||
//String[] urls = new String[] {
|
||||
// "http://cdn-s1.touchfound.net/1526449199142_3617.png",
|
||||
// "http://cdn-s1.touchfound.net/mtVmResources/1526287158571.zip",
|
||||
// "http://cdn-s1.touchfound.net/1526450206960_2186.png",
|
||||
// "http://cdn-s1.touchfound.net/1526449199025_1476.png"
|
||||
//};
|
||||
//for (int i = 0, len = urls.length; i < len; i++){
|
||||
//
|
||||
// Aria.download(this)
|
||||
// .load(urls[i])
|
||||
// //.addHeader("Accept-Encoding", "gzip")
|
||||
// .setRequestMode(RequestEnum.GET)
|
||||
// .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg123456.apk" + i)
|
||||
// //.resetState()
|
||||
// .start();
|
||||
//}
|
||||
}
|
||||
|
||||
void stop(String url) {
|
||||
|
||||
@@ -39,7 +39,7 @@ task clean(type: Delete) {
|
||||
ext {
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = '3.4.4'
|
||||
publishVersion = '3.4.5'
|
||||
// publishVersion = '1.0.3' //FTP插件
|
||||
repoName='maven'
|
||||
desc = 'android 下载框架'
|
||||
|
||||
Reference in New Issue
Block a user