修复head头部信息过长时出现的崩溃问题 https://github.com/AriaLyy/Aria/issues/177

pull/330/head
AriaLyy 7 years ago
parent 8b322176d1
commit 8bcdf35353
  1. 26
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTarget.java
  2. 3
      Aria/src/main/java/com/arialyy/aria/orm/DBConfig.java
  3. 8
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  4. 2
      DEV_LOG.md
  5. 2
      app/src/main/assets/aria_config.xml
  6. 15
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  7. 2
      build.gradle

@ -150,7 +150,21 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
* @param header 头部value * @param header 头部value
*/ */
public TARGET addHeader(@NonNull String key, @NonNull String header) { public TARGET addHeader(@NonNull String key, @NonNull String header) {
return addHeader(key, header, false);
}
/**
* 给url请求添加头部
*
* @param key 头部key
* @param header 头部value
* @param refreshHeader 更新数据库中保存的头部信息
*/
public TARGET addHeader(@NonNull String key, @NonNull String header, boolean refreshHeader) {
mTaskEntity.headers.put(key, header); mTaskEntity.headers.put(key, header);
if (refreshHeader) {
mTaskEntity.update();
}
return (TARGET) this; return (TARGET) this;
} }
@ -158,12 +172,24 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
* 给url请求添加头部 * 给url请求添加头部
*/ */
public TARGET addHeaders(Map<String, String> headers) { public TARGET addHeaders(Map<String, String> headers) {
return addHeaders(headers, false);
}
/**
* 给url请求添加头部
*
* @param refreshHeader 更新数据库中保存的头部信息
*/
public TARGET addHeaders(Map<String, String> headers, boolean refreshHeader) {
if (headers != null && headers.size() > 0) { if (headers != null && headers.size() > 0) {
Set<String> keys = headers.keySet(); Set<String> keys = headers.keySet();
for (String key : keys) { for (String key : keys) {
mTaskEntity.headers.put(key, headers.get(key)); mTaskEntity.headers.put(key, headers.get(key));
} }
} }
if (refreshHeader) {
mTaskEntity.update();
}
return (TARGET) this; return (TARGET) this;
} }

@ -34,8 +34,7 @@ import java.util.Map;
class DBConfig { class DBConfig {
static Map<String, Class> mapping = new HashMap<>(); static Map<String, Class> mapping = new HashMap<>();
static String DB_NAME; static String DB_NAME;
//static int VERSION = 16; static int VERSION = 20;
static int VERSION = 18;
static { static {
if (TextUtils.isEmpty(DB_NAME)) { if (TextUtils.isEmpty(DB_NAME)) {

@ -175,7 +175,8 @@ final class SqlHelper extends SQLiteOpenHelper {
+ " WHERE " + " WHERE "
+ column + column
+ " MATCH '" + " MATCH '"
+ mathSql + "'"; + mathSql
+ "'";
Cursor cursor = db.rawQuery(sql, null); Cursor cursor = db.rawQuery(sql, null);
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null; List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null;
@ -486,8 +487,7 @@ final class SqlHelper extends SQLiteOpenHelper {
} }
Class<?> type = field.getType(); Class<?> type = field.getType();
sb.append(field.getName()); sb.append(field.getName());
if (type == String.class || type == Map.class || type == List.class || SqlUtil.isOneToOne( if (type == String.class || SqlUtil.isOneToOne(field) || type.isEnum()) {
field) || type.isEnum()) {
sb.append(" varchar"); sb.append(" varchar");
} else if (type == int.class || type == Integer.class) { } else if (type == int.class || type == Integer.class) {
sb.append(" interger"); sb.append(" interger");
@ -503,6 +503,8 @@ final class SqlHelper extends SQLiteOpenHelper {
sb.append(" data"); sb.append(" data");
} else if (type == byte.class || type == Byte.class) { } else if (type == byte.class || type == Byte.class) {
sb.append(" blob"); sb.append(" blob");
} else if (type == Map.class || type == List.class) {
sb.append(" text");
} else { } else {
continue; continue;
} }

@ -1,6 +1,8 @@
## 开发日志 ## 开发日志
+ v_3.3.8 + v_3.3.8
- 添加POST支持 - 添加POST支持
- 任务执行的过程中,如果调用removeRecord()方法,将会取消任务 https://github.com/AriaLyy/Aria/issues/174
- 修复一个数据库初始化的问题 https://github.com/AriaLyy/Aria/issues/173
+ v_3.3.7 + v_3.3.7
- 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160 - 修复一个线程重启的问题 https://github.com/AriaLyy/Aria/issues/160
- 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161 - 修复配置文件异常问题、格式化速度为0问题 https://github.com/AriaLyy/Aria/issues/161

@ -5,7 +5,7 @@
<download> <download>
<!--设置下载线程,线程下载数改变后,新的下载任务才会生效,如果任务大小小于1m,该设置也不会生效--> <!--设置下载线程,线程下载数改变后,新的下载任务才会生效,如果任务大小小于1m,该设置也不会生效-->
<threadNum value="1"/> <threadNum value="3"/>
<!--设置下载队列最大任务数, 默认为2--> <!--设置下载队列最大任务数, 默认为2-->
<maxTaskNum value="2"/> <maxTaskNum value="2"/>

@ -43,6 +43,8 @@ import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivitySingleBinding; import com.arialyy.simple.databinding.ActivitySingleBinding;
import java.io.File; import java.io.File;
import java.util.HashMap;
import java.util.Map;
public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> { public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
@ -59,7 +61,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
//"http://down8.androidgame-store.com/201706122321/97967927DD4E53D9905ECAA7874C8128/new/game1/19/45319/com.neuralprisma-2.5.2.174-2000174_1494784835.apk?f=web_1"; //"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://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.start) Button mStart;
@Bind(R.id.stop) Button mStop; @Bind(R.id.stop) Button mStop;
@Bind(R.id.cancel) Button mCancel; @Bind(R.id.cancel) Button mCancel;
@ -214,11 +217,15 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
private void startD(){ private void startD(){
//Aria.get(this).setLogLevel(ALog.LOG_CLOSE); //Aria.get(this).setLogLevel(ALog.LOG_CLOSE);
//Aria.download(this).load("aaaa.apk"); //Aria.download(this).load("aaaa.apk");
Map<String, String> 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) Aria.download(SingleTaskActivity.this)
.load(DOWNLOAD_URL) .load(DOWNLOAD_URL)
.addHeader("groupName", "value") //.addHeader("groupName", "value")
.setRequestMode(RequestEnum.POST) .addHeaders(map)
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk") //.setRequestMode(RequestEnum.POST)
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/ggsg.apk")
.start(); .start();
} }

@ -39,7 +39,7 @@ task clean(type: Delete) {
ext { ext {
userOrg = 'arialyy' userOrg = 'arialyy'
groupId = 'com.arialyy.aria' groupId = 'com.arialyy.aria'
publishVersion = '3.3.7' publishVersion = '3.3.8'
// publishVersion = '1.0.3' //FTP插件 // publishVersion = '1.0.3' //FTP插件
repoName='maven' repoName='maven'
desc = 'android 下载框架' desc = 'android 下载框架'

Loading…
Cancel
Save