From 31f0acf059f82cf4f0d67b1b1e2177e4ef63b1e5 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 2 Jan 2018 21:47:41 +0800 Subject: [PATCH] =?UTF-8?q?=E6=B7=BB=E5=8A=A0=E9=87=8D=E7=BD=AE=E7=8A=B6?= =?UTF-8?q?=E6=80=81=E7=9A=84api=EF=BC=8C=E5=BD=93=E4=B8=8B=E8=BD=BD?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E4=B8=8D=E6=94=B9=E5=8F=98=EF=BC=8C=E5=8F=AA?= =?UTF-8?q?=E6=98=AF=E6=9B=BF=E6=8D=A2=E4=BA=86=E6=9C=8D=E5=8A=A1=E5=99=A8?= =?UTF-8?q?=E7=9A=84=E5=AF=B9=E5=BA=94=E7=9A=84=E6=96=87=E4=BB=B6=EF=BC=8C?= =?UTF-8?q?=E5=8F=AF=E7=94=A8`Aria.download(this).load(url).resetState()`?= =?UTF-8?q?=E9=87=8D=E7=BD=AE=E4=B8=8B=E8=BD=BD=E7=8A=B6=E6=80=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../core/download/DownloadGroupTarget.java | 4 +-- .../aria/core/download/DownloadReceiver.java | 4 +-- .../downloader/DownloadGroupUtil.java | 6 +++++ .../arialyy/aria/core/inf/AbsGroupTask.java | 2 +- .../com/arialyy/aria/core/inf/AbsTarget.java | 9 +++++++ .../arialyy/aria/core/manager/TEManager.java | 1 + .../java/com/arialyy/aria/orm/SqlHelper.java | 26 ++++++++++++------- DEV_LOG.md | 3 +++ .../simple/download/SingleTaskActivity.java | 6 ++--- .../download/group/DownloadGroupActivity.java | 13 +++++++++- .../simple/download/group/GroupModule.java | 7 +++++ app/src/main/res/values/strings.xml | 4 +-- build.gradle | 2 +- 13 files changed, 66 insertions(+), 21 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java index 9d288cdc..9bd63dd7 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadGroupTarget.java @@ -15,6 +15,7 @@ */ package com.arialyy.aria.core.download; +import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.manager.TEManager; import com.arialyy.aria.core.queue.DownloadGroupTaskQueue; import com.arialyy.aria.util.ALog; @@ -36,8 +37,7 @@ public class DownloadGroupTarget this.mUrls.addAll(groupEntity.getUrls()); } mGroupName = CommonUtil.getMd5Code(groupEntity.getUrls()); - mTaskEntity = TEManager.getInstance() - .getTEntity(DownloadGroupTaskEntity.class, mGroupName); + mTaskEntity = TEManager.getInstance().getTEntity(DownloadGroupTaskEntity.class, mGroupName); if (mTaskEntity == null) { mTaskEntity = TEManager.getInstance().createTEntity(DownloadGroupTaskEntity.class, groupEntity); 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 d849369f..61ea9f29 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 @@ -84,7 +84,7 @@ public class DownloadReceiver extends AbsReceiver { * 加载Http、https单任务下载地址 * * @param url 下载地址 - * @param refreshInfo 是否刷新下载信息 + * @param refreshInfo 是否刷新下载信息,当下载地址改变而保存路径不变,则需要设置该参数为{@code true} */ public DownloadTarget load(@NonNull String url, boolean refreshInfo) { CheckUtil.checkUrl(url); @@ -111,7 +111,7 @@ public class DownloadReceiver extends AbsReceiver { /** * 使用下载实体执行下载操作 * - * @param refreshInfo 是否刷新下载信息 + * @param refreshInfo 是否刷新下载信息,当下载地址改变而保存路径不变,则需要设置该参数为{@code true} */ public FtpDownloadTarget loadFtp(DownloadEntity entity, boolean refreshInfo) { CheckUtil.checkDownloadEntity(entity); diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java index 82513e9a..937f535f 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/downloader/DownloadGroupUtil.java @@ -21,6 +21,7 @@ import com.arialyy.aria.core.common.OnFileInfoCallback; import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity; import com.arialyy.aria.core.inf.IEntity; +import com.arialyy.aria.util.ALog; import java.util.Set; import java.util.concurrent.ExecutorService; import java.util.concurrent.Executors; @@ -63,6 +64,11 @@ public class DownloadGroupUtil extends AbsGroupUtil implements IUtil { @Override protected void onStart() { super.onStart(); + if (mExeMap.size() == 0){ + ALog.e(TAG, "任务组无可执行任务"); + mListener.onFail(false); + return; + } Set keys = mExeMap.keySet(); int i = 0; for (String key : keys) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsGroupTask.java b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsGroupTask.java index 41883028..e395b1f9 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsGroupTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsGroupTask.java @@ -27,7 +27,7 @@ public abstract class AbsGroupTask protected AbsGroupUtil mUtil; @Override public String getKey() { - return mTaskEntity.getEntity().getGroupName(); + return mTaskEntity.getEntity().getKey(); } /** diff --git a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java index 76e66441..985196c8 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java @@ -42,6 +42,15 @@ public abstract class AbsTarget fields = CommonUtil.getAllFields(clazz); DbEntity cacheEntity = mDataCache.get(dbEntity.hashCode()); if (fields != null && fields.size() > 0) { - StringBuilder sb = new StringBuilder(); - sb.append("UPDATE ").append(CommonUtil.getClassName(dbEntity)).append(" SET "); + StringBuilder sql = new StringBuilder(); + StringBuilder prams = new StringBuilder(); + sql.append("UPDATE ").append(CommonUtil.getClassName(dbEntity)).append(" SET "); int i = 0; for (Field field : fields) { field.setAccessible(true); @@ -345,9 +346,11 @@ final class SqlHelper extends SQLiteOpenHelper { continue; } - sb.append(i > 0 ? ", " : ""); + //sb.append(i > 0 ? ", " : ""); + //sb.append(field.getName()).append("='"); String value; - sb.append(field.getName()).append("='"); + prams.append(i > 0 ? ", " : ""); + prams.append(field.getName()).append("='"); Type type = field.getType(); if (type == Map.class) { value = SqlUtil.map2Str((Map) field.get(dbEntity)); @@ -364,16 +367,21 @@ final class SqlHelper extends SQLiteOpenHelper { value = obj == null ? "" : obj.toString(); } - sb.append(value == null ? "" : value); - sb.append("'"); + //sb.append(value == null ? "" : value); + //sb.append("'"); + prams.append(TextUtils.isEmpty(value) ? "" : value); + prams.append("'"); } catch (IllegalAccessException e) { e.printStackTrace(); } i++; } - sb.append(" where rowid=").append(dbEntity.rowID); - print(MODIFY_DATA, sb.toString()); - db.execSQL(sb.toString()); + if (!TextUtils.isEmpty(prams.toString())) { + sql.append(prams.toString()); + sql.append(" where rowid=").append(dbEntity.rowID); + print(MODIFY_DATA, sql.toString()); + db.execSQL(sql.toString()); + } } close(db); } diff --git a/DEV_LOG.md b/DEV_LOG.md index 923c075a..69d361d2 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,7 @@ ## 开发日志 + + v_3.3.10 + - 修复地址切换导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/181 + - 添加重置状态的api,当下载信息不改变,只是替换了服务器的对应的文件,可用`Aria.download(this).load(url).resetState()`重置下载状态 https://github.com/AriaLyy/Aria/issues/182 + v_3.3.9 - 添加POST支持 - 任务执行的过程中,如果调用removeRecord()方法,将会取消任务 https://github.com/AriaLyy/Aria/issues/174 diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index d89f85fa..fe30b087 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -61,8 +61,8 @@ public class SingleTaskActivity extends BaseActivity { //"http://down8.androidgame-store.com/201706122321/97967927DD4E53D9905ECAA7874C8128/new/game1/19/45319/com.neuralprisma-2.5.2.174-2000174_1494784835.apk?f=web_1"; //不支持断点的链接 //"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; - //"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk"; - "http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2"; + "http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk"; + //"http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; @@ -226,7 +226,7 @@ public class SingleTaskActivity extends BaseActivity { //.addHeader("groupName", "value") .addHeaders(map) //.setRequestMode(RequestEnum.POST) - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/ggsg.apk") + .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/ggsg1.apk") .start(); } diff --git a/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java b/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java index 66b9034b..e53219a9 100644 --- a/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/group/DownloadGroupActivity.java @@ -26,6 +26,7 @@ import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadGroupEntity; import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadGroupTaskEntity; +import com.arialyy.aria.core.manager.TEManager; import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.T; import com.arialyy.simple.R; @@ -66,6 +67,7 @@ public class DownloadGroupActivity extends BaseActivity getUrls() { + List urls = new ArrayList<>(); + String[] str = getContext().getResources().getStringArray(R.array.group_urls_1); + Collections.addAll(urls, str); + return urls; + } + + List getUrls1() { List urls = new ArrayList<>(); String[] str = getContext().getResources().getStringArray(R.array.group_urls); Collections.addAll(urls, str); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e14beb6d..2aabf57f 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,7 +58,7 @@ - https://res5.d.cn/5a6a3384c1b2be1a426f06bfc69034d69c44ae1a01da180cab8e59bd1a5e1a784bac46ba0c64579d14f0e80a4ce4f068af89b0369a393456f4f449a8829cad5c.apk + http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk @@ -79,7 +79,7 @@ - 王者荣耀.apk + 战斗吧剑灵.apk 天魔幻想.apk diff --git a/build.gradle b/build.gradle index 77153ac4..f7cca8f1 100644 --- a/build.gradle +++ b/build.gradle @@ -39,7 +39,7 @@ task clean(type: Delete) { ext { userOrg = 'arialyy' groupId = 'com.arialyy.aria' - publishVersion = '3.3.9' + publishVersion = '3.3.10' // publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架'