diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java index 05b48059..c490372e 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java @@ -32,6 +32,8 @@ import java.math.BigDecimal; import java.util.Properties; import java.util.Timer; import java.util.TimerTask; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; /** * Created by lyy on 2017/1/18. @@ -60,6 +62,17 @@ public abstract class AbsThreadTask info) { @@ -76,6 +89,7 @@ public abstract class AbsThreadTask= Build.VERSION_CODES.LOLLIPOP; } + @Override protected void finalize() throws Throwable { + super.finalize(); + if (mConfigThreadPool != null) { + mConfigThreadPool.shutdown(); + } + } + /** * 停止任务 */ @@ -134,20 +155,12 @@ public abstract class AbsThreadTask 5000 && mChildCurrentLocation < mConfig.END_LOCATION) { mLastSaveTime = System.currentTimeMillis(); - new Thread(new Runnable() { - @Override public void run() { - final long currentTemp = mChildCurrentLocation; - try { - writeConfig(false, currentTemp); - } catch (IOException e) { - e.printStackTrace(); - } - } - }).start(); + if (!mConfigThreadPool.isShutdown()) { + mConfigThreadPool.execute(mConfigThread); + } } } } 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..bcf00f21 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 @@ -24,6 +24,7 @@ import com.arialyy.aria.core.command.normal.NormalCmdFactory; import com.arialyy.aria.core.common.ProxyHelper; 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.scheduler.DownloadGroupSchedulers; import com.arialyy.aria.core.scheduler.DownloadSchedulers; import com.arialyy.aria.core.scheduler.ISchedulerListener; @@ -65,8 +66,18 @@ public class DownloadReceiver extends AbsReceiver { * 使用下载实体执行下载操作 * * @param refreshInfo 是否刷新下载信息 + * @deprecated 请使用 {@link AbsTarget#resetState()} + *
+   *   
+   *   Aria.download(this)
+   *       .load(URL)
+   *       .setDownloadPath(PATH)
+   *       .resetState()
+   *       .start();
+   *   
+   * 
*/ - public DownloadTarget load(DownloadEntity entity, boolean refreshInfo) { + @Deprecated public DownloadTarget load(DownloadEntity entity, boolean refreshInfo) { CheckUtil.checkDownloadEntity(entity); return new DownloadTarget(entity, targetName, refreshInfo); } @@ -84,9 +95,19 @@ public class DownloadReceiver extends AbsReceiver { * 加载Http、https单任务下载地址 * * @param url 下载地址 - * @param refreshInfo 是否刷新下载信息 + * @param refreshInfo 是否刷新下载信息,当下载地址改变而保存路径不变,则需要设置该参数为{@code true} + * @deprecated 请使用 {@link AbsTarget#resetState()} + *
+   *   
+   *   Aria.download(this)
+   *       .load(URL)
+   *       .setDownloadPath(PATH)
+   *       .resetState()
+   *       .start();
+   *   
+   * 
*/ - public DownloadTarget load(@NonNull String url, boolean refreshInfo) { + @Deprecated public DownloadTarget load(@NonNull String url, boolean refreshInfo) { CheckUtil.checkUrl(url); return new DownloadTarget(url, targetName, refreshInfo); } @@ -111,9 +132,19 @@ public class DownloadReceiver extends AbsReceiver { /** * 使用下载实体执行下载操作 * - * @param refreshInfo 是否刷新下载信息 + * @param refreshInfo 是否刷新下载信息,当下载地址改变而保存路径不变,则需要设置该参数为{@code true} + * @deprecated 请使用 {@link AbsTarget#resetState()} + *
+   *   
+   *   Aria.download(this)
+   *       .load(URL)
+   *       .setDownloadPath(PATH)
+   *       .resetState()
+   *       .start();
+   *   
+   * 
*/ - public FtpDownloadTarget loadFtp(DownloadEntity entity, boolean refreshInfo) { + @Deprecated public FtpDownloadTarget loadFtp(DownloadEntity entity, boolean refreshInfo) { CheckUtil.checkDownloadEntity(entity); if (!entity.getUrl().startsWith("ftp")) { throw new IllegalArgumentException("非FTP请求不能使用该方法"); 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 ab174537..6e2d69c4 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 @@ -24,6 +24,7 @@ import com.arialyy.aria.core.command.normal.NormalCmdFactory; import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.download.DownloadGroupTaskEntity; import com.arialyy.aria.core.download.DownloadTaskEntity; +import com.arialyy.aria.core.manager.TEManager; import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.util.ALog; import com.arialyy.aria.util.CommonUtil; @@ -41,6 +42,16 @@ public abstract class AbsTarget map = new ConcurrentHashMap<>(); + private LruCache cache = new LruCache<>(1024); private Lock lock; public static TEManager getInstance() { @@ -61,7 +60,7 @@ public class TEManager { final Lock lock = this.lock; lock.lock(); try { - AbsTaskEntity tEntity = map.get(convertKey(key)); + AbsTaskEntity tEntity = cache.get(convertKey(key)); if (tEntity == null || tEntity.getClass() != clazz) { ITEntityFactory factory = chooseFactory(clazz); if (factory == null) { @@ -69,7 +68,7 @@ public class TEManager { return null; } tEntity = factory.create(key); - map.put(convertKey(key), tEntity); + cache.put(convertKey(key), tEntity); } return (TE) tEntity; } finally { @@ -87,7 +86,7 @@ public class TEManager { lock.lock(); try { String groupName = CommonUtil.getMd5Code(urls); - AbsTaskEntity tEntity = map.get(convertKey(groupName)); + AbsTaskEntity tEntity = cache.get(convertKey(groupName)); if (tEntity == null || tEntity.getClass() != clazz) { IGTEntityFactory factory = chooseGroupFactory(clazz); if (factory == null) { @@ -95,7 +94,7 @@ public class TEManager { return null; } tEntity = factory.create(groupName, urls); - map.put(convertKey(groupName), tEntity); + cache.put(convertKey(groupName), tEntity); } return (TE) tEntity; } finally { @@ -112,7 +111,7 @@ public class TEManager { final Lock lock = this.lock; lock.lock(); try { - AbsTaskEntity tEntity = map.get(convertKey(absEntity.getKey())); + AbsTaskEntity tEntity = cache.get(convertKey(absEntity.getKey())); if (tEntity == null || tEntity.getClass() != clazz) { ITEntityFactory factory = chooseFactory(clazz); if (factory == null) { @@ -120,7 +119,7 @@ public class TEManager { return null; } tEntity = factory.create(absEntity); - map.put(convertKey(absEntity.getKey()), tEntity); + cache.put(convertKey(absEntity.getKey()), tEntity); } return (TE) tEntity; } finally { @@ -153,7 +152,7 @@ public class TEManager { final Lock lock = this.lock; lock.lock(); try { - AbsTaskEntity tEntity = map.get(convertKey(key)); + AbsTaskEntity tEntity = cache.get(convertKey(key)); if (tEntity == null) { return null; } else { @@ -177,7 +176,7 @@ public class TEManager { final Lock lock = this.lock; lock.lock(); try { - return map.put(convertKey(te.key), te) != null; + return cache.put(convertKey(te.key), te) != null; } finally { lock.unlock(); } @@ -185,12 +184,13 @@ public class TEManager { /** * 通过key删除任务实体 + * 当任务complete或删除记录时将删除缓存 */ public AbsTaskEntity removeTEntity(String key) { final Lock lock = this.lock; lock.lock(); try { - return map.remove(convertKey(key)); + return cache.remove(convertKey(key)); } finally { lock.unlock(); } 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 d691dec1..bb485a4c 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java @@ -34,7 +34,7 @@ import java.util.Map; class DBConfig { static Map mapping = new HashMap<>(); static String DB_NAME; - static int VERSION = 20; + static int VERSION = 22; static { if (TextUtils.isEmpty(DB_NAME)) { diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java b/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java index 787d319a..8b6ced31 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java @@ -36,15 +36,15 @@ public class DbEntity { } - /** - * 关键字模糊检索全文 - * - * @param column 需要查找的列 - * @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green” - */ - public static List searchData(Class clazz, String column, String mathSql) { - return DbUtil.getInstance().searchData(clazz, column, mathSql); - } + ///** + // * 关键字模糊检索全文 + // * + // * @param column 需要查找的列 + // * @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green” + // */ + //public static List searchData(Class clazz, String column, String mathSql) { + // return DbUtil.getInstance().searchData(clazz, column, mathSql); + //} /** * 检查某个字段的值是否存在 diff --git a/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java b/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java index 3cc12950..7e1bf8d9 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java @@ -64,16 +64,16 @@ public class DbUtil { return INSTANCE; } - /** - * 关键字模糊检索全文 - * - * @param column 需要查找的列 - * @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green” - */ - public List searchData(Class clazz, String column, String mathSql) { - checkDb(); - return SqlHelper.searchData(mDb, clazz, column, mathSql); - } + ///** + // * 关键字模糊检索全文 + // * + // * @param column 需要查找的列 + // * @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green” + // */ + //public List searchData(Class clazz, String column, String mathSql) { + // checkDb(); + // return SqlHelper.searchData(mDb, clazz, column, mathSql); + //} /** * 检查某个字段的值是否存在 diff --git a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java index bc4671c3..e0884fb1 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -21,6 +21,7 @@ import android.database.Cursor; import android.database.sqlite.SQLiteDatabase; import android.database.sqlite.SQLiteOpenHelper; import android.support.annotation.NonNull; +import android.support.v4.util.LruCache; import android.text.TextUtils; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.util.ALog; @@ -49,6 +50,7 @@ final class SqlHelper extends SQLiteOpenHelper { private static final int DEL_DATA = 6; private static volatile SqlHelper INSTANCE = null; + private static LruCache mDataCache = new LruCache<>(1024); static SqlHelper init(Context context) { if (INSTANCE == null) { @@ -162,27 +164,27 @@ final class SqlHelper extends SQLiteOpenHelper { return count; } - /** - * 关键字模糊检索全文 - * - * @param column 需要查找的列 - * @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green” - */ - public static List searchData(SQLiteDatabase db, Class clazz, - String column, String mathSql) { - String sql = "SELECT * FROM " - + CommonUtil.getClassName(clazz) - + " WHERE " - + column - + " MATCH '" - + mathSql - + "'"; - - Cursor cursor = db.rawQuery(sql, null); - List data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; - closeCursor(cursor); - return data; - } + ///** + // * 关键字模糊检索全文 + // * + // * @param column 需要查找的列 + // * @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green” + // */ + //public static List searchData(SQLiteDatabase db, Class clazz, + // String column, String mathSql) { + // String sql = "SELECT * FROM " + // + CommonUtil.getClassName(clazz) + // + " WHERE " + // + column + // + " MATCH '" + // + mathSql + // + "'"; + // + // Cursor cursor = db.rawQuery(sql, null); + // List data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; + // closeCursor(cursor); + // return data; + //} /** * 检查某个字段的值是否存在 @@ -328,19 +330,27 @@ final class SqlHelper extends SQLiteOpenHelper { db = checkDb(db); Class clazz = dbEntity.getClass(); List 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); if (SqlUtil.ignoreField(field)) { continue; } - sb.append(i > 0 ? ", " : ""); try { + if (cacheEntity != null && field.get(dbEntity) == field.get(cacheEntity)) { + continue; + } + + //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)); @@ -357,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); } @@ -477,9 +492,11 @@ final class SqlHelper extends SQLiteOpenHelper { //外键Map,在Sqlite3中foreign修饰的字段必须放在最后 final List foreignArray = new ArrayList<>(); StringBuilder sb = new StringBuilder(); - sb.append("create VIRTUAL table ") + //sb.append("create VIRTUAL table ") + sb.append("create table ") .append(TextUtils.isEmpty(tableName) ? CommonUtil.getClassName(clazz) : tableName) - .append(" USING fts4("); + //.append(" USING fts4("); + .append(" ("); for (Field field : fields) { field.setAccessible(true); if (SqlUtil.ignoreField(field)) { @@ -656,6 +673,7 @@ final class SqlHelper extends SQLiteOpenHelper { } } entity.rowID = cursor.getInt(cursor.getColumnIndex("rowid")); + mDataCache.put(entity.hashCode(), entity); entitys.add(entity); } closeCursor(cursor); diff --git a/Aria/src/main/java/com/arialyy/aria/orm/SqlUtil.java b/Aria/src/main/java/com/arialyy/aria/orm/SqlUtil.java index dd736b81..877f10dd 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/SqlUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlUtil.java @@ -110,10 +110,19 @@ final class SqlUtil { if (TextUtils.isEmpty(str)) { return map; } + boolean isDecode = false; + if (str.endsWith("_&_decode_&_")) { + isDecode = true; + str = str.substring(0, str.length() - 12); + } String[] element = str.split(","); for (String data : element) { String[] s = data.split("\\$"); - map.put(s[0], s[1]); + if (isDecode) { + map.put(CommonUtil.decryptBASE64(s[0]), CommonUtil.decryptBASE64(s[1])); + } else { + map.put(s[0], s[1]); + } } return map; } @@ -128,10 +137,18 @@ final class SqlUtil { StringBuilder sb = new StringBuilder(); Set keys = map.keySet(); for (String key : keys) { - sb.append(key).append("$").append(map.get(key)).append(","); + sb.append(CommonUtil.encryptBASE64(key)) + .append("$") + .append(CommonUtil.encryptBASE64(map.get(key))) + .append(","); } String str = sb.toString(); - return TextUtils.isEmpty(str) ? str : str.substring(0, str.length() - 1); + str = TextUtils.isEmpty(str) ? str : str.substring(0, str.length() - 1); + //3.3.10版本之前没有decode,需要加标志 + if (map.size() != 0) { + str += "_&_decode_&_"; + } + return str; } /** 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/README.md b/README.md index 593f141e..8dbb7b46 100644 --- a/README.md +++ b/README.md @@ -1,5 +1,5 @@ # Aria -![图标](https://github.com/AriaLyy/DownloadUtil/blob/v_2.0/app/src/main/res/mipmap-hdpi/ic_launcher.png)
+![图标](https://github.com/AriaLyy/DownloadUtil/blob/v_3.0/app/src/main/res/mipmap-hdpi/ic_launcher.png)
## [ENGLISH DOC](https://github.com/AriaLyy/Aria/blob/master/ENGLISH_README.md)
Aria项目源于工作中遇到的一个文件下载管理的需求,当时被下载折磨的痛不欲生,从那时起便萌生了编写一个简单易用,稳当高效的下载框架,aria经历了1.0到3.0的开发,算是越来越接近当初所制定的目标了。 @@ -28,8 +28,8 @@ Aria有以下特点: [![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion) [![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion) ```java -compile 'com.arialyy.aria:aria-core:3.3.7' -annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.7' +compile 'com.arialyy.aria:aria-core:3.3.10' +annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.10' ``` 如果你使用的是kotlin,请使用kotlin官方提供的方法配置apt,[kotlin kapt官方配置传送门](https://www.kotlincn.net/docs/reference/kapt.html) @@ -97,9 +97,9 @@ protected void onCreate(Bundle savedInstanceState) { ### [更多说明,见WIKI](https://github.com/AriaLyy/Aria/wiki) ### 升级日志 -+ v_3.3.7 - - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 ++ 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 [更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md) 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 fd14a025..afa60d39 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -209,7 +209,8 @@ public class SingleTaskActivity extends BaseActivity { //Aria.download(this).load(DOWNLOAD_URL).removeRecord(); break; case R.id.cancel: - Aria.download(this).load(DOWNLOAD_URL).cancel(); + //Aria.download(this).load(DOWNLOAD_URL).cancel(); + Aria.download(this).load(DOWNLOAD_URL).removeRecord(); break; } } @@ -225,7 +226,8 @@ 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") + .resetState() .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..b682d4c7 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/java/com/arialyy/simple/download/multi_download/MultiTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/multi_download/MultiTaskActivity.java index 607a2690..fe422b61 100644 --- a/app/src/main/java/com/arialyy/simple/download/multi_download/MultiTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/multi_download/MultiTaskActivity.java @@ -66,8 +66,8 @@ public class MultiTaskActivity extends BaseActivity { dialog.show(getSupportFragmentManager(), "download_num"); break; case R.id.stop_all: - //Aria.download(this).stopAllTask(); - Aria.download(this).removeAllTask(false); + Aria.download(this).stopAllTask(); + //Aria.download(this).removeAllTask(false); break; case R.id.turn: startActivity(new Intent(this, MultiDownloadActivity.class)); diff --git a/app/src/main/res/values/strings.xml b/app/src/main/res/values/strings.xml index e14beb6d..911363ca 100644 --- a/app/src/main/res/values/strings.xml +++ b/app/src/main/res/values/strings.xml @@ -58,13 +58,14 @@ - 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 http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk + http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk @@ -79,7 +80,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 下载框架'