From 1d116f71b73f02ea32c205e0c57d8807cc59a0f1 Mon Sep 17 00:00:00 2001 From: laoyuyu <511455842@qq.com> Date: Fri, 29 Jun 2018 19:56:41 +0800 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E4=BA=86=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E4=B8=B2=E4=B8=AD=E6=9C=89=E7=89=B9=E6=AE=8A=E5=AD=97=E7=AC=A6?= =?UTF-8?q?=E5=AF=BC=E8=87=B4=E7=9A=84=E8=B7=AF=E5=BE=84=E5=86=B2=E7=AA=81?= =?UTF-8?q?=E9=97=AE=E9=A2=98=EF=BC=9B=E4=BF=AE=E5=A4=8Dftp=E5=88=86?= =?UTF-8?q?=E5=9D=97=E4=B8=8B=E8=BD=BD=E5=A4=B1=E8=B4=A5=E9=97=AE=E9=A2=98?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arialyy/aria/core/common/AbsFileer.java | 2 +- .../aria/core/common/AbsThreadTask.java | 5 ++ .../aria/core/common/StateConstance.java | 2 +- .../aria/core/download/BaseNormalTarget.java | 9 +- .../aria/core/download/DownloadReceiver.java | 88 +------------------ .../aria/core/download/DownloadTarget.java | 13 +-- .../aria/core/download/FtpDownloadTarget.java | 15 ++-- .../download/downloader/FtpThreadTask.java | 18 ++-- .../downloader/HttpFileInfoThread.java | 2 +- .../com/arialyy/aria/orm/AbsDelegate.java | 24 +++-- .../java/com/arialyy/aria/orm/DBConfig.java | 2 +- .../com/arialyy/aria/orm/DelegateCommon.java | 4 +- .../com/arialyy/aria/orm/DelegateFind.java | 4 +- .../com/arialyy/aria/orm/DelegateUpdate.java | 12 +-- .../simple/download/FtpDownloadActivity.java | 2 +- .../arialyy/simple/test/AnyRunActivity.java | 30 +++---- .../arialyy/simple/test/AnyRunnModule.java | 42 --------- build.gradle | 2 +- 18 files changed, 73 insertions(+), 203 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java index 50035334..5680a83d 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java @@ -489,7 +489,7 @@ public abstract class AbsFileer mEntity.getFileSize()) { + ALog.d(TAG, String.format("currentLocation=%s, fileSize=%s", STATE.CURRENT_LOCATION, + mEntity.getFileSize())); taskBreak = true; fail(mChildCurrentLocation, "下载失败,下载长度超出文件大小", null, false); return; diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/StateConstance.java b/Aria/src/main/java/com/arialyy/aria/core/common/StateConstance.java index 00a09e2c..b3cae98b 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/StateConstance.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/StateConstance.java @@ -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); } /** diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java index 0bbfd380..5bc9abdc 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java @@ -37,12 +37,12 @@ abstract class 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 return (TARGET) this; } this.newUrl = newUrl; + mTaskEntity.setRefreshInfo(true); return (TARGET) this; } @@ -199,6 +200,10 @@ abstract class BaseNormalTarget ALog.e(TAG, "下载失败,url【" + url + "】不合法"); return false; } + if (!TextUtils.isEmpty(newUrl)){ + mEntity.setUrl(newUrl); + mTaskEntity.setUrl(newUrl); + } return true; } } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java index 3cb4301f..b688ffaf 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java @@ -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()} - *
-   *   
-   *   Aria.download(this)
-   *       .load(URL)
-   *       .setDownloadPath(PATH)
-   *       .resetState()
-   *       .start();
-   *   
-   * 
- */ - @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()} - *
-   *   
-   *   Aria.download(this)
-   *       .load(URL)
-   *       .setDownloadPath(PATH)
-   *       .resetState()
-   *       .start();
-   *   
-   * 
- */ - @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()} - *
-   *   
-   *   Aria.download(this)
-   *       .load(URL)
-   *       .setDownloadPath(PATH)
-   *       .resetState()
-   *       .start();
-   *   
-   * 
- */ - @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); } /** diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java index 207cccaa..5014e30c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTarget.java @@ -31,20 +31,13 @@ public class DownloadTarget extends BaseNormalTarget implements IHttpHeaderTarget { private HttpHeaderDelegate 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); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java index 8cfcc298..6d73b43c 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/FtpDownloadTarget.java @@ -30,24 +30,19 @@ public class FtpDownloadTarget extends BaseNormalTarget implements IFtpTarget { private FtpDelegate 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); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java index e5c2a046..4d2390e8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/FtpThreadTask.java @@ -61,7 +61,6 @@ class FtpThreadTask extends AbsFtpThreadTask handleComplete(); return; } - //当前子线程的下载位置 mChildCurrentLocation = mConfig.START_LOCATION; FTPClient client = null; InputStream is = null; @@ -172,10 +171,19 @@ class FtpThreadTask extends AbsFtpThreadTask 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) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java index 59724e97..71b206c8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/HttpFileInfoThread.java @@ -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(); diff --git a/Aria/src/main/java/com/arialyy/aria/orm/AbsDelegate.java b/Aria/src/main/java/com/arialyy/aria/orm/AbsDelegate.java index fecf50e9..0fc7e88c 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/AbsDelegate.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/AbsDelegate.java @@ -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} * @@ -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 { diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java index 287da597..582cd5cc 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java @@ -35,7 +35,7 @@ class DBConfig { /*adb pull /mnt/sdcard/Android/data/com.arialyy.simple/files/DB/AriaLyyDb d:/db*/ static Map mapping = new HashMap<>(); static String DB_NAME; - static int VERSION = 35; + static int VERSION = 39; /** * 是否将数据库保存在Sd卡,{@code true} 是 diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java index 6f615c39..f75695aa 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateCommon.java @@ -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); diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java index f038520c..81c8a85d 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateFind.java @@ -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); diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java b/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java index 7b3d2b58..f1a87b81 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DelegateUpdate.java @@ -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}自动增长的主键和需要忽略的字段 */ diff --git a/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java b/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java index 9475c982..332183f6 100644 --- a/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/FtpDownloadActivity.java @@ -59,7 +59,7 @@ public class FtpDownloadActivity extends BaseActivity { //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 { 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 list = Aria.download(this).getTotalTaskList(); - //ALog.d(TAG, "size ==> " + list.size()); + //module.start(URL); + module.startFtp(URL); break; case R.id.stop: - //List 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; } } diff --git a/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java b/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java index ab86d6a0..c54fa1eb 100644 --- a/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java +++ b/app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java @@ -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) { diff --git a/build.gradle b/build.gradle index 3bf91731..e172e363 100644 --- a/build.gradle +++ b/build.gradle @@ -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 下载框架'