修复普通下载任务、组合任务共享执行队列、缓存池的问题
修复组合任务启动失败时,`DownloadGroupEntity`的状态变为执行中的问题 fix bug https://github.com/AriaLyy/Aria/issues/441
This commit is contained in:
@@ -201,10 +201,12 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_WRAPPER
|
|||||||
* @param state {@link IThreadState#STATE_STOP}..
|
* @param state {@link IThreadState#STATE_STOP}..
|
||||||
* @param bundle 而外数据
|
* @param bundle 而外数据
|
||||||
*/
|
*/
|
||||||
void sendState(int state, @Nullable Bundle bundle) {
|
synchronized void sendState(int state, @Nullable Bundle bundle) {
|
||||||
Message msg = mStateHandler.obtainMessage();
|
Message msg = mStateHandler.obtainMessage();
|
||||||
msg.what = state;
|
msg.what = state;
|
||||||
msg.obj = this;
|
if (state != IThreadState.STATE_UPDATE_PROGRESS) {
|
||||||
|
msg.obj = this;
|
||||||
|
}
|
||||||
|
|
||||||
if ((state == IThreadState.STATE_COMPLETE || state == IThreadState.STATE_FAIL)
|
if ((state == IThreadState.STATE_COMPLETE || state == IThreadState.STATE_FAIL)
|
||||||
&& (mTaskWrapper.getRequestType() == AbsTaskWrapper.M3U8_VOD
|
&& (mTaskWrapper.getRequestType() == AbsTaskWrapper.M3U8_VOD
|
||||||
|
|||||||
@@ -96,12 +96,14 @@ public class ThreadStateManager implements IThreadState {
|
|||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_RUNNING:
|
case STATE_RUNNING:
|
||||||
mProgress += (long) msg.obj;
|
if (msg.obj instanceof Long) {
|
||||||
|
mProgress += (long) msg.obj;
|
||||||
|
}
|
||||||
break;
|
break;
|
||||||
case STATE_UPDATE_PROGRESS:
|
case STATE_UPDATE_PROGRESS:
|
||||||
if (msg.obj == null) {
|
if (msg.obj == null) {
|
||||||
mProgress = updateBlockProgress();
|
mProgress = updateBlockProgress();
|
||||||
} else {
|
} else if (msg.obj instanceof Long) {
|
||||||
mProgress = (long) msg.obj;
|
mProgress = (long) msg.obj;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
|
|||||||
@@ -211,12 +211,19 @@ public abstract class AbsGroupUtil implements IUtil, Runnable {
|
|||||||
closeTimer();
|
closeTimer();
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
onStart();
|
if (onStart()) {
|
||||||
startRunningFlow();
|
startRunningFlow();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void onStart() {
|
/**
|
||||||
|
* 处理启动前的检查:获取组合任务大小
|
||||||
|
*
|
||||||
|
* @return {@code false} 将不再走后续流程,任务介绍
|
||||||
|
*/
|
||||||
|
protected boolean onStart() {
|
||||||
|
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
synchronized void closeTimer() {
|
synchronized void closeTimer() {
|
||||||
|
|||||||
@@ -68,8 +68,7 @@ public class DGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void onStart() {
|
@Override protected boolean onStart() {
|
||||||
super.onStart();
|
|
||||||
if (mState.getCompleteNum() == mState.getSubSize()) {
|
if (mState.getCompleteNum() == mState.getSubSize()) {
|
||||||
mListener.onComplete();
|
mListener.onComplete();
|
||||||
} else {
|
} else {
|
||||||
@@ -84,6 +83,7 @@ public class DGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
} catch (InterruptedException e) {
|
} catch (InterruptedException e) {
|
||||||
e.printStackTrace();
|
e.printStackTrace();
|
||||||
}
|
}
|
||||||
|
return getLenComplete;
|
||||||
} else {
|
} else {
|
||||||
for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) {
|
for (DTaskWrapper wrapper : mGTWrapper.getSubTaskWrapper()) {
|
||||||
if (wrapper.getState() != IEntity.STATE_COMPLETE) {
|
if (wrapper.getState() != IEntity.STATE_COMPLETE) {
|
||||||
@@ -92,6 +92,7 @@ public class DGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -137,6 +138,7 @@ public class DGroupUtil extends AbsGroupUtil implements IUtil {
|
|||||||
*/
|
*/
|
||||||
private void checkGetSizeComplete(int count, int failCount) {
|
private void checkGetSizeComplete(int count, int failCount) {
|
||||||
if (failCount == mGTWrapper.getSubTaskWrapper().size()) {
|
if (failCount == mGTWrapper.getSubTaskWrapper().size()) {
|
||||||
|
mState.isRunning = false;
|
||||||
mListener.onFail(false, new AriaIOException(TAG, "获取子任务长度失败"));
|
mListener.onFail(false, new AriaIOException(TAG, "获取子任务长度失败"));
|
||||||
notifyLock();
|
notifyLock();
|
||||||
return;
|
return;
|
||||||
|
|||||||
@@ -38,8 +38,7 @@ public class FtpDirDownloadUtil extends AbsGroupUtil {
|
|||||||
return FTP_DIR;
|
return FTP_DIR;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override protected void onStart() {
|
@Override protected boolean onStart() {
|
||||||
super.onStart();
|
|
||||||
if (mGTWrapper.getEntity().getFileSize() > 1) {
|
if (mGTWrapper.getEntity().getFileSize() > 1) {
|
||||||
startDownload();
|
startDownload();
|
||||||
} else {
|
} else {
|
||||||
@@ -57,6 +56,7 @@ public class FtpDirDownloadUtil extends AbsGroupUtil {
|
|||||||
});
|
});
|
||||||
new Thread(infoThread).start();
|
new Thread(infoThread).start();
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void startDownload() {
|
private void startDownload() {
|
||||||
|
|||||||
@@ -26,7 +26,8 @@ import com.arialyy.aria.core.manager.TaskWrapperManager;
|
|||||||
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
import com.arialyy.aria.core.manager.ThreadTaskManager;
|
||||||
import com.arialyy.aria.core.queue.pool.BaseCachePool;
|
import com.arialyy.aria.core.queue.pool.BaseCachePool;
|
||||||
import com.arialyy.aria.core.queue.pool.BaseExecutePool;
|
import com.arialyy.aria.core.queue.pool.BaseExecutePool;
|
||||||
import com.arialyy.aria.core.queue.pool.DownloadSharePool;
|
import com.arialyy.aria.core.queue.pool.DGLoadSharePool;
|
||||||
|
import com.arialyy.aria.core.queue.pool.DLoadSharePool;
|
||||||
import com.arialyy.aria.core.queue.pool.UploadSharePool;
|
import com.arialyy.aria.core.queue.pool.UploadSharePool;
|
||||||
import com.arialyy.aria.core.upload.UploadTask;
|
import com.arialyy.aria.core.upload.UploadTask;
|
||||||
import com.arialyy.aria.util.ALog;
|
import com.arialyy.aria.util.ALog;
|
||||||
@@ -47,9 +48,12 @@ public abstract class AbsTaskQueue<TASK extends AbsTask, TASK_WRAPPER extends Ab
|
|||||||
AbsTaskQueue() {
|
AbsTaskQueue() {
|
||||||
switch (getQueueType()) {
|
switch (getQueueType()) {
|
||||||
case TYPE_D_QUEUE:
|
case TYPE_D_QUEUE:
|
||||||
|
mCachePool = DLoadSharePool.getInstance().cachePool;
|
||||||
|
mExecutePool = DLoadSharePool.getInstance().executePool;
|
||||||
|
break;
|
||||||
case TYPE_DG_QUEUE:
|
case TYPE_DG_QUEUE:
|
||||||
mCachePool = DownloadSharePool.getInstance().cachePool;
|
mCachePool = DGLoadSharePool.getInstance().cachePool;
|
||||||
mExecutePool = DownloadSharePool.getInstance().executePool;
|
mExecutePool = DGLoadSharePool.getInstance().executePool;
|
||||||
break;
|
break;
|
||||||
case TYPE_U_QUEUE:
|
case TYPE_U_QUEUE:
|
||||||
mCachePool = UploadSharePool.getInstance().cachePool;
|
mCachePool = UploadSharePool.getInstance().cachePool;
|
||||||
|
|||||||
@@ -0,0 +1,31 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.arialyy.aria.core.queue.pool;
|
||||||
|
|
||||||
|
import com.arialyy.aria.core.AriaManager;
|
||||||
|
import com.arialyy.aria.core.inf.AbsTask;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by AriaL on 2017/6/29.
|
||||||
|
* 单个下载任务的执行池
|
||||||
|
*/
|
||||||
|
class DGLoadExecutePool<TASK extends AbsTask> extends DLoadExecutePool<TASK> {
|
||||||
|
private final String TAG = "DGLoadExecutePool";
|
||||||
|
|
||||||
|
@Override protected int getMaxSize() {
|
||||||
|
return AriaManager.getInstance(AriaManager.APP).getDGroupConfig().getMaxTaskNum();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -19,21 +19,21 @@ package com.arialyy.aria.core.queue.pool;
|
|||||||
* Created by Aria.Lao on 2017/7/17.
|
* Created by Aria.Lao on 2017/7/17.
|
||||||
* 下载任务池,该池子为简单任务和任务组共用
|
* 下载任务池,该池子为简单任务和任务组共用
|
||||||
*/
|
*/
|
||||||
public class DownloadSharePool {
|
public class DGLoadSharePool {
|
||||||
private static volatile DownloadSharePool INSTANCE;
|
private static volatile DGLoadSharePool INSTANCE;
|
||||||
|
|
||||||
public DownloadExecutePool executePool;
|
public DGLoadExecutePool executePool;
|
||||||
public BaseCachePool cachePool;
|
public BaseCachePool cachePool;
|
||||||
|
|
||||||
private DownloadSharePool() {
|
private DGLoadSharePool() {
|
||||||
executePool = new DownloadExecutePool<>();
|
executePool = new DGLoadExecutePool<>();
|
||||||
cachePool = new BaseCachePool<>();
|
cachePool = new BaseCachePool<>();
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DownloadSharePool getInstance() {
|
public static DGLoadSharePool getInstance() {
|
||||||
if (INSTANCE == null) {
|
if (INSTANCE == null) {
|
||||||
synchronized (DownloadSharePool.class) {
|
synchronized (DGLoadSharePool.class) {
|
||||||
INSTANCE = new DownloadSharePool();
|
INSTANCE = new DGLoadSharePool();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return INSTANCE;
|
return INSTANCE;
|
||||||
@@ -26,7 +26,7 @@ import java.util.concurrent.TimeUnit;
|
|||||||
* Created by AriaL on 2017/6/29.
|
* Created by AriaL on 2017/6/29.
|
||||||
* 单个下载任务的执行池
|
* 单个下载任务的执行池
|
||||||
*/
|
*/
|
||||||
class DownloadExecutePool<TASK extends AbsTask> extends BaseExecutePool<TASK> {
|
class DLoadExecutePool<TASK extends AbsTask> extends BaseExecutePool<TASK> {
|
||||||
private final String TAG = "DownloadExecutePool";
|
private final String TAG = "DownloadExecutePool";
|
||||||
|
|
||||||
@Override protected int getMaxSize() {
|
@Override protected int getMaxSize() {
|
||||||
@@ -34,7 +34,7 @@ class DownloadExecutePool<TASK extends AbsTask> extends BaseExecutePool<TASK> {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override public boolean putTask(TASK task) {
|
@Override public boolean putTask(TASK task) {
|
||||||
synchronized (DownloadExecutePool.class) {
|
synchronized (DLoadExecutePool.class) {
|
||||||
if (task == null) {
|
if (task == null) {
|
||||||
ALog.e(TAG, "任务不能为空!!");
|
ALog.e(TAG, "任务不能为空!!");
|
||||||
return false;
|
return false;
|
||||||
@@ -0,0 +1,41 @@
|
|||||||
|
/*
|
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
*
|
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
||||||
|
* you may not use this file except in compliance with the License.
|
||||||
|
* You may obtain a copy of the License at
|
||||||
|
*
|
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
*
|
||||||
|
* Unless required by applicable law or agreed to in writing, software
|
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
||||||
|
* See the License for the specific language governing permissions and
|
||||||
|
* limitations under the License.
|
||||||
|
*/
|
||||||
|
package com.arialyy.aria.core.queue.pool;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Created by Aria.Lao on 2017/7/17.
|
||||||
|
* 下载任务池,该池子为简单任务和任务组共用
|
||||||
|
*/
|
||||||
|
public class DLoadSharePool {
|
||||||
|
private static volatile DLoadSharePool INSTANCE;
|
||||||
|
|
||||||
|
public DLoadExecutePool executePool;
|
||||||
|
public BaseCachePool cachePool;
|
||||||
|
|
||||||
|
private DLoadSharePool() {
|
||||||
|
executePool = new DLoadExecutePool<>();
|
||||||
|
cachePool = new BaseCachePool<>();
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DLoadSharePool getInstance() {
|
||||||
|
if (INSTANCE == null) {
|
||||||
|
synchronized (DLoadSharePool.class) {
|
||||||
|
INSTANCE = new DLoadSharePool();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return INSTANCE;
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -106,7 +106,9 @@ class DelegateCommon extends AbsDelegate {
|
|||||||
*/
|
*/
|
||||||
boolean checkDataExist(SQLiteDatabase db, Class clazz, String... expression) {
|
boolean checkDataExist(SQLiteDatabase db, Class clazz, String... expression) {
|
||||||
db = checkDb(db);
|
db = checkDb(db);
|
||||||
CheckUtil.checkSqlExpression(expression);
|
if (!CheckUtil.checkSqlExpression(expression)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
String sql = String.format("SELECT rowid, * FROM %s WHERE %s ", CommonUtil.getClassName(clazz),
|
String sql = String.format("SELECT rowid, * FROM %s WHERE %s ", CommonUtil.getClassName(clazz),
|
||||||
expression[0]);
|
expression[0]);
|
||||||
sql = sql.replace("?", "%s");
|
sql = sql.replace("?", "%s");
|
||||||
|
|||||||
@@ -15,7 +15,6 @@
|
|||||||
*/
|
*/
|
||||||
package com.arialyy.aria.orm;
|
package com.arialyy.aria.orm;
|
||||||
|
|
||||||
import android.annotation.SuppressLint;
|
|
||||||
import android.database.Cursor;
|
import android.database.Cursor;
|
||||||
import android.database.sqlite.SQLiteDatabase;
|
import android.database.sqlite.SQLiteDatabase;
|
||||||
import android.text.TextUtils;
|
import android.text.TextUtils;
|
||||||
@@ -30,10 +29,8 @@ import java.lang.reflect.Field;
|
|||||||
import java.net.URLDecoder;
|
import java.net.URLDecoder;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Date;
|
import java.util.Date;
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Created by laoyuyu on 2018/3/22.
|
* Created by laoyuyu on 2018/3/22.
|
||||||
@@ -201,7 +198,9 @@ class DelegateFind extends AbsDelegate {
|
|||||||
.append(cTableName.concat(".").concat(m.entityColumn()));
|
.append(cTableName.concat(".").concat(m.entityColumn()));
|
||||||
String sql;
|
String sql;
|
||||||
if (expression != null && expression.length > 0) {
|
if (expression != null && expression.length > 0) {
|
||||||
CheckUtil.checkSqlExpression(expression);
|
if (!CheckUtil.checkSqlExpression(expression)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
sb.append(" WHERE ").append(expression[0]).append(" ");
|
sb.append(" WHERE ").append(expression[0]).append(" ");
|
||||||
sql = sb.toString();
|
sql = sb.toString();
|
||||||
sql = sql.replace("?", "%s");
|
sql = sql.replace("?", "%s");
|
||||||
@@ -321,7 +320,9 @@ class DelegateFind extends AbsDelegate {
|
|||||||
*/
|
*/
|
||||||
<T extends DbEntity> List<T> findData(SQLiteDatabase db, Class<T> clazz, String... expression) {
|
<T extends DbEntity> List<T> findData(SQLiteDatabase db, Class<T> clazz, String... expression) {
|
||||||
db = checkDb(db);
|
db = checkDb(db);
|
||||||
CheckUtil.checkSqlExpression(expression);
|
if (!CheckUtil.checkSqlExpression(expression)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
String sql = String.format("SELECT rowid, * FROM %s WHERE %s", CommonUtil.getClassName(clazz),
|
String sql = String.format("SELECT rowid, * FROM %s WHERE %s", CommonUtil.getClassName(clazz),
|
||||||
expression[0]);
|
expression[0]);
|
||||||
String[] params = new String[expression.length - 1];
|
String[] params = new String[expression.length - 1];
|
||||||
@@ -339,7 +340,9 @@ class DelegateFind extends AbsDelegate {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
db = checkDb(db);
|
db = checkDb(db);
|
||||||
CheckUtil.checkSqlExpression(expression);
|
if (!CheckUtil.checkSqlExpression(expression)) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
String sql = String.format("SELECT rowid, * FROM %s WHERE %s LIMIT %s,%s",
|
String sql = String.format("SELECT rowid, * FROM %s WHERE %s LIMIT %s,%s",
|
||||||
CommonUtil.getClassName(clazz),
|
CommonUtil.getClassName(clazz),
|
||||||
expression[0], (page - 1) * num, num);
|
expression[0], (page - 1) * num, num);
|
||||||
|
|||||||
@@ -34,13 +34,15 @@ class DelegateUpdate extends AbsDelegate {
|
|||||||
private DelegateUpdate() {
|
private DelegateUpdate() {
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* 删除某条数据
|
* 删除某条数据
|
||||||
*/
|
*/
|
||||||
synchronized <T extends DbEntity> void delData(SQLiteDatabase db, Class<T> clazz,
|
synchronized <T extends DbEntity> void delData(SQLiteDatabase db, Class<T> clazz,
|
||||||
String... expression) {
|
String... expression) {
|
||||||
db = checkDb(db);
|
db = checkDb(db);
|
||||||
CheckUtil.checkSqlExpression(expression);
|
if (!CheckUtil.checkSqlExpression(expression)) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
String sql = "DELETE FROM " + CommonUtil.getClassName(clazz) + " WHERE " + expression[0] + " ";
|
String sql = "DELETE FROM " + CommonUtil.getClassName(clazz) + " WHERE " + expression[0] + " ";
|
||||||
sql = sql.replace("?", "%s");
|
sql = sql.replace("?", "%s");
|
||||||
@@ -60,7 +62,7 @@ class DelegateUpdate extends AbsDelegate {
|
|||||||
ContentValues values = createValues(dbEntity);
|
ContentValues values = createValues(dbEntity);
|
||||||
if (values != null) {
|
if (values != null) {
|
||||||
db.update(CommonUtil.getClassName(dbEntity), values, "rowid=?",
|
db.update(CommonUtil.getClassName(dbEntity), values, "rowid=?",
|
||||||
new String[] {String.valueOf(dbEntity.rowID)});
|
new String[] { String.valueOf(dbEntity.rowID) });
|
||||||
} else {
|
} else {
|
||||||
ALog.e(TAG, "更新记录失败,记录没有属性字段");
|
ALog.e(TAG, "更新记录失败,记录没有属性字段");
|
||||||
}
|
}
|
||||||
@@ -69,7 +71,7 @@ class DelegateUpdate extends AbsDelegate {
|
|||||||
/**
|
/**
|
||||||
* 更新多条记录
|
* 更新多条记录
|
||||||
*/
|
*/
|
||||||
synchronized <T extends DbEntity> void updateManyData(SQLiteDatabase db, List<T> dbEntities) {
|
synchronized <T extends DbEntity> void updateManyData(SQLiteDatabase db, List<T> dbEntities) {
|
||||||
db = checkDb(db);
|
db = checkDb(db);
|
||||||
db.beginTransaction();
|
db.beginTransaction();
|
||||||
try {
|
try {
|
||||||
@@ -84,7 +86,7 @@ class DelegateUpdate extends AbsDelegate {
|
|||||||
if (value == null) {
|
if (value == null) {
|
||||||
ALog.e(TAG, "更新记录失败,记录没有属性字段");
|
ALog.e(TAG, "更新记录失败,记录没有属性字段");
|
||||||
} else {
|
} else {
|
||||||
db.update(table, value, "rowid=?", new String[] {String.valueOf(entity.rowID)});
|
db.update(table, value, "rowid=?", new String[] { String.valueOf(entity.rowID) });
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
db.setTransactionSuccessful();
|
db.setTransactionSuccessful();
|
||||||
|
|||||||
@@ -24,6 +24,7 @@ import com.arialyy.aria.core.upload.UTaskWrapper;
|
|||||||
import com.arialyy.aria.core.upload.UploadEntity;
|
import com.arialyy.aria.core.upload.UploadEntity;
|
||||||
import com.arialyy.aria.exception.ParamException;
|
import com.arialyy.aria.exception.ParamException;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
|
import java.util.Arrays;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.regex.Matcher;
|
import java.util.regex.Matcher;
|
||||||
import java.util.regex.Pattern;
|
import java.util.regex.Pattern;
|
||||||
@@ -68,17 +69,22 @@ public class CheckUtil {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* 检查sql的expression是否合法
|
* 检查sql的expression是否合法
|
||||||
|
*
|
||||||
|
* @return false 不合法
|
||||||
*/
|
*/
|
||||||
public static void checkSqlExpression(String... expression) {
|
public static boolean checkSqlExpression(String... expression) {
|
||||||
if (expression.length == 0) {
|
if (expression.length == 0) {
|
||||||
throw new IllegalArgumentException("sql语句表达式不能为null");
|
ALog.e(TAG, "sql语句表达式不能为null");
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (expression.length == 1) {
|
if (expression.length == 1) {
|
||||||
throw new IllegalArgumentException("表达式需要写入参数");
|
ALog.e(TAG, String.format("表达式需要写入参数,参数信息:%s", Arrays.toString(expression)));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
String where = expression[0];
|
String where = expression[0];
|
||||||
if (!where.contains("?")) {
|
if (!where.contains("?")) {
|
||||||
throw new IllegalArgumentException("请在where语句的'='后编写?");
|
ALog.e(TAG, String.format("请在where语句的'='后编写?,参数信息:%s", Arrays.toString(expression)));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
Pattern pattern = Pattern.compile("\\?");
|
Pattern pattern = Pattern.compile("\\?");
|
||||||
Matcher matcher = pattern.matcher(where);
|
Matcher matcher = pattern.matcher(where);
|
||||||
@@ -87,11 +93,14 @@ public class CheckUtil {
|
|||||||
count++;
|
count++;
|
||||||
}
|
}
|
||||||
if (count < expression.length - 1) {
|
if (count < expression.length - 1) {
|
||||||
throw new IllegalArgumentException("条件语句的?个数不能小于参数个数");
|
ALog.e(TAG, String.format("条件语句的?个数不能小于参数个数,参数信息:%s", Arrays.toString(expression)));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
if (count > expression.length - 1) {
|
if (count > expression.length - 1) {
|
||||||
throw new IllegalArgumentException("条件语句的?个数不能大于参数个数");
|
ALog.e(TAG, String.format("条件语句的?个数不能大于参数个数, 参数信息:%s", Arrays.toString(expression)));
|
||||||
|
return false;
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -113,7 +113,7 @@
|
|||||||
<dGroup>
|
<dGroup>
|
||||||
|
|
||||||
<!--组合任务下载队列最大任务数, 默认为2-->
|
<!--组合任务下载队列最大任务数, 默认为2-->
|
||||||
<maxTaskNum value="1"/>
|
<maxTaskNum value="2"/>
|
||||||
|
|
||||||
<!--设置下载失败,重试次数,默认为10-->
|
<!--设置下载失败,重试次数,默认为10-->
|
||||||
<reTryNum value="1"/>
|
<reTryNum value="1"/>
|
||||||
@@ -131,7 +131,7 @@
|
|||||||
<!-- =============================以下为子任务的配置====================================-->
|
<!-- =============================以下为子任务的配置====================================-->
|
||||||
|
|
||||||
<!--能同时下载的子任务最大任务数,默认3-->
|
<!--能同时下载的子任务最大任务数,默认3-->
|
||||||
<subMaxTaskNum value="1"/>
|
<subMaxTaskNum value="5"/>
|
||||||
|
|
||||||
<!--子任务下载失败时的重试次数,默认为5-->
|
<!--子任务下载失败时的重试次数,默认为5-->
|
||||||
<subReTryNum value="5"/>
|
<subReTryNum value="5"/>
|
||||||
|
|||||||
@@ -76,7 +76,7 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
|
|||||||
Log.d(TAG, task.getTaskName() + ", " + task.getState());
|
Log.d(TAG, task.getTaskName() + ", " + task.getState());
|
||||||
}
|
}
|
||||||
|
|
||||||
@Download.onWait void onWait(DownloadTask task){
|
@Download.onWait void onWait(DownloadTask task) {
|
||||||
mAdapter.updateState(task.getEntity());
|
mAdapter.updateState(task.getEntity());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -139,8 +139,10 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
|
|||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskFail void groupTaskFail(DownloadGroupTask task) {
|
@DownloadGroup.onTaskFail void groupTaskFail(DownloadGroupTask task) {
|
||||||
ALog.d(TAG, String.format("group【%s】fail", task.getTaskName()));
|
if (task != null) {
|
||||||
mAdapter.updateState(task.getEntity());
|
ALog.d(TAG, String.format("group【%s】fail", task.getTaskName()));
|
||||||
|
mAdapter.updateState(task.getEntity());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@DownloadGroup.onTaskComplete void groupTaskComplete(DownloadGroupTask task) {
|
@DownloadGroup.onTaskComplete void groupTaskComplete(DownloadGroupTask task) {
|
||||||
|
|||||||
@@ -106,16 +106,13 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="group_urls">
|
<string-array name="group_urls">
|
||||||
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a65d84b914e6a6fef697637578b6db2eb1056d50b09cf1dcf289d4045df7ef95746e498e3d6a848ab84c89b77aa60194e2c48e5a7cb748265.apk</item>-->
|
<item>https://downs.muzhiwan.com/2019/06/19/com.and.games505.TerrariaPaid5d0a074e451c0.gpk</item>
|
||||||
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a52034c72752e8475414630ebc69318b84ef584115ebf5eaaab945ae07b7fe3596afc72a7940ff328d4a9553f6ae92d6c09ba4bfb533137f6.apk</item>-->
|
<item>https://downs.muzhiwan.com/2017/03/28/com.xyzstudio_58da07426e959.apk</item>
|
||||||
<!--<item>https://res5.d.cn/5a6a3384c1b2be1a426f06bfc69034d69c44ae1a01da180cab8e59bd1a5e1a784bac46ba0c64579d14f0e80a4ce4f068af89b0369a393456f4f449a8829cad5c.apk</item>-->
|
|
||||||
<item>http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk</item>
|
|
||||||
<!--<item>http://static.ilongyuan.cn/rayark/RayarkFZ_2.0.7.apk</item>-->
|
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="group_urls_1">
|
<string-array name="group_urls_1">
|
||||||
<item>http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk</item>
|
<item>http://hzdown.muzhiwan.com/2017/05/08/nl.noio.kingdom_59104935e56f0.apk</item>
|
||||||
<item>https://atom-installer.github.com/v1.13.0/AtomSetup.exe1</item>
|
<!--<item>https://atom-installer.github.com/v1.13.0/AtomSetup.exe1</item>-->
|
||||||
<item>http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk</item>
|
<item>http://hzdown.muzhiwan.com/2017/09/05/com.mir.iphone.empire83jie.mzw_59ae6d5a3638d.apk</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
@@ -125,8 +122,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="group_urls_3">
|
<string-array name="group_urls_3">
|
||||||
<item>http://apk500.bce.baidu-mgame.com/game/883000/883227/20170828102306_oem_5502845.apk?r=1</item>
|
<item>https://downs.muzhiwan.com/2019/07/23/com.amazid.me_5d36bade614d9.apk</item>
|
||||||
<item>http://static.gaoshouyou.com/d/92/12/5592a647b8126755647abbe8074fde39.apk</item>
|
<item>https://downs.muzhiwan.com/2019/07/30/com.counter.terrorist.attack.fps.sniper.fight_5d3fe8f0a7edf.apk</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="group_url4">
|
<string-array name="group_url4">
|
||||||
@@ -135,8 +132,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="group_names">
|
<string-array name="group_names">
|
||||||
<item>王者荣耀.apk</item>
|
<item>泰拉瑞亚.apk</item>
|
||||||
<item>战斗吧剑灵.apk</item>
|
<item>疯狂屁股.apk</item>
|
||||||
<!--<item>天魔幻想.apk</item>-->
|
<!--<item>天魔幻想.apk</item>-->
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
@@ -151,8 +148,8 @@
|
|||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
<string-array name="group_names_3">
|
<string-array name="group_names_3">
|
||||||
<item>部落冲突.apk</item>
|
<item>神奇的绳索英雄.apk</item>
|
||||||
<item>城堡争霸.apk</item>
|
<item>自由火力反击.apk</item>
|
||||||
</string-array>
|
</string-array>
|
||||||
|
|
||||||
</resources>
|
</resources>
|
||||||
|
|||||||
@@ -43,7 +43,7 @@ task clean(type: Delete) {
|
|||||||
ext {
|
ext {
|
||||||
userOrg = 'arialyy'
|
userOrg = 'arialyy'
|
||||||
groupId = 'com.arialyy.aria'
|
groupId = 'com.arialyy.aria'
|
||||||
publishVersion = '3.6.6_beta_1'
|
publishVersion = '3.6.6_beta_3'
|
||||||
// publishVersion = '1.0.4' //FTP插件
|
// publishVersion = '1.0.4' //FTP插件
|
||||||
repoName='maven'
|
repoName='maven'
|
||||||
desc = 'android 下载框架'
|
desc = 'android 下载框架'
|
||||||
|
|||||||
Reference in New Issue
Block a user