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

This commit is contained in:
AriaLyy
2017-12-27 21:17:52 +08:00
parent 8b322176d1
commit 8bcdf35353
7 changed files with 47 additions and 11 deletions

View File

@@ -150,7 +150,21 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
* @param header 头部value
*/
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);
if (refreshHeader) {
mTaskEntity.update();
}
return (TARGET) this;
}
@@ -158,12 +172,24 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
* 给url请求添加头部
*/
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) {
Set<String> keys = headers.keySet();
for (String key : keys) {
mTaskEntity.headers.put(key, headers.get(key));
}
}
if (refreshHeader) {
mTaskEntity.update();
}
return (TARGET) this;
}

View File

@@ -34,8 +34,7 @@ import java.util.Map;
class DBConfig {
static Map<String, Class> 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)) {

View File

@@ -175,7 +175,8 @@ final class SqlHelper extends SQLiteOpenHelper {
+ " WHERE "
+ column
+ " MATCH '"
+ mathSql + "'";
+ mathSql
+ "'";
Cursor cursor = db.rawQuery(sql, 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();
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;
}