Merge branch 'v_3.0'
This commit is contained in:
commit
1322d8209d
26 files changed
+210
-46
No files matched your search
@@ -100,7 +100,7 @@ public abstract class AbsFtpThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTI
|
|||||||
client.setDataTimeout(10 * 1000);
|
client.setDataTimeout(10 * 1000);
|
||||||
client.enterLocalPassiveMode();
|
client.enterLocalPassiveMode();
|
||||||
client.setFileType(FTP.BINARY_FILE_TYPE);
|
client.setFileType(FTP.BINARY_FILE_TYPE);
|
||||||
client.setControlKeepAliveTimeout(5);
|
client.setControlKeepAliveTimeout(5000);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -125,9 +125,8 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
|||||||
private void handleSpeed(long speed) {
|
private void handleSpeed(long speed) {
|
||||||
if (isConvertSpeed) {
|
if (isConvertSpeed) {
|
||||||
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
|
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
|
||||||
} else {
|
|
||||||
mEntity.setSpeed(speed < 0 ? 0 : speed);
|
|
||||||
}
|
}
|
||||||
|
mEntity.setSpeed(speed < 0 ? 0 : speed);
|
||||||
|
|
||||||
mEntity.setPercent((int) (mEntity.getFileSize() <= 0 ? 0
|
mEntity.setPercent((int) (mEntity.getFileSize() <= 0 ? 0
|
||||||
: mEntity.getCurrentProgress() * 100 / mEntity.getFileSize()));
|
: mEntity.getCurrentProgress() * 100 / mEntity.getFileSize()));
|
||||||
|
|||||||
@@ -16,6 +16,7 @@
|
|||||||
package com.arialyy.aria.core.download;
|
package com.arialyy.aria.core.download;
|
||||||
|
|
||||||
import com.arialyy.aria.core.manager.TEManager;
|
import com.arialyy.aria.core.manager.TEManager;
|
||||||
|
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
import com.arialyy.aria.util.CheckUtil;
|
import com.arialyy.aria.util.CheckUtil;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
@@ -86,4 +87,9 @@ public class DownloadGroupTarget
|
|||||||
mEntity.update();
|
mEntity.update();
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean isRunning() {
|
||||||
|
DownloadGroupTask task = DownloadGroupTaskQueue.getInstance().getTask(mEntity.getKey());
|
||||||
|
return task != null && task.isRunning();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -28,7 +28,6 @@ import com.arialyy.aria.core.scheduler.DownloadGroupSchedulers;
|
|||||||
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
|
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
|
||||||
import com.arialyy.aria.core.scheduler.ISchedulerListener;
|
import com.arialyy.aria.core.scheduler.ISchedulerListener;
|
||||||
import com.arialyy.aria.orm.DbEntity;
|
import com.arialyy.aria.orm.DbEntity;
|
||||||
import com.arialyy.aria.util.ALog;
|
|
||||||
import com.arialyy.aria.util.CheckUtil;
|
import com.arialyy.aria.util.CheckUtil;
|
||||||
import com.arialyy.aria.util.CommonUtil;
|
import com.arialyy.aria.util.CommonUtil;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
@@ -250,13 +249,31 @@ public class DownloadReceiver extends AbsReceiver {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取普通下载任务列表
|
* 获取所有普通下载任务
|
||||||
|
* 获取未完成的普通任务列表{@link #getAllNotCompletTask()}
|
||||||
|
* 获取已经完成的普通任务列表{@link #getAllCompleteTask()}
|
||||||
*/
|
*/
|
||||||
@Override public List<DownloadEntity> getSimpleTaskList() {
|
@Override public List<DownloadEntity> getTaskList() {
|
||||||
return DownloadEntity.findDatas(DownloadEntity.class, "isGroupChild=? and downloadPath!=''",
|
return DownloadEntity.findDatas(DownloadEntity.class, "isGroupChild=? and downloadPath!=''",
|
||||||
"false");
|
"false");
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有未完成的普通下载任务
|
||||||
|
*/
|
||||||
|
public List<DownloadEntity> getAllNotCompletTask() {
|
||||||
|
return DownloadEntity.findDatas(DownloadEntity.class,
|
||||||
|
"isGroupChild=? and downloadPath!='' and isComplete=?", "false", "false");
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 获取所有已经完成的普通任务
|
||||||
|
*/
|
||||||
|
public List<DownloadEntity> getAllCompleteTask() {
|
||||||
|
return DownloadEntity.findDatas(DownloadEntity.class,
|
||||||
|
"isGroupChild=? and downloadPath!='' and isComplete=?", "false", "true");
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 获取任务组列表
|
* 获取任务组列表
|
||||||
*/
|
*/
|
||||||
@@ -269,7 +286,7 @@ public class DownloadReceiver extends AbsReceiver {
|
|||||||
*/
|
*/
|
||||||
public List<AbsEntity> getTotleTaskList() {
|
public List<AbsEntity> getTotleTaskList() {
|
||||||
List<AbsEntity> list = new ArrayList<>();
|
List<AbsEntity> list = new ArrayList<>();
|
||||||
List<DownloadEntity> simpleTask = getSimpleTaskList();
|
List<DownloadEntity> simpleTask = getTaskList();
|
||||||
List<DownloadGroupEntity> groupTask = getGroupTaskList();
|
List<DownloadGroupEntity> groupTask = getGroupTaskList();
|
||||||
if (simpleTask != null && !simpleTask.isEmpty()) {
|
if (simpleTask != null && !simpleTask.isEmpty()) {
|
||||||
list.addAll(simpleTask);
|
list.addAll(simpleTask);
|
||||||
|
|||||||
@@ -17,7 +17,6 @@ package com.arialyy.aria.core.download;
|
|||||||
|
|
||||||
import android.support.annotation.NonNull;
|
import android.support.annotation.NonNull;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import android.util.Log;
|
|
||||||
import com.arialyy.aria.core.inf.AbsDownloadTarget;
|
import com.arialyy.aria.core.inf.AbsDownloadTarget;
|
||||||
import com.arialyy.aria.core.manager.TEManager;
|
import com.arialyy.aria.core.manager.TEManager;
|
||||||
import com.arialyy.aria.core.queue.DownloadTaskQueue;
|
import com.arialyy.aria.core.queue.DownloadTaskQueue;
|
||||||
@@ -63,6 +62,18 @@ public class DownloadTarget
|
|||||||
mTaskEntity.refreshInfo = refreshInfo;
|
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、在下载队列中,有且只有一个最高优先级任务
|
* 1、在下载队列中,有且只有一个最高优先级任务
|
||||||
@@ -131,8 +142,14 @@ public class DownloadTarget
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否在下载
|
* 是否在下载
|
||||||
|
*
|
||||||
|
* @deprecated {@link #isRunning()}
|
||||||
*/
|
*/
|
||||||
public boolean isDownloading() {
|
public boolean isDownloading() {
|
||||||
|
return isRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean isRunning() {
|
||||||
DownloadTask task = DownloadTaskQueue.getInstance().getTask(mEntity.getKey());
|
DownloadTask task = DownloadTaskQueue.getInstance().getTask(mEntity.getKey());
|
||||||
return task != null && task.isRunning();
|
return task != null && task.isRunning();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -18,6 +18,7 @@ package com.arialyy.aria.core.download;
|
|||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||||
import com.arialyy.aria.core.manager.TEManager;
|
import com.arialyy.aria.core.manager.TEManager;
|
||||||
|
import com.arialyy.aria.core.queue.DownloadGroupTaskQueue;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -83,4 +84,9 @@ public class FtpDirDownloadTarget
|
|||||||
mTaskEntity.urlEntity.account = account;
|
mTaskEntity.urlEntity.account = account;
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override public boolean isRunning() {
|
||||||
|
DownloadGroupTask task = DownloadGroupTaskQueue.getInstance().getTask(mEntity.getKey());
|
||||||
|
return task != null && task.isRunning();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
@@ -54,6 +54,7 @@ class HttpFileInfoThread implements Runnable {
|
|||||||
conn = ConnectionHelp.setConnectParam(mTaskEntity, conn);
|
conn = ConnectionHelp.setConnectParam(mTaskEntity, conn);
|
||||||
conn.setRequestProperty("Range", "bytes=" + 0 + "-");
|
conn.setRequestProperty("Range", "bytes=" + 0 + "-");
|
||||||
conn.setConnectTimeout(mConnectTimeOut);
|
conn.setConnectTimeout(mConnectTimeOut);
|
||||||
|
conn.setRequestMethod(mTaskEntity.requestEnum.name);
|
||||||
conn.connect();
|
conn.connect();
|
||||||
handleConnect(conn);
|
handleConnect(conn);
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
|
|||||||
@@ -42,10 +42,24 @@ public abstract class AbsTarget<TARGET extends AbsTarget, ENTITY extends AbsEnti
|
|||||||
protected String mTargetName;
|
protected String mTargetName;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除记录
|
* 删除记录,如果任务正在执行,则会删除正在下载的任务
|
||||||
*/
|
*/
|
||||||
public void removeRecord() {
|
public void removeRecord() {
|
||||||
mTaskEntity.deleteData();
|
if (isRunning()) {
|
||||||
|
ALog.d("AbsTarget", "任务正在下载,即将删除任务");
|
||||||
|
cancel();
|
||||||
|
} else {
|
||||||
|
mTaskEntity.deleteData();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 任务是否在执行
|
||||||
|
*
|
||||||
|
* @return {@code true} 任务正在执行
|
||||||
|
*/
|
||||||
|
public boolean isRunning() {
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -136,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;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,17 +172,30 @@ 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;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 设置请求类型
|
* 设置请求类型,POST或GET,默认为在GET
|
||||||
|
* 只试用于HTTP请求
|
||||||
*
|
*
|
||||||
* @param requestEnum {@link RequestEnum}
|
* @param requestEnum {@link RequestEnum}
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -105,6 +105,12 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
|
|||||||
*/
|
*/
|
||||||
public String md5Key = "Content-MD5";
|
public String md5Key = "Content-MD5";
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 是否使用服务器通过content-disposition传递的文件名,内容格式{@code attachment;filename=***}
|
||||||
|
* {@code true} 使用
|
||||||
|
*/
|
||||||
|
public boolean useServerFileName = false;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 从header中获取文件描述信息所需要的key
|
* 从header中获取文件描述信息所需要的key
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -51,8 +51,14 @@ public abstract class AbsUploadTarget<TARGET extends AbsUploadTarget, ENTITY ext
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 是否在下载
|
* 是否在下载
|
||||||
|
*
|
||||||
|
* @deprecated {@link #isRunning()}
|
||||||
*/
|
*/
|
||||||
public boolean isUploading() {
|
public boolean isUploading() {
|
||||||
|
return isRunning();
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override public boolean isRunning() {
|
||||||
UploadTask task = UploadTaskQueue.getInstance().getTask(mEntity.getKey());
|
UploadTask task = UploadTaskQueue.getInstance().getTask(mEntity.getKey());
|
||||||
return task != null && task.isRunning();
|
return task != null && task.isRunning();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -52,5 +52,5 @@ public interface IReceiver<ENTITY extends IEntity> {
|
|||||||
/**
|
/**
|
||||||
* 获取任务列表
|
* 获取任务列表
|
||||||
*/
|
*/
|
||||||
List<ENTITY> getSimpleTaskList();
|
List<ENTITY> getTaskList();
|
||||||
}
|
}
|
||||||
@@ -113,9 +113,8 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
|||||||
private void handleSpeed(long speed) {
|
private void handleSpeed(long speed) {
|
||||||
if (isConvertSpeed) {
|
if (isConvertSpeed) {
|
||||||
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
|
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
|
||||||
} else {
|
|
||||||
mEntity.setSpeed(speed < 0 ? 0 : speed);
|
|
||||||
}
|
}
|
||||||
|
mEntity.setSpeed(speed < 0 ? 0 : speed);
|
||||||
mEntity.setPercent((int) (mEntity.getFileSize() <= 0 ? 0
|
mEntity.setPercent((int) (mEntity.getFileSize() <= 0 ? 0
|
||||||
: mEntity.getCurrentProgress() * 100 / mEntity.getFileSize()));
|
: mEntity.getCurrentProgress() * 100 / mEntity.getFileSize()));
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -72,7 +72,7 @@ public class UploadReceiver extends AbsReceiver<UploadEntity> {
|
|||||||
return DbEntity.findFirst(UploadEntity.class, "filePath=?", filePath) != null;
|
return DbEntity.findFirst(UploadEntity.class, "filePath=?", filePath) != null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override public List<UploadEntity> getSimpleTaskList() {
|
@Override public List<UploadEntity> getTaskList() {
|
||||||
return DbEntity.findAllData(UploadEntity.class);
|
return DbEntity.findAllData(UploadEntity.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -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 = 17;
|
|
||||||
|
|
||||||
static {
|
static {
|
||||||
if (TextUtils.isEmpty(DB_NAME)) {
|
if (TextUtils.isEmpty(DB_NAME)) {
|
||||||
|
|||||||
@@ -36,6 +36,16 @@ public class DbEntity {
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关键字模糊检索全文
|
||||||
|
*
|
||||||
|
* @param column 需要查找的列
|
||||||
|
* @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green”
|
||||||
|
*/
|
||||||
|
public static <T extends DbEntity> List<T> searchData(Class<T> clazz, String column, String mathSql) {
|
||||||
|
return DbUtil.getInstance().searchData(clazz, column, mathSql);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查某个字段的值是否存在
|
* 检查某个字段的值是否存在
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -64,6 +64,17 @@ public class DbUtil {
|
|||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关键字模糊检索全文
|
||||||
|
*
|
||||||
|
* @param column 需要查找的列
|
||||||
|
* @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green”
|
||||||
|
*/
|
||||||
|
public <T extends DbEntity> List<T> searchData(Class<T> clazz, String column, String mathSql) {
|
||||||
|
checkDb();
|
||||||
|
return SqlHelper.searchData(mDb, clazz, column, mathSql);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查某个字段的值是否存在
|
* 检查某个字段的值是否存在
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -162,14 +162,35 @@ final class SqlHelper extends SQLiteOpenHelper {
|
|||||||
return count;
|
return count;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* 关键字模糊检索全文
|
||||||
|
*
|
||||||
|
* @param column 需要查找的列
|
||||||
|
* @param mathSql 关键字语法,exsimple “white OR green”、“blue AND red”、“white NOT green”
|
||||||
|
*/
|
||||||
|
public static <T extends DbEntity> List<T> searchData(SQLiteDatabase db, Class<T> clazz,
|
||||||
|
String column, String mathSql) {
|
||||||
|
String sql = "SELECT * FROM "
|
||||||
|
+ CommonUtil.getClassName(clazz)
|
||||||
|
+ " WHERE "
|
||||||
|
+ column
|
||||||
|
+ " MATCH '"
|
||||||
|
+ mathSql
|
||||||
|
+ "'";
|
||||||
|
|
||||||
|
Cursor cursor = db.rawQuery(sql, null);
|
||||||
|
List<T> data = cursor.getCount() > 0 ? newInstanceEntity(db, clazz, cursor) : null;
|
||||||
|
closeCursor(cursor);
|
||||||
|
return data;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查某个字段的值是否存在
|
* 检查某个字段的值是否存在
|
||||||
*
|
*
|
||||||
* @param expression 字段和值"url=xxx"
|
* @param expression 字段和值"url=xxx"
|
||||||
* @return {@code true}该字段的对应的value已存在
|
* @return {@code true}该字段的对应的value已存在
|
||||||
*/
|
*/
|
||||||
static synchronized boolean checkDataExist(SQLiteDatabase db, Class clazz,
|
static synchronized boolean checkDataExist(SQLiteDatabase db, Class clazz, String... expression) {
|
||||||
String... expression) {
|
|
||||||
db = checkDb(db);
|
db = checkDb(db);
|
||||||
CheckUtil.checkSqlExpression(expression);
|
CheckUtil.checkSqlExpression(expression);
|
||||||
String sql =
|
String sql =
|
||||||
@@ -414,12 +435,16 @@ final class SqlHelper extends SQLiteOpenHelper {
|
|||||||
* @return true,该数据库实体对应的表存在;false,不存在
|
* @return true,该数据库实体对应的表存在;false,不存在
|
||||||
*/
|
*/
|
||||||
static synchronized boolean tableExists(SQLiteDatabase db, Class clazz) {
|
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);
|
db = checkDb(db);
|
||||||
Cursor cursor = null;
|
Cursor cursor = null;
|
||||||
try {
|
try {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("SELECT COUNT(*) AS c FROM sqlite_master WHERE type='table' AND name='");
|
sb.append("SELECT COUNT(*) AS c FROM sqlite_master WHERE type='table' AND name='");
|
||||||
sb.append(CommonUtil.getClassName(clazz));
|
sb.append(tableName);
|
||||||
sb.append("'");
|
sb.append("'");
|
||||||
print(TABLE_EXISTS, sb.toString());
|
print(TABLE_EXISTS, sb.toString());
|
||||||
cursor = db.rawQuery(sb.toString(), null);
|
cursor = db.rawQuery(sb.toString(), null);
|
||||||
@@ -446,14 +471,15 @@ final class SqlHelper extends SQLiteOpenHelper {
|
|||||||
*/
|
*/
|
||||||
static synchronized void createTable(SQLiteDatabase db, Class clazz, String tableName) {
|
static synchronized void createTable(SQLiteDatabase db, Class clazz, String tableName) {
|
||||||
db = checkDb(db);
|
db = checkDb(db);
|
||||||
|
createFTSTable(db);
|
||||||
List<Field> fields = CommonUtil.getAllFields(clazz);
|
List<Field> fields = CommonUtil.getAllFields(clazz);
|
||||||
if (fields != null && fields.size() > 0) {
|
if (fields != null && fields.size() > 0) {
|
||||||
//外键Map,在Sqlite3中foreign修饰的字段必须放在最后
|
//外键Map,在Sqlite3中foreign修饰的字段必须放在最后
|
||||||
final List<Field> foreignArray = new ArrayList<>();
|
final List<Field> foreignArray = new ArrayList<>();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
sb.append("create table ")
|
sb.append("create VIRTUAL table ")
|
||||||
.append(TextUtils.isEmpty(tableName) ? CommonUtil.getClassName(clazz) : tableName)
|
.append(TextUtils.isEmpty(tableName) ? CommonUtil.getClassName(clazz) : tableName)
|
||||||
.append("(");
|
.append(" USING fts4(");
|
||||||
for (Field field : fields) {
|
for (Field field : fields) {
|
||||||
field.setAccessible(true);
|
field.setAccessible(true);
|
||||||
if (SqlUtil.ignoreField(field)) {
|
if (SqlUtil.ignoreField(field)) {
|
||||||
@@ -461,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");
|
||||||
@@ -478,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;
|
||||||
}
|
}
|
||||||
@@ -486,7 +513,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
|||||||
|
|
||||||
}
|
}
|
||||||
if (SqlUtil.isForeign(field)) {
|
if (SqlUtil.isForeign(field)) {
|
||||||
foreignArray.add(field);
|
//foreignArray.add(field);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (SqlUtil.isNoNull(field)) {
|
if (SqlUtil.isNoNull(field)) {
|
||||||
@@ -514,6 +541,17 @@ final class SqlHelper extends SQLiteOpenHelper {
|
|||||||
close(db);
|
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);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 打印数据库日志
|
* 打印数据库日志
|
||||||
*
|
*
|
||||||
|
|||||||
@@ -1,4 +1,9 @@
|
|||||||
## 开发日志
|
## 开发日志
|
||||||
|
+ 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
|
+ 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
|
||||||
|
|||||||
@@ -13,6 +13,7 @@ android {
|
|||||||
targetSdkVersion 23
|
targetSdkVersion 23
|
||||||
versionCode 1
|
versionCode 1
|
||||||
versionName "1.0"
|
versionName "1.0"
|
||||||
|
multiDexEnabled true
|
||||||
}
|
}
|
||||||
buildTypes {
|
buildTypes {
|
||||||
release {
|
release {
|
||||||
|
|||||||
@@ -8,7 +8,7 @@
|
|||||||
<threadNum value="3"/>
|
<threadNum value="3"/>
|
||||||
|
|
||||||
<!--设置下载队列最大任务数, 默认为2-->
|
<!--设置下载队列最大任务数, 默认为2-->
|
||||||
<maxTaskNum value="1"/>
|
<maxTaskNum value="2"/>
|
||||||
|
|
||||||
<!--设置下载失败,重试次数,默认为10-->
|
<!--设置下载失败,重试次数,默认为10-->
|
||||||
<reTryNum value="2"/>
|
<reTryNum value="2"/>
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ public class HighestPriorityActivity extends BaseActivity<ActivityHighestPriorit
|
|||||||
setBtState(false);
|
setBtState(false);
|
||||||
}
|
}
|
||||||
mSize.setText(target.getConvertFileSize());
|
mSize.setText(target.getConvertFileSize());
|
||||||
List<DownloadEntity> temp = Aria.download(this).getSimpleTaskList();
|
List<DownloadEntity> temp = Aria.download(this).getTaskList();
|
||||||
if (temp != null && !temp.isEmpty()) {
|
if (temp != null && !temp.isEmpty()) {
|
||||||
for (DownloadEntity entity : temp) {
|
for (DownloadEntity entity : temp) {
|
||||||
if (entity.getUrl().equals(DOWNLOAD_URL)) continue;
|
if (entity.getUrl().equals(DOWNLOAD_URL)) continue;
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ import butterknife.Bind;
|
|||||||
import com.arialyy.annotations.Download;
|
import com.arialyy.annotations.Download;
|
||||||
import com.arialyy.annotations.DownloadGroup;
|
import com.arialyy.annotations.DownloadGroup;
|
||||||
import com.arialyy.aria.core.Aria;
|
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.DownloadEntity;
|
||||||
import com.arialyy.aria.core.download.DownloadGroupTask;
|
import com.arialyy.aria.core.download.DownloadGroupTask;
|
||||||
import com.arialyy.aria.core.download.DownloadTarget;
|
import com.arialyy.aria.core.download.DownloadTarget;
|
||||||
@@ -42,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> {
|
||||||
|
|
||||||
@@ -58,10 +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://172.18.104.50:8080/download/_302turn";
|
|
||||||
//"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk";
|
//"http://gdown.baidu.com/data/wisegame/0904344dee4a2d92/QQ_718.apk";
|
||||||
"http://shouji.360tpcdn.com/160824/2c0407dbab4a86c7a84fa7340b9969e7/block.app.wars_30.apk";
|
"http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2";
|
||||||
//"http://172.21.1.99:8080/download/test+ 中文123.zip";
|
|
||||||
@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;
|
||||||
@@ -171,6 +172,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
setBtState(true);
|
setBtState(true);
|
||||||
getBinding().setSpeed("");
|
getBinding().setSpeed("");
|
||||||
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath())));
|
L.d(TAG, "md5Code ==> " + CommonUtil.getFileMD5(new File(task.getDownloadPath())));
|
||||||
|
L.d(TAG, "data ==> " + Aria.download(this).getDownloadEntity(DOWNLOAD_URL));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onNoSupportBreakPoint
|
@Download.onNoSupportBreakPoint
|
||||||
@@ -201,20 +203,10 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
|||||||
switch (view.getId()) {
|
switch (view.getId()) {
|
||||||
case R.id.start:
|
case R.id.start:
|
||||||
startD();
|
startD();
|
||||||
//new Thread(new Runnable() {
|
|
||||||
// @Override public void run() {
|
|
||||||
// startD();
|
|
||||||
// }
|
|
||||||
//}).start();
|
|
||||||
//
|
|
||||||
//new Thread(new Runnable() {
|
|
||||||
// @Override public void run() {
|
|
||||||
// startD();
|
|
||||||
// }
|
|
||||||
//}).start();
|
|
||||||
break;
|
break;
|
||||||
case R.id.stop:
|
case R.id.stop:
|
||||||
Aria.download(this).load(DOWNLOAD_URL).stop();
|
Aria.download(this).load(DOWNLOAD_URL).stop();
|
||||||
|
//Aria.download(this).load(DOWNLOAD_URL).removeRecord();
|
||||||
break;
|
break;
|
||||||
case R.id.cancel:
|
case R.id.cancel:
|
||||||
Aria.download(this).load(DOWNLOAD_URL).cancel();
|
Aria.download(this).load(DOWNLOAD_URL).cancel();
|
||||||
@@ -225,10 +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")
|
||||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/hhhhhhhh.apk")
|
.addHeaders(map)
|
||||||
|
//.setRequestMode(RequestEnum.POST)
|
||||||
|
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/ggsg.apk")
|
||||||
.start();
|
.start();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import com.arialyy.simple.widget.SubStateLinearLayout;
|
|||||||
* Created by Aria.Lao on 2017/7/6.
|
* Created by Aria.Lao on 2017/7/6.
|
||||||
*/
|
*/
|
||||||
public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBinding> {
|
public class FTPDirDownloadActivity extends BaseActivity<ActivityDownloadGroupBinding> {
|
||||||
private static final String dir = "ftp://172.18.104.64:21/upload/测试";
|
private static final String dir = "ftp://192.168.1.2:21/upload/测试";
|
||||||
|
|
||||||
@Bind(R.id.child_list) SubStateLinearLayout mChildList;
|
@Bind(R.id.child_list) SubStateLinearLayout mChildList;
|
||||||
|
|
||||||
|
|||||||
@@ -35,7 +35,7 @@ import com.arialyy.simple.databinding.ActivityFtpUploadBinding;
|
|||||||
*/
|
*/
|
||||||
public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
public class FtpUploadActivity extends BaseActivity<ActivityFtpUploadBinding> {
|
||||||
private final String FILE_PATH = "/mnt/sdcard/Download/me.jpg";
|
private final String FILE_PATH = "/mnt/sdcard/Download/me.jpg";
|
||||||
private final String URL = "ftp://172.18.104.65:21/upload/测试";
|
private final String URL = "ftp://192.168.1.2:21/upload/测试";
|
||||||
|
|
||||||
@Override protected void init(Bundle savedInstanceState) {
|
@Override protected void init(Bundle savedInstanceState) {
|
||||||
setTile("D_FTP 文件上传");
|
setTile("D_FTP 文件上传");
|
||||||
|
|||||||
@@ -272,6 +272,11 @@ class Configuration {
|
|||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setThreadNum(int threadNum){
|
||||||
|
this.threadNum = threadNum;
|
||||||
|
saveKey("threadNum", String.valueOf(threadNum));
|
||||||
|
}
|
||||||
|
|
||||||
public DownloadConfig setIOTimeOut(int iOTimeOut) {
|
public DownloadConfig setIOTimeOut(int iOTimeOut) {
|
||||||
this.iOTimeOut = iOTimeOut;
|
this.iOTimeOut = iOTimeOut;
|
||||||
saveKey("iOTimeOut", iOTimeOut + "");
|
saveKey("iOTimeOut", iOTimeOut + "");
|
||||||
|
|||||||
+1
-1
@@ -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.9'
|
||||||
// publishVersion = '1.0.3' //FTP插件
|
// publishVersion = '1.0.3' //FTP插件
|
||||||
repoName='maven'
|
repoName='maven'
|
||||||
desc = 'android 下载框架'
|
desc = 'android 下载框架'
|
||||||
|
|||||||
Reference in new issue
Block a user