From 3773e254d8a232a3f81caa26b156383c73f03678 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Thu, 30 Nov 2017 20:42:09 +0800 Subject: [PATCH 1/4] =?UTF-8?q?POST=20=E6=94=AF=E6=8C=81?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../arialyy/aria/core/download/DownloadTarget.java | 13 ++++++++++++- .../download/downloader/HttpFileInfoThread.java | 1 + .../java/com/arialyy/aria/core/inf/AbsTarget.java | 3 ++- .../com/arialyy/aria/core/inf/AbsTaskEntity.java | 6 ++++++ .../main/java/com/arialyy/aria/orm/DBConfig.java | 2 +- DEV_LOG.md | 2 ++ .../arialyy/simple/download/SingleTaskActivity.java | 6 ++++-- 7 files changed, 28 insertions(+), 5 deletions(-) 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 b242af47..6c9cdeab 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 @@ -17,7 +17,6 @@ package com.arialyy.aria.core.download; import android.support.annotation.NonNull; import android.text.TextUtils; -import android.util.Log; import com.arialyy.aria.core.inf.AbsDownloadTarget; import com.arialyy.aria.core.manager.TEManager; import com.arialyy.aria.core.queue.DownloadTaskQueue; @@ -63,6 +62,18 @@ public class DownloadTarget mTaskEntity.refreshInfo = refreshInfo; } + /** + * 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment;filename=***} + * 如果获取不到服务器文件名,则使用用户设置的文件名 + * 只适用于HTTP请求 + * + * @param use {@code true} 使用 + */ + @Deprecated public DownloadTarget useServerFileName(boolean use) { + mTaskEntity.useServerFileName = use; + return this; + } + /** * 将任务设置为最高优先级任务,最高优先级任务有以下特点: * 1、在下载队列中,有且只有一个最高优先级任务 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 652696d1..64aa80ca 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 @@ -54,6 +54,7 @@ class HttpFileInfoThread implements Runnable { conn = ConnectionHelp.setConnectParam(mTaskEntity, conn); conn.setRequestProperty("Range", "bytes=" + 0 + "-"); conn.setConnectTimeout(mConnectTimeOut); + conn.setRequestMethod(mTaskEntity.requestEnum.name); conn.connect(); handleConnect(conn); } catch (IOException e) { 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 aea773c3..cd922c51 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 @@ -154,7 +154,8 @@ public abstract class AbsTarget extends DbEntity { */ public String md5Key = "Content-MD5"; + /** + * 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment;filename=***} + * {@code true} 使用 + */ + public boolean useServerFileName = false; + /** * 从header中获取文件描述信息所需要的key */ 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 c5f44524..748f063d 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 { static Map mapping = new HashMap<>(); static String DB_NAME; //static int VERSION = 16; - static int VERSION = 17; + static int VERSION = 18; static { if (TextUtils.isEmpty(DB_NAME)) { diff --git a/DEV_LOG.md b/DEV_LOG.md index 48d2342f..b088dc4f 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,4 +1,6 @@ ## 开发日志 + + v_3.3.8 + - 添加POST支持 + v_3.3.7 - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 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 1c12838f..3c81ee05 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -29,6 +29,7 @@ import butterknife.Bind; import com.arialyy.annotations.Download; import com.arialyy.annotations.DownloadGroup; import com.arialyy.aria.core.Aria; +import com.arialyy.aria.core.common.RequestEnum; import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadTarget; @@ -60,8 +61,8 @@ public class SingleTaskActivity extends BaseActivity { //"http://ox.konsung.net:5555/ksdc-web/download/downloadFile/?fileName=ksdc_1.0.2.apk&rRange=0-"; //"http://172.18.104.50:8080/download/_302turn"; //"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk"; - "http://shouji.360tpcdn.com/160824/2c0407dbab4a86c7a84fa7340b9969e7/block.app.wars_30.apk"; - //"http://172.21.1.99:8080/download/test+ 中文123.zip"; + //"http://shouji.360tpcdn.com/160824/2c0407dbab4a86c7a84fa7340b9969e7/block.app.wars_30.apk"; + "http://172.21.1.72:8080/download/test+ 中文123.zip"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; @@ -228,6 +229,7 @@ public class SingleTaskActivity extends BaseActivity { Aria.download(SingleTaskActivity.this) .load(DOWNLOAD_URL) .addHeader("groupName", "value") + .setRequestMode(RequestEnum.POST) .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") .start(); } From 3265fd7ed50c507a0927ce2be37a09aa8062e846 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Tue, 26 Dec 2017 21:26:23 +0800 Subject: [PATCH 2/4] =?UTF-8?q?=E5=A6=82=E5=88=A0=E9=99=A4=E6=AD=A3?= =?UTF-8?q?=E5=9C=A8=E8=BF=90=E8=A1=8C=E7=9A=84=E4=BB=BB=E5=8A=A1=E7=9A=84?= =?UTF-8?q?=E8=AE=B0=E5=BD=95=EF=BC=8C=E5=B0=86=E5=9B=9E=E6=89=A7=E8=A1=8C?= =?UTF-8?q?=E5=8F=96=E6=B6=88=E4=BB=BB=E5=8A=A1=E7=9A=84=E8=AE=B0=E5=BD=95?= =?UTF-8?q?=EF=BC=8C=20https://github.com/AriaLyy/Aria/issues/174=EF=BC=8C?= =?UTF-8?q?=20fix=20bug=20https://github.com/AriaLyy/Aria/issues/173?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../aria/core/common/AbsFtpThreadTask.java | 2 +- .../aria/core/download/BaseDListener.java | 3 +- .../core/download/DownloadGroupTarget.java | 6 +++ .../aria/core/download/DownloadReceiver.java | 25 ++++++++-- .../aria/core/download/DownloadTarget.java | 7 ++- .../core/download/FtpDirDownloadTarget.java | 6 +++ .../com/arialyy/aria/core/inf/AbsTarget.java | 18 ++++++- .../aria/core/inf/AbsUploadTarget.java | 6 +++ .../com/arialyy/aria/core/inf/IReceiver.java | 2 +- .../aria/core/upload/BaseUListener.java | 3 +- .../aria/core/upload/UploadReceiver.java | 2 +- .../java/com/arialyy/aria/orm/DBConfig.java | 2 +- .../java/com/arialyy/aria/orm/DbEntity.java | 10 ++++ .../java/com/arialyy/aria/orm/DbUtil.java | 11 +++++ .../java/com/arialyy/aria/orm/SqlHelper.java | 48 ++++++++++++++++--- app/build.gradle | 1 + app/src/main/assets/aria_config.xml | 4 +- .../download/HighestPriorityActivity.java | 2 +- .../simple/download/SingleTaskActivity.java | 15 +----- .../com/arialyy/aria/core/Configuration.java | 14 +++++- 20 files changed, 148 insertions(+), 39 deletions(-) diff --git a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java index 224f245a..1570e117 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/common/AbsFtpThreadTask.java @@ -100,7 +100,7 @@ public abstract class AbsFtpThreadTask getSimpleTaskList() { + @Override public List getTaskList() { return DownloadEntity.findDatas(DownloadEntity.class, "isGroupChild=? and downloadPath!=''", "false"); } + /** + * 获取所有未完成的普通下载任务 + */ + public List getAllNotCompletTask() { + return DownloadEntity.findDatas(DownloadEntity.class, + "isGroupChild=? and downloadPath!='' and isComplete=?", "false", "false"); + } + + /** + * 获取所有已经完成的普通任务 + */ + public List getAllCompleteTask() { + return DownloadEntity.findDatas(DownloadEntity.class, + "isGroupChild=? and downloadPath!='' and isComplete=?", "false", "true"); + } + /** * 获取任务组列表 */ @@ -269,7 +286,7 @@ public class DownloadReceiver extends AbsReceiver { */ public List getTotleTaskList() { List list = new ArrayList<>(); - List simpleTask = getSimpleTaskList(); + List simpleTask = getTaskList(); List groupTask = getGroupTaskList(); if (simpleTask != null && !simpleTask.isEmpty()) { list.addAll(simpleTask); 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 b242af47..d1c9d53f 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 @@ -17,7 +17,6 @@ package com.arialyy.aria.core.download; import android.support.annotation.NonNull; import android.text.TextUtils; -import android.util.Log; import com.arialyy.aria.core.inf.AbsDownloadTarget; import com.arialyy.aria.core.manager.TEManager; import com.arialyy.aria.core.queue.DownloadTaskQueue; @@ -131,8 +130,14 @@ public class DownloadTarget /** * 是否在下载 + * + * @deprecated {@link #isRunning()} */ public boolean isDownloading() { + return isRunning(); + } + + @Override public boolean isRunning() { DownloadTask task = DownloadTaskQueue.getInstance().getTask(mEntity.getKey()); return task != null && task.isRunning(); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java index 8cb5fcb2..f7c51df7 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/FtpDirDownloadTarget.java @@ -18,6 +18,7 @@ package com.arialyy.aria.core.download; import android.text.TextUtils; import com.arialyy.aria.core.inf.AbsTaskEntity; import com.arialyy.aria.core.manager.TEManager; +import com.arialyy.aria.core.queue.DownloadGroupTaskQueue; import com.arialyy.aria.util.ALog; /** @@ -83,4 +84,9 @@ public class FtpDirDownloadTarget mTaskEntity.urlEntity.account = account; return this; } + + @Override public boolean isRunning() { + DownloadGroupTask task = DownloadGroupTaskQueue.getInstance().getTask(mEntity.getKey()); + return task != null && task.isRunning(); + } } 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 aea773c3..32d4a935 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,10 +42,24 @@ public abstract class AbsTarget { /** * 获取任务列表 */ - List getSimpleTaskList(); + List getTaskList(); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java index ca7180db..a0591d78 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java @@ -113,9 +113,8 @@ class BaseUListener { return DbEntity.findFirst(UploadEntity.class, "filePath=?", filePath) != null; } - @Override public List getSimpleTaskList() { + @Override public List getTaskList() { return DbEntity.findAllData(UploadEntity.class); } 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 c5f44524..748f063d 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 { static Map mapping = new HashMap<>(); static String DB_NAME; //static int VERSION = 16; - static int VERSION = 17; + static int VERSION = 18; 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 95a8f809..787d319a 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java @@ -36,6 +36,16 @@ 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); + } + /** * 检查某个字段的值是否存在 * 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 53940df8..3cc12950 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java @@ -64,6 +64,17 @@ 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); + } + /** * 检查某个字段的值是否存在 * 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 91bf52e2..e07d7c9a 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -162,14 +162,34 @@ 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 expression 字段和值"url=xxx" * @return {@code true}该字段的对应的value已存在 */ - static synchronized boolean checkDataExist(SQLiteDatabase db, Class clazz, - String... expression) { + static synchronized boolean checkDataExist(SQLiteDatabase db, Class clazz, String... expression) { db = checkDb(db); CheckUtil.checkSqlExpression(expression); String sql = @@ -414,12 +434,16 @@ final class SqlHelper extends SQLiteOpenHelper { * @return true,该数据库实体对应的表存在;false,不存在 */ static synchronized boolean tableExists(SQLiteDatabase db, Class clazz) { + return tableExists(db, CommonUtil.getClassName(clazz)); + } + + static synchronized boolean tableExists(SQLiteDatabase db, String tableName) { db = checkDb(db); Cursor cursor = null; try { StringBuilder sb = new StringBuilder(); sb.append("SELECT COUNT(*) AS c FROM sqlite_master WHERE type='table' AND name='"); - sb.append(CommonUtil.getClassName(clazz)); + sb.append(tableName); sb.append("'"); print(TABLE_EXISTS, sb.toString()); cursor = db.rawQuery(sb.toString(), null); @@ -446,14 +470,15 @@ final class SqlHelper extends SQLiteOpenHelper { */ static synchronized void createTable(SQLiteDatabase db, Class clazz, String tableName) { db = checkDb(db); + createFTSTable(db); List fields = CommonUtil.getAllFields(clazz); if (fields != null && fields.size() > 0) { //外键Map,在Sqlite3中foreign修饰的字段必须放在最后 final List foreignArray = new ArrayList<>(); StringBuilder sb = new StringBuilder(); - sb.append("create table ") + sb.append("create VIRTUAL table ") .append(TextUtils.isEmpty(tableName) ? CommonUtil.getClassName(clazz) : tableName) - .append("("); + .append(" USING fts4("); for (Field field : fields) { field.setAccessible(true); if (SqlUtil.ignoreField(field)) { @@ -486,7 +511,7 @@ final class SqlHelper extends SQLiteOpenHelper { } if (SqlUtil.isForeign(field)) { - foreignArray.add(field); + //foreignArray.add(field); } if (SqlUtil.isNoNull(field)) { @@ -514,6 +539,17 @@ final class SqlHelper extends SQLiteOpenHelper { close(db); } + /** + * 创建分词表 + */ + private static void createFTSTable(SQLiteDatabase db) { + String tableName = "ariaFts"; + String sql = "CREATE VIRTUAL TABLE " + tableName + " USING fts4(tokenize= porter)"; + if (!tableExists(db, tableName)) { + db.execSQL(sql); + } + } + /** * 打印数据库日志 * diff --git a/app/build.gradle b/app/build.gradle index 3776d524..f7b3c632 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -13,6 +13,7 @@ android { targetSdkVersion 23 versionCode 1 versionName "1.0" + multiDexEnabled true } buildTypes { release { diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 0220148e..7255c73f 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -5,10 +5,10 @@ - + - + diff --git a/app/src/main/java/com/arialyy/simple/download/HighestPriorityActivity.java b/app/src/main/java/com/arialyy/simple/download/HighestPriorityActivity.java index 6b699651..baa72ac9 100644 --- a/app/src/main/java/com/arialyy/simple/download/HighestPriorityActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/HighestPriorityActivity.java @@ -86,7 +86,7 @@ public class HighestPriorityActivity extends BaseActivity temp = Aria.download(this).getSimpleTaskList(); + List temp = Aria.download(this).getTaskList(); if (temp != null && !temp.isEmpty()) { for (DownloadEntity entity : temp) { if (entity.getUrl().equals(DOWNLOAD_URL)) continue; 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 7adfdc78..039e5484 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -58,9 +58,7 @@ 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://172.18.104.50:8080/download/_302turn"; "http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk"; - //"http://172.21.1.99:8080/download/test+ 中文123.zip"; @Bind(R.id.start) Button mStart; @Bind(R.id.stop) Button mStop; @Bind(R.id.cancel) Button mCancel; @@ -170,6 +168,7 @@ public class SingleTaskActivity extends BaseActivity { setBtState(true); getBinding().setSpeed(""); L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath()))); + L.d(TAG, "data ==> " + Aria.download(this).getDownloadEntity(DOWNLOAD_URL)); } @Download.onNoSupportBreakPoint @@ -200,20 +199,10 @@ public class SingleTaskActivity extends BaseActivity { switch (view.getId()) { case R.id.start: startD(); - //new Thread(new Runnable() { - // @Override public void run() { - // startD(); - // } - //}).start(); - // - //new Thread(new Runnable() { - // @Override public void run() { - // startD(); - // } - //}).start(); break; case R.id.stop: Aria.download(this).load(DOWNLOAD_URL).stop(); + //Aria.download(this).load(DOWNLOAD_URL).removeRecord(); break; case R.id.cancel: Aria.download(this).load(DOWNLOAD_URL).cancel(); diff --git a/aria/src/main/java/com/arialyy/aria/core/Configuration.java b/aria/src/main/java/com/arialyy/aria/core/Configuration.java index 0b927cf7..6ae2b732 100644 --- a/aria/src/main/java/com/arialyy/aria/core/Configuration.java +++ b/aria/src/main/java/com/arialyy/aria/core/Configuration.java @@ -157,8 +157,13 @@ class Configuration { try { for (Field field : fields) { int m = field.getModifiers(); - if (field.getName().equals("oldMaxTaskNum") || Modifier.isFinal(m) || Modifier.isStatic( - m)) { + String fileName = field.getName(); + if (fileName.equals("oldMaxTaskNum") + || field.isSynthetic() + || Modifier.isFinal(m) + || Modifier.isStatic(m) + || fileName.equals("shadow$_klass_") + || fileName.equals("shadow$_monitor_")) { continue; } field.setAccessible(true); @@ -267,6 +272,11 @@ class Configuration { return this; } + public void setThreadNum(int threadNum){ + this.threadNum = threadNum; + saveKey("threadNum", String.valueOf(threadNum)); + } + public DownloadConfig setIOTimeOut(int iOTimeOut) { this.iOTimeOut = iOTimeOut; saveKey("iOTimeOut", iOTimeOut + ""); From 8bcdf35353df77ea812b3751e1e6be2c91c60b8f Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Wed, 27 Dec 2017 21:17:52 +0800 Subject: [PATCH 3/4] =?UTF-8?q?=E4=BF=AE=E5=A4=8Dhead=E5=A4=B4=E9=83=A8?= =?UTF-8?q?=E4=BF=A1=E6=81=AF=E8=BF=87=E9=95=BF=E6=97=B6=E5=87=BA=E7=8E=B0?= =?UTF-8?q?=E7=9A=84=E5=B4=A9=E6=BA=83=E9=97=AE=E9=A2=98=20https://github.?= =?UTF-8?q?com/AriaLyy/Aria/issues/177?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .../com/arialyy/aria/core/inf/AbsTarget.java | 26 +++++++++++++++++++ .../java/com/arialyy/aria/orm/DBConfig.java | 3 +-- .../java/com/arialyy/aria/orm/SqlHelper.java | 8 +++--- DEV_LOG.md | 2 ++ app/src/main/assets/aria_config.xml | 2 +- .../simple/download/SingleTaskActivity.java | 15 ++++++++--- build.gradle | 2 +- 7 files changed, 47 insertions(+), 11 deletions(-) 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 ea30b47f..ab174537 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 @@ -150,7 +150,21 @@ public abstract class AbsTarget headers) { + return addHeaders(headers, false); + } + + /** + * 给url请求添加头部 + * + * @param refreshHeader 更新数据库中保存的头部信息 + */ + public TARGET addHeaders(Map headers, boolean refreshHeader) { if (headers != null && headers.size() > 0) { Set keys = headers.keySet(); for (String key : keys) { mTaskEntity.headers.put(key, headers.get(key)); } } + if (refreshHeader) { + mTaskEntity.update(); + } return (TARGET) this; } 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 748f063d..d691dec1 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java @@ -34,8 +34,7 @@ import java.util.Map; class DBConfig { static Map mapping = new HashMap<>(); static String DB_NAME; - //static int VERSION = 16; - static int VERSION = 18; + static int VERSION = 20; static { if (TextUtils.isEmpty(DB_NAME)) { 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 e07d7c9a..bc4671c3 100644 --- a/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java +++ b/Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java @@ -175,7 +175,8 @@ final class SqlHelper extends SQLiteOpenHelper { + " WHERE " + column + " MATCH '" - + mathSql + "'"; + + mathSql + + "'"; Cursor cursor = db.rawQuery(sql, null); List data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; @@ -486,8 +487,7 @@ final class SqlHelper extends SQLiteOpenHelper { } Class type = field.getType(); sb.append(field.getName()); - if (type == String.class || type == Map.class || type == List.class || SqlUtil.isOneToOne( - field) || type.isEnum()) { + if (type == String.class || SqlUtil.isOneToOne(field) || type.isEnum()) { sb.append(" varchar"); } else if (type == int.class || type == Integer.class) { sb.append(" interger"); @@ -503,6 +503,8 @@ final class SqlHelper extends SQLiteOpenHelper { sb.append(" data"); } else if (type == byte.class || type == Byte.class) { sb.append(" blob"); + } else if (type == Map.class || type == List.class) { + sb.append(" text"); } else { continue; } diff --git a/DEV_LOG.md b/DEV_LOG.md index b088dc4f..b7753db3 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,6 +1,8 @@ ## 开发日志 + v_3.3.8 - 添加POST支持 + - 任务执行的过程中,如果调用removeRecord()方法,将会取消任务 https://github.com/AriaLyy/Aria/issues/174 + - 修复一个数据库初始化的问题 https://github.com/AriaLyy/Aria/issues/173 + v_3.3.7 - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 7255c73f..92324c01 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -5,7 +5,7 @@ - + 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 14361bff..fd14a025 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -43,6 +43,8 @@ import com.arialyy.simple.R; import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.databinding.ActivitySingleBinding; import java.io.File; +import java.util.HashMap; +import java.util.Map; public class SingleTaskActivity extends BaseActivity { @@ -59,7 +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://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; @@ -214,11 +217,15 @@ public class SingleTaskActivity extends BaseActivity { private void startD(){ //Aria.get(this).setLogLevel(ALog.LOG_CLOSE); //Aria.download(this).load("aaaa.apk"); + Map map = new HashMap<>(); + map.put("User-Agent", "Mozilla/5.0 (Linux; Android 4.4.4; Nexus 5 Build/KTU84P; wv) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/57.0.2987.132 Mobile MQQBrowser/6.2 TBS/043722 Safari/537.36"); + map.put("Cookie", "BAIDUID=DFC7EF42C60AD1ACF0BA94389AA67F13:FG=1; H_WISE_SIDS=121192_104493_114745_121434_119046_100098_120212_121140_118882_118858_118850_118820_118792_121254_121534_121214_117588_117242_117431_119974_120597_121043_121422_120943_121175_121272_117552_120482_121013_119962_119145_120851_120841_120034_121325_116407_121109_120654_110085_120708; PSINO=7; BDORZ=AE84CDB3A529C0F8A2B9DCDD1D18B695"); Aria.download(SingleTaskActivity.this) .load(DOWNLOAD_URL) - .addHeader("groupName", "value") - .setRequestMode(RequestEnum.POST) - .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") + //.addHeader("groupName", "value") + .addHeaders(map) + //.setRequestMode(RequestEnum.POST) + .setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/ggsg.apk") .start(); } diff --git a/build.gradle b/build.gradle index dca1776b..c0cc2f4d 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.7' + publishVersion = '3.3.8' // publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架' From d341f9dd9ff156cc1114a40ac60eb16b2c258c8c Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Wed, 27 Dec 2017 21:51:38 +0800 Subject: [PATCH 4/4] 3.3.9 --- DEV_LOG.md | 3 ++- build.gradle | 2 +- 2 files changed, 3 insertions(+), 2 deletions(-) diff --git a/DEV_LOG.md b/DEV_LOG.md index b7753db3..923c075a 100644 --- a/DEV_LOG.md +++ b/DEV_LOG.md @@ -1,8 +1,9 @@ ## 开发日志 - + v_3.3.8 + + v_3.3.9 - 添加POST支持 - 任务执行的过程中,如果调用removeRecord()方法,将会取消任务 https://github.com/AriaLyy/Aria/issues/174 - 修复一个数据库初始化的问题 https://github.com/AriaLyy/Aria/issues/173 + - 修复head头部信息过长时出现的崩溃问题 https://github.com/AriaLyy/Aria/issues/177 + v_3.3.7 - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 diff --git a/build.gradle b/build.gradle index c0cc2f4d..77153ac4 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.8' + publishVersion = '3.3.9' // publishVersion = '1.0.3' //FTP插件 repoName='maven' desc = 'android 下载框架'