Merge branch 'v_3.0'
This commit is contained in:
@@ -86,10 +86,29 @@ class ConfigHelper extends DefaultHandler {
|
||||
case "queueMod":
|
||||
loadQueueMod(value);
|
||||
break;
|
||||
case "updateInterval":
|
||||
loadUpdateInterval(value);
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private void loadUpdateInterval(String value) {
|
||||
long temp = 1000;
|
||||
if (!TextUtils.isEmpty(value)) {
|
||||
temp = Long.parseLong(value);
|
||||
if (temp <= 0) {
|
||||
temp = 1000;
|
||||
}
|
||||
}
|
||||
if (isDownloadConfig) {
|
||||
mDownloadConfig.updateInterval = temp;
|
||||
}
|
||||
if (isUploadConfig) {
|
||||
mUploadConfig.updateInterval = temp;
|
||||
}
|
||||
}
|
||||
|
||||
private void loadQueueMod(String value) {
|
||||
String mod = "now";
|
||||
if (!TextUtils.isEmpty(value) && (value.equalsIgnoreCase("now") || value.equalsIgnoreCase(
|
||||
|
||||
@@ -40,6 +40,9 @@ import java.util.concurrent.Executors;
|
||||
*/
|
||||
public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>>
|
||||
implements Runnable, IUtil {
|
||||
public static final String STATE = "_state_";
|
||||
public static final String RECORD = "_record_";
|
||||
|
||||
private final String TAG = "AbsFileer";
|
||||
protected IEventListener mListener;
|
||||
protected TASK_ENTITY mTaskEntity;
|
||||
@@ -63,6 +66,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
*/
|
||||
private static final long SUB_LEN = 1024 * 1024;
|
||||
private Timer mTimer;
|
||||
private long mUpdateInterval = 1000;
|
||||
|
||||
protected AbsFileer(IEventListener listener, TASK_ENTITY taskEntity) {
|
||||
mListener = listener;
|
||||
@@ -111,7 +115,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
mConstance.THREAD_NUM = mTotalThreadNum;
|
||||
handleNoSupportBP();
|
||||
} else {
|
||||
mTotalThreadNum = isNewTask ? (getNewTaskThreadNum()) : mStartThreadNum + mCompleteThreadNum;
|
||||
mTotalThreadNum = isNewTask ? (getNewTaskThreadNum()) : mStartThreadNum;
|
||||
mConstance.THREAD_NUM = mTotalThreadNum;
|
||||
handleBreakpoint();
|
||||
}
|
||||
@@ -145,7 +149,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
mListener.onProgress(mConstance.CURRENT_LOCATION);
|
||||
}
|
||||
}
|
||||
}, 0, 1000);
|
||||
}, 0, mUpdateInterval);
|
||||
}
|
||||
|
||||
protected void closeTimer() {
|
||||
@@ -156,6 +160,20 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置定时器更新间隔
|
||||
*
|
||||
* @param interval 单位毫秒,不能小于0
|
||||
*/
|
||||
protected long setUpdateInterval(long interval) {
|
||||
if (interval < 0) {
|
||||
ALog.w(TAG, "更新间隔不能小于0,默认为1000毫秒");
|
||||
return 1000;
|
||||
}
|
||||
mUpdateInterval = interval;
|
||||
return interval;
|
||||
}
|
||||
|
||||
@Override public long getFileSize() {
|
||||
return mEntity.getFileSize();
|
||||
}
|
||||
@@ -249,10 +267,14 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
int num = 0;
|
||||
for (Object key : keys) {
|
||||
String str = String.valueOf(key);
|
||||
if (str.contains("_record_")) {
|
||||
Object state = pro.getProperty(str);
|
||||
if (str.contains(RECORD)) {
|
||||
num++;
|
||||
} else if (str.contains("_state_")) {
|
||||
mCompleteThreadNum++;
|
||||
} else if (state != null && str.contains(STATE) && Integer.parseInt(state + "") == 1) {
|
||||
int i = Integer.parseInt(str.substring(str.length() - 1, str.length()));
|
||||
if (pro.getProperty(mTempFile.getName() + RECORD + i) != null) {
|
||||
mCompleteThreadNum++;
|
||||
}
|
||||
}
|
||||
}
|
||||
if (num == 0) {
|
||||
@@ -260,8 +282,8 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
}
|
||||
mStartThreadNum = num;
|
||||
for (int i = 0; i < mStartThreadNum; i++) {
|
||||
if (pro.getProperty(mTempFile.getName() + "_record_" + i) == null) {
|
||||
Object state = pro.getProperty(mTempFile.getName() + "_state_" + i);
|
||||
if (pro.getProperty(mTempFile.getName() + RECORD + i) == null) {
|
||||
Object state = pro.getProperty(mTempFile.getName() + STATE + i);
|
||||
if (state != null && Integer.parseInt(state + "") == 1) {
|
||||
continue;
|
||||
}
|
||||
@@ -332,17 +354,18 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
|
||||
}
|
||||
for (int i = 0; i < mTotalThreadNum; i++) {
|
||||
long startL = i * blockSize, endL = (i + 1) * blockSize;
|
||||
Object state = pro.getProperty(mTempFile.getName() + "_state_" + i);
|
||||
if (state != null && Integer.parseInt(state + "") == 1) { //该线程已经完成
|
||||
Object state = pro.getProperty(mTempFile.getName() + STATE + i);
|
||||
Object record = pro.getProperty(mTempFile.getName() + RECORD + i);
|
||||
if (state != null && Integer.parseInt(state + "") == 1 && record != null) { //该线程已经完成
|
||||
if (resumeRecordLocation(i, startL, endL)) return;
|
||||
continue;
|
||||
}
|
||||
//分配下载位置
|
||||
Object record = pro.getProperty(mTempFile.getName() + "_record_" + i);
|
||||
|
||||
//如果有记录,则恢复下载
|
||||
if (!isNewTask && record != null && Long.parseLong(record + "") >= 0) {
|
||||
Long r = Long.parseLong(record + "");
|
||||
if (r > startL) {
|
||||
//记录的位置需要在线程区间中
|
||||
if (startL < r && r < (i == (mTotalThreadNum - 1) ? fileLength : endL)) {
|
||||
mConstance.CURRENT_LOCATION += r - startL;
|
||||
startL = r;
|
||||
}
|
||||
|
||||
@@ -263,10 +263,10 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
|
||||
synchronized (AriaManager.LOCK) {
|
||||
String key = null, value = null;
|
||||
if (record >= mConfig.END_LOCATION || isComplete) {
|
||||
key = mConfig.TEMP_FILE.getName() + "_state_" + mConfig.THREAD_ID;
|
||||
key = mConfig.TEMP_FILE.getName() + AbsFileer.STATE + mConfig.THREAD_ID;
|
||||
value = "1";
|
||||
} else if (0 < record && record < mConfig.END_LOCATION) {
|
||||
key = mConfig.TEMP_FILE.getName() + "_record_" + mConfig.THREAD_ID;
|
||||
key = mConfig.TEMP_FILE.getName() + AbsFileer.RECORD + mConfig.THREAD_ID;
|
||||
value = String.valueOf(record);
|
||||
}
|
||||
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {
|
||||
|
||||
@@ -63,7 +63,7 @@ public class StateConstance {
|
||||
* 所有子线程是否都已经完成下载
|
||||
*/
|
||||
public boolean isComplete() {
|
||||
return COMPLETE_THREAD_NUM == THREAD_NUM;
|
||||
return COMPLETE_THREAD_NUM >= THREAD_NUM;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -41,6 +41,7 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
private boolean isConvertSpeed = false;
|
||||
boolean isWait = false;
|
||||
private long mLastSaveTime;
|
||||
private long mUpdateInterval;
|
||||
|
||||
BaseDListener(TASK task, Handler outHandler) {
|
||||
this.outHandler = new WeakReference<>(outHandler);
|
||||
@@ -51,6 +52,7 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
isConvertSpeed = manager.getDownloadConfig().isConvertSpeed();
|
||||
mLastLen = mEntity.getCurrentProgress();
|
||||
mLastSaveTime = System.currentTimeMillis();
|
||||
mUpdateInterval = manager.getDownloadConfig().getUpdateInterval();
|
||||
}
|
||||
|
||||
@Override public void onPre() {
|
||||
@@ -123,6 +125,9 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
}
|
||||
|
||||
private void handleSpeed(long speed) {
|
||||
if (mUpdateInterval != 1000) {
|
||||
speed = speed * 1000 / mUpdateInterval;
|
||||
}
|
||||
if (isConvertSpeed) {
|
||||
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
|
||||
}
|
||||
|
||||
@@ -99,6 +99,7 @@ public abstract class AbsGroupUtil implements IUtil {
|
||||
int mInitFailNum = 0;
|
||||
//任务组大小
|
||||
int mGroupSize = 0;
|
||||
long mUpdateInterval = 1000;
|
||||
|
||||
AbsGroupUtil(IDownloadGroupListener listener, DownloadGroupTaskEntity groupEntity) {
|
||||
mListener = listener;
|
||||
@@ -131,6 +132,8 @@ public abstract class AbsGroupUtil implements IUtil {
|
||||
}
|
||||
}
|
||||
updateFileSize();
|
||||
mUpdateInterval =
|
||||
AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getUpdateInterval();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -371,7 +374,7 @@ public abstract class AbsGroupUtil implements IUtil {
|
||||
mListener.onProgress(mCurrentLocation);
|
||||
}
|
||||
}
|
||||
}, 0, 1000);
|
||||
}, 0, mUpdateInterval);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.download.downloader;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.common.AbsFileer;
|
||||
import com.arialyy.aria.core.common.AbsThreadTask;
|
||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||
@@ -39,6 +40,8 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
|
||||
|
||||
Downloader(IDownloadListener listener, DownloadTaskEntity taskEntity) {
|
||||
super(listener, taskEntity);
|
||||
setUpdateInterval(
|
||||
AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getUpdateInterval());
|
||||
}
|
||||
|
||||
@Override protected void checkTask() {
|
||||
|
||||
@@ -36,10 +36,6 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
|
||||
* HTTP任务组下载
|
||||
*/
|
||||
public static final int DG_HTTP = 0x12;
|
||||
/**
|
||||
* HTTP单文件上传
|
||||
*/
|
||||
public static final int U_HTTP = 0xA1;
|
||||
|
||||
/**
|
||||
* FTP单文件下载
|
||||
@@ -49,6 +45,11 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
|
||||
* FTP文件夹下载,为避免登录过多,子任务由单线程进行处理
|
||||
*/
|
||||
public static final int D_FTP_DIR = 0x14;
|
||||
|
||||
/**
|
||||
* HTTP单文件上传
|
||||
*/
|
||||
public static final int U_HTTP = 0xA1;
|
||||
/**
|
||||
* FTP单文件上传
|
||||
*/
|
||||
|
||||
@@ -41,6 +41,7 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
private boolean isConvertSpeed = false;
|
||||
boolean isWait = false;
|
||||
private long mLastSaveTime;
|
||||
private long mUpdateInterval;
|
||||
|
||||
BaseUListener(TASK task, Handler outHandler) {
|
||||
this.outHandler = new WeakReference<>(outHandler);
|
||||
@@ -51,6 +52,7 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
isConvertSpeed = manager.getDownloadConfig().isConvertSpeed();
|
||||
mLastLen = mEntity.getCurrentProgress();
|
||||
mLastSaveTime = System.currentTimeMillis();
|
||||
mUpdateInterval = manager.getUploadConfig().getUpdateInterval();
|
||||
}
|
||||
|
||||
@Override public void onPre() {
|
||||
@@ -111,6 +113,9 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
|
||||
}
|
||||
|
||||
private void handleSpeed(long speed) {
|
||||
if (mUpdateInterval != 1000) {
|
||||
speed = speed * 1000 / mUpdateInterval;
|
||||
}
|
||||
if (isConvertSpeed) {
|
||||
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
|
||||
}
|
||||
|
||||
@@ -90,7 +90,7 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
|
||||
}
|
||||
uploadFile(writer, mTaskEntity.attachment, uploadFile);
|
||||
finish(writer);
|
||||
} catch (IOException e) {
|
||||
} catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
fail();
|
||||
}
|
||||
|
||||
@@ -17,6 +17,7 @@ package com.arialyy.aria.core.upload.uploader;
|
||||
|
||||
import com.arialyy.aria.core.common.IUtil;
|
||||
import com.arialyy.aria.core.common.OnFileInfoCallback;
|
||||
import com.arialyy.aria.core.inf.AbsTaskEntity;
|
||||
import com.arialyy.aria.core.inf.IUploadListener;
|
||||
import com.arialyy.aria.core.upload.UploadEntity;
|
||||
import com.arialyy.aria.core.upload.UploadTaskEntity;
|
||||
@@ -47,19 +48,26 @@ public class SimpleUploadUtil implements IUtil, Runnable {
|
||||
|
||||
@Override public void run() {
|
||||
mListener.onPre();
|
||||
new FtpFileInfoThread(mTaskEntity, new OnFileInfoCallback() {
|
||||
@Override public void onComplete(String url, int code) {
|
||||
if (code == FtpFileInfoThread.CODE_COMPLETE) {
|
||||
mListener.onComplete();
|
||||
} else {
|
||||
mUploader.start();
|
||||
}
|
||||
}
|
||||
switch (mTaskEntity.requestType) {
|
||||
case AbsTaskEntity.U_FTP:
|
||||
new FtpFileInfoThread(mTaskEntity, new OnFileInfoCallback() {
|
||||
@Override public void onComplete(String url, int code) {
|
||||
if (code == FtpFileInfoThread.CODE_COMPLETE) {
|
||||
mListener.onComplete();
|
||||
} else {
|
||||
mUploader.start();
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||
mListener.onFail(needRetry);
|
||||
}
|
||||
}).start();
|
||||
@Override public void onFail(String url, String errorMsg, boolean needRetry) {
|
||||
mListener.onFail(needRetry);
|
||||
}
|
||||
}).start();
|
||||
break;
|
||||
case AbsTaskEntity.U_HTTP:
|
||||
mUploader.start();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
@Override public long getFileSize() {
|
||||
|
||||
@@ -15,6 +15,7 @@
|
||||
*/
|
||||
package com.arialyy.aria.core.upload.uploader;
|
||||
|
||||
import com.arialyy.aria.core.AriaManager;
|
||||
import com.arialyy.aria.core.common.AbsFileer;
|
||||
import com.arialyy.aria.core.common.AbsThreadTask;
|
||||
import com.arialyy.aria.core.common.SubThreadConfig;
|
||||
@@ -35,6 +36,8 @@ class Uploader extends AbsFileer<UploadEntity, UploadTaskEntity> {
|
||||
Uploader(IUploadListener listener, UploadTaskEntity taskEntity) {
|
||||
super(listener, taskEntity);
|
||||
mTempFile = new File(mEntity.getFilePath());
|
||||
setUpdateInterval(
|
||||
AriaManager.getInstance(AriaManager.APP).getUploadConfig().getUpdateInterval());
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -200,7 +200,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
sql = sql.replace("?", "%s");
|
||||
Object[] params = new String[expression.length - 1];
|
||||
for (int i = 0, len = params.length; i < len; i++) {
|
||||
params[i] = "'" + expression[i + 1] + "'";
|
||||
params[i] = "\"" + expression[i + 1] + "\"";
|
||||
}
|
||||
sql = String.format(sql, params);
|
||||
print(FIND_DATA, sql);
|
||||
@@ -223,7 +223,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
sql = sql.replace("?", "%s");
|
||||
Object[] params = new String[expression.length - 1];
|
||||
for (int i = 0, len = params.length; i < len; i++) {
|
||||
params[i] = "'" + expression[i + 1] + "'";
|
||||
params[i] = "\"" + expression[i + 1] + "\"";
|
||||
}
|
||||
sql = String.format(sql, params);
|
||||
print(FIND_DATA, sql);
|
||||
@@ -265,7 +265,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
sb.append("SELECT rowid, * FROM ").append(CommonUtil.getClassName(clazz)).append(" where ");
|
||||
int i = 0;
|
||||
for (Object where : wheres) {
|
||||
sb.append(where).append("=").append("'").append(values[i]).append("'");
|
||||
sb.append(where).append("=").append("\"").append(values[i]).append("\"");
|
||||
sb.append(i >= wheres.length - 1 ? "" : " AND ");
|
||||
i++;
|
||||
}
|
||||
@@ -315,7 +315,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
sql = sql.replace("?", "%s");
|
||||
Object[] params = new String[expression.length - 1];
|
||||
for (int i = 0, len = params.length; i < len; i++) {
|
||||
params[i] = "'" + expression[i + 1] + "'";
|
||||
params[i] = "\"" + expression[i + 1] + "\"";
|
||||
}
|
||||
sql = String.format(sql, params);
|
||||
SqlHelper.print(DEL_DATA, sql);
|
||||
@@ -350,7 +350,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
//sb.append(field.getName()).append("='");
|
||||
String value;
|
||||
prams.append(i > 0 ? ", " : "");
|
||||
prams.append(field.getName()).append("='");
|
||||
prams.append(field.getName()).append("=\"");
|
||||
Type type = field.getType();
|
||||
if (type == Map.class) {
|
||||
value = SqlUtil.map2Str((Map<String, String>) field.get(dbEntity));
|
||||
@@ -370,7 +370,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
//sb.append(value == null ? "" : value);
|
||||
//sb.append("'");
|
||||
prams.append(TextUtils.isEmpty(value) ? "" : value);
|
||||
prams.append("'");
|
||||
prams.append("\"");
|
||||
} catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
@@ -415,7 +415,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
continue;
|
||||
}
|
||||
sb.append(i > 0 ? ", " : "");
|
||||
sb.append("'");
|
||||
sb.append("\"");
|
||||
Type type = field.getType();
|
||||
if (type == Map.class) {
|
||||
sb.append(SqlUtil.map2Str((Map<String, String>) field.get(dbEntity)));
|
||||
@@ -430,7 +430,7 @@ final class SqlHelper extends SQLiteOpenHelper {
|
||||
} else {
|
||||
sb.append(field.get(dbEntity));
|
||||
}
|
||||
sb.append("'");
|
||||
sb.append("\"");
|
||||
i++;
|
||||
}
|
||||
} catch (IllegalAccessException e) {
|
||||
|
||||
@@ -1,4 +1,10 @@
|
||||
## 开发日志
|
||||
+ v_3.3.11
|
||||
- 添加进度更新间隔api,在`aria_config.xml`配置`<updateInterval value="1000"/>`或在代码中调用
|
||||
`AriaManager.getInstance(AriaManager.APP).getDownloadConfig().setUpdateInterval(3000)`便可以改变进度刷新间隔
|
||||
- 修复下载过程中kill进程可能出现的文件错误的问题 https://github.com/AriaLyy/Aria/issues/192
|
||||
- 修复http上传的空指针问题 https://github.com/AriaLyy/Aria/issues/193
|
||||
- 修复下载地址中含有`'`导致的崩溃问题 https://github.com/AriaLyy/Aria/issues/194
|
||||
+ v_3.3.10
|
||||
- 修复地址切换导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/181
|
||||
- 添加重置状态的api,当下载信息不改变,只是替换了服务器的对应的文件,可用`Aria.download(this).load(url).resetState()`重置下载状态 https://github.com/AriaLyy/Aria/issues/182
|
||||
|
||||
13
README.md
13
README.md
@@ -28,8 +28,8 @@ Aria有以下特点:
|
||||
[](https://bintray.com/arialyy/maven/AriaApi/_latestVersion)
|
||||
[](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion)
|
||||
```java
|
||||
compile 'com.arialyy.aria:aria-core:3.3.10'
|
||||
annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.10'
|
||||
compile 'com.arialyy.aria:aria-core:3.3.11'
|
||||
annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.11'
|
||||
```
|
||||
如果你使用的是kotlin,请使用kotlin官方提供的方法配置apt,[kotlin kapt官方配置传送门](https://www.kotlincn.net/docs/reference/kapt.html)
|
||||
|
||||
@@ -97,9 +97,12 @@ protected void onCreate(Bundle savedInstanceState) {
|
||||
### [更多说明,见WIKI](https://github.com/AriaLyy/Aria/wiki)
|
||||
|
||||
### 升级日志
|
||||
+ v_3.3.10
|
||||
- 修复地址切换导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/181
|
||||
- 添加重置状态的api,当下载信息不改变,只是替换了服务器的对应的文件,可用`Aria.download(this).load(url).resetState()`重置下载状态 https://github.com/AriaLyy/Aria/issues/182
|
||||
+ v_3.3.11
|
||||
- 添加进度更新间隔api,在`aria_config.xml`配置`<updateInterval value="1000"/>`或在代码中调用
|
||||
`AriaManager.getInstance(AriaManager.APP).getDownloadConfig().setUpdateInterval(3000)`便可以改变进度刷新间隔
|
||||
- 修复下载过程中kill进程可能出现的文件错误的问题 https://github.com/AriaLyy/Aria/issues/192
|
||||
- 修复http上传的空指针问题 https://github.com/AriaLyy/Aria/issues/193
|
||||
- 修复下载地址中含有`'`导致的崩溃问题 https://github.com/AriaLyy/Aria/issues/194
|
||||
|
||||
[更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)
|
||||
|
||||
|
||||
@@ -34,6 +34,9 @@
|
||||
<!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait-->
|
||||
<queueMod value="wait"/>
|
||||
|
||||
<!--进度更新更新间隔,默认1000毫秒-->
|
||||
<updateInterval value="1000"/>
|
||||
|
||||
</download>
|
||||
|
||||
<upload>
|
||||
@@ -54,6 +57,9 @@
|
||||
|
||||
<!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait-->
|
||||
<queueMod value="wait"/>
|
||||
|
||||
<!--进度更新更新间隔,默认1000毫秒-->
|
||||
<updateInterval value="1000"/>
|
||||
</upload>
|
||||
|
||||
</aria>
|
||||
@@ -62,7 +62,8 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
//不支持断点的链接
|
||||
//"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://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2";
|
||||
//"http://qudao.5535.cn/one/game.html?game=531&cpsuser=xiaoeryu2";
|
||||
"https://bogoe-res.mytbz.com/tbzengsong/If You're Happy.mp3";
|
||||
@Bind(R.id.start) Button mStart;
|
||||
@Bind(R.id.stop) Button mStop;
|
||||
@Bind(R.id.cancel) Button mCancel;
|
||||
@@ -157,6 +158,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
mStart.setText("开始");
|
||||
setBtState(true);
|
||||
getBinding().setSpeed("");
|
||||
Log.d(TAG, "cancel");
|
||||
}
|
||||
|
||||
@Download.onTaskFail void taskFail(DownloadTask task) {
|
||||
|
||||
@@ -19,6 +19,7 @@ package com.arialyy.simple.download.multi_download;
|
||||
import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.util.Log;
|
||||
import android.view.Menu;
|
||||
import android.view.MenuItem;
|
||||
import butterknife.Bind;
|
||||
@@ -29,10 +30,12 @@ import com.arialyy.aria.core.download.DownloadEntity;
|
||||
import com.arialyy.aria.core.download.DownloadGroupTask;
|
||||
import com.arialyy.aria.core.download.DownloadTask;
|
||||
import com.arialyy.aria.core.inf.AbsEntity;
|
||||
import com.arialyy.frame.util.FileUtil;
|
||||
import com.arialyy.frame.util.show.L;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityMultiDownloadBinding;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
|
||||
@@ -21,6 +21,7 @@ import android.os.Bundle;
|
||||
import android.support.v7.widget.LinearLayoutManager;
|
||||
import android.support.v7.widget.RecyclerView;
|
||||
import android.support.v7.widget.Toolbar;
|
||||
import android.util.Log;
|
||||
import android.view.View;
|
||||
import butterknife.Bind;
|
||||
import com.arialyy.annotations.Download;
|
||||
@@ -28,10 +29,12 @@ import com.arialyy.annotations.DownloadGroup;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadGroupTask;
|
||||
import com.arialyy.aria.core.download.DownloadTask;
|
||||
import com.arialyy.frame.util.FileUtil;
|
||||
import com.arialyy.simple.R;
|
||||
import com.arialyy.simple.base.BaseActivity;
|
||||
import com.arialyy.simple.databinding.ActivityMultiBinding;
|
||||
import com.arialyy.simple.download.DownloadModule;
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
@@ -95,6 +98,10 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
|
||||
mAdapter.updateBtState(task.getKey(), true);
|
||||
}
|
||||
|
||||
@Download.onTaskComplete void taskComplete(DownloadTask task){
|
||||
Log.d(TAG, FileUtil.getFileMD5(new File(task.getDownloadPath())));
|
||||
}
|
||||
|
||||
//############################### 任务组 ##############################
|
||||
@DownloadGroup.onTaskComplete void groupTaskComplete(DownloadGroupTask task) {
|
||||
mAdapter.updateBtState(task.getKey(), true);
|
||||
|
||||
@@ -35,7 +35,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
|
||||
private static final String TAG = "HttpUploadActivity";
|
||||
@Bind(R.id.pb) HorizontalProgressBarWithNumber mPb;
|
||||
|
||||
private static final String FILE_PATH = "/sdcard/large.rar";
|
||||
private static final String FILE_PATH = "/mnt/sdcard/gg.zip";
|
||||
|
||||
@Override protected int setLayoutId() {
|
||||
return R.layout.activity_upload;
|
||||
@@ -50,8 +50,8 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
|
||||
@OnClick(R.id.upload) void upload() {
|
||||
Aria.upload(HttpUploadActivity.this)
|
||||
.load(FILE_PATH)
|
||||
.setUploadUrl("http://172.18.104.66:8080/upload/sign_file")
|
||||
.setAttachment("file")
|
||||
.setUploadUrl("http://192.168.1.9:8080/upload/")
|
||||
.setAttachment("serveFile")
|
||||
.start();
|
||||
}
|
||||
|
||||
|
||||
@@ -19,6 +19,7 @@ import android.text.TextUtils;
|
||||
import com.arialyy.aria.core.common.QueueMod;
|
||||
import com.arialyy.aria.core.queue.DownloadTaskQueue;
|
||||
import com.arialyy.aria.core.queue.UploadTaskQueue;
|
||||
import com.arialyy.aria.util.ALog;
|
||||
import com.arialyy.aria.util.CommonUtil;
|
||||
import java.io.File;
|
||||
import java.lang.reflect.Field;
|
||||
@@ -39,6 +40,11 @@ class Configuration {
|
||||
* 通用配置
|
||||
*/
|
||||
public static class BaseConfig {
|
||||
/**
|
||||
* 进度刷新间隔,默认1秒
|
||||
*/
|
||||
long updateInterval = 1000;
|
||||
|
||||
/**
|
||||
* 旧任务数
|
||||
*/
|
||||
@@ -73,6 +79,25 @@ class Configuration {
|
||||
*/
|
||||
String queueMod = "wait";
|
||||
|
||||
public long getUpdateInterval() {
|
||||
return updateInterval;
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置进度更新间隔,该设置对正在运行的任务无效,默认为1000毫秒
|
||||
*
|
||||
* @param updateInterval 不能小于0
|
||||
*/
|
||||
public BaseConfig setUpdateInterval(long updateInterval) {
|
||||
if (updateInterval <= 0) {
|
||||
ALog.w("Configuration", "进度更新间隔不能小于0");
|
||||
return this;
|
||||
}
|
||||
this.updateInterval = updateInterval;
|
||||
saveKey("updateInterval", String.valueOf(updateInterval));
|
||||
return this;
|
||||
}
|
||||
|
||||
public String getQueueMod() {
|
||||
return queueMod;
|
||||
}
|
||||
@@ -272,7 +297,7 @@ class Configuration {
|
||||
return this;
|
||||
}
|
||||
|
||||
public void setThreadNum(int threadNum){
|
||||
public void setThreadNum(int threadNum) {
|
||||
this.threadNum = threadNum;
|
||||
saveKey("threadNum", String.valueOf(threadNum));
|
||||
}
|
||||
|
||||
@@ -39,7 +39,7 @@ task clean(type: Delete) {
|
||||
ext {
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
publishVersion = '3.3.10'
|
||||
publishVersion = '3.3.11'
|
||||
// publishVersion = '1.0.3' //FTP插件
|
||||
repoName='maven'
|
||||
desc = 'android 下载框架'
|
||||
|
||||
Reference in New Issue
Block a user