Merge branch 'v_3.0'

pull/330/head
AriaLyy 7 years ago
commit c02d8c82b5
  1. 19
      Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
  2. 47
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  3. 4
      Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  4. 2
      Aria/src/main/java/com/arialyy/aria/core/common/StateConstance.java
  5. 5
      Aria/src/main/java/com/arialyy/aria/core/download/BaseDListener.java
  6. 5
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/AbsGroupUtil.java
  7. 3
      Aria/src/main/java/com/arialyy/aria/core/download/downloader/Downloader.java
  8. 9
      Aria/src/main/java/com/arialyy/aria/core/inf/AbsTaskEntity.java
  9. 5
      Aria/src/main/java/com/arialyy/aria/core/upload/BaseUListener.java
  10. 2
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/HttpThreadTask.java
  11. 32
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/SimpleUploadUtil.java
  12. 3
      Aria/src/main/java/com/arialyy/aria/core/upload/uploader/Uploader.java
  13. 16
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  14. 6
      DEV_LOG.md
  15. 13
      README.md
  16. 6
      app/src/main/assets/aria_config.xml
  17. 4
      app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java
  18. 3
      app/src/main/java/com/arialyy/simple/download/multi_download/MultiDownloadActivity.java
  19. 7
      app/src/main/java/com/arialyy/simple/download/multi_download/MultiTaskActivity.java
  20. 6
      app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java
  21. 27
      aria/src/main/java/com/arialyy/aria/core/Configuration.java
  22. 2
      build.gradle

@ -86,8 +86,27 @@ class ConfigHelper extends DefaultHandler {
case "queueMod": case "queueMod":
loadQueueMod(value); loadQueueMod(value);
break; 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) { private void loadQueueMod(String value) {

@ -40,6 +40,9 @@ import java.util.concurrent.Executors;
*/ */
public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>> public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY extends AbsTaskEntity<ENTITY>>
implements Runnable, IUtil { implements Runnable, IUtil {
public static final String STATE = "_state_";
public static final String RECORD = "_record_";
private final String TAG = "AbsFileer"; private final String TAG = "AbsFileer";
protected IEventListener mListener; protected IEventListener mListener;
protected TASK_ENTITY mTaskEntity; 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 static final long SUB_LEN = 1024 * 1024;
private Timer mTimer; private Timer mTimer;
private long mUpdateInterval = 1000;
protected AbsFileer(IEventListener listener, TASK_ENTITY taskEntity) { protected AbsFileer(IEventListener listener, TASK_ENTITY taskEntity) {
mListener = listener; mListener = listener;
@ -111,7 +115,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
mConstance.THREAD_NUM = mTotalThreadNum; mConstance.THREAD_NUM = mTotalThreadNum;
handleNoSupportBP(); handleNoSupportBP();
} else { } else {
mTotalThreadNum = isNewTask ? (getNewTaskThreadNum()) : mStartThreadNum + mCompleteThreadNum; mTotalThreadNum = isNewTask ? (getNewTaskThreadNum()) : mStartThreadNum;
mConstance.THREAD_NUM = mTotalThreadNum; mConstance.THREAD_NUM = mTotalThreadNum;
handleBreakpoint(); handleBreakpoint();
} }
@ -145,7 +149,7 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
mListener.onProgress(mConstance.CURRENT_LOCATION); mListener.onProgress(mConstance.CURRENT_LOCATION);
} }
} }
}, 0, 1000); }, 0, mUpdateInterval);
} }
protected void closeTimer() { 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() { @Override public long getFileSize() {
return mEntity.getFileSize(); return mEntity.getFileSize();
} }
@ -249,10 +267,14 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
int num = 0; int num = 0;
for (Object key : keys) { for (Object key : keys) {
String str = String.valueOf(key); String str = String.valueOf(key);
if (str.contains("_record_")) { Object state = pro.getProperty(str);
if (str.contains(RECORD)) {
num++; num++;
} else if (str.contains("_state_")) { } else if (state != null && str.contains(STATE) && Integer.parseInt(state + "") == 1) {
mCompleteThreadNum++; int i = Integer.parseInt(str.substring(str.length() - 1, str.length()));
if (pro.getProperty(mTempFile.getName() + RECORD + i) != null) {
mCompleteThreadNum++;
}
} }
} }
if (num == 0) { if (num == 0) {
@ -260,8 +282,8 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
} }
mStartThreadNum = num; mStartThreadNum = num;
for (int i = 0; i < mStartThreadNum; i++) { for (int i = 0; i < mStartThreadNum; i++) {
if (pro.getProperty(mTempFile.getName() + "_record_" + i) == null) { if (pro.getProperty(mTempFile.getName() + RECORD + i) == null) {
Object state = pro.getProperty(mTempFile.getName() + "_state_" + i); Object state = pro.getProperty(mTempFile.getName() + STATE + i);
if (state != null && Integer.parseInt(state + "") == 1) { if (state != null && Integer.parseInt(state + "") == 1) {
continue; continue;
} }
@ -332,17 +354,18 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
} }
for (int i = 0; i < mTotalThreadNum; i++) { for (int i = 0; i < mTotalThreadNum; i++) {
long startL = i * blockSize, endL = (i + 1) * blockSize; long startL = i * blockSize, endL = (i + 1) * blockSize;
Object state = pro.getProperty(mTempFile.getName() + "_state_" + i); Object state = pro.getProperty(mTempFile.getName() + STATE + i);
if (state != null && Integer.parseInt(state + "") == 1) { //该线程已经完成 Object record = pro.getProperty(mTempFile.getName() + RECORD + i);
if (state != null && Integer.parseInt(state + "") == 1 && record != null) { //该线程已经完成
if (resumeRecordLocation(i, startL, endL)) return; if (resumeRecordLocation(i, startL, endL)) return;
continue; continue;
} }
//分配下载位置
Object record = pro.getProperty(mTempFile.getName() + "_record_" + i);
//如果有记录,则恢复下载 //如果有记录,则恢复下载
if (!isNewTask && record != null && Long.parseLong(record + "") >= 0) { if (!isNewTask && record != null && Long.parseLong(record + "") >= 0) {
Long r = Long.parseLong(record + ""); Long r = Long.parseLong(record + "");
if (r > startL) { //记录的位置需要在线程区间中
if (startL < r && r < (i == (mTotalThreadNum - 1) ? fileLength : endL)) {
mConstance.CURRENT_LOCATION += r - startL; mConstance.CURRENT_LOCATION += r - startL;
startL = r; startL = r;
} }

@ -263,10 +263,10 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
synchronized (AriaManager.LOCK) { synchronized (AriaManager.LOCK) {
String key = null, value = null; String key = null, value = null;
if (record >= mConfig.END_LOCATION || isComplete) { 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"; value = "1";
} else if (0 < record && record < mConfig.END_LOCATION) { } 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); value = String.valueOf(record);
} }
if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) { if (!TextUtils.isEmpty(key) && !TextUtils.isEmpty(value)) {

@ -63,7 +63,7 @@ public class StateConstance {
* 所有子线程是否都已经完成下载 * 所有子线程是否都已经完成下载
*/ */
public boolean isComplete() { 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; private boolean isConvertSpeed = false;
boolean isWait = false; boolean isWait = false;
private long mLastSaveTime; private long mLastSaveTime;
private long mUpdateInterval;
BaseDListener(TASK task, Handler outHandler) { BaseDListener(TASK task, Handler outHandler) {
this.outHandler = new WeakReference<>(outHandler); this.outHandler = new WeakReference<>(outHandler);
@ -51,6 +52,7 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
isConvertSpeed = manager.getDownloadConfig().isConvertSpeed(); isConvertSpeed = manager.getDownloadConfig().isConvertSpeed();
mLastLen = mEntity.getCurrentProgress(); mLastLen = mEntity.getCurrentProgress();
mLastSaveTime = System.currentTimeMillis(); mLastSaveTime = System.currentTimeMillis();
mUpdateInterval = manager.getDownloadConfig().getUpdateInterval();
} }
@Override public void onPre() { @Override public void onPre() {
@ -123,6 +125,9 @@ class BaseDListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
} }
private void handleSpeed(long speed) { private void handleSpeed(long speed) {
if (mUpdateInterval != 1000) {
speed = speed * 1000 / mUpdateInterval;
}
if (isConvertSpeed) { if (isConvertSpeed) {
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s"); mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
} }

@ -99,6 +99,7 @@ public abstract class AbsGroupUtil implements IUtil {
int mInitFailNum = 0; int mInitFailNum = 0;
//任务组大小 //任务组大小
int mGroupSize = 0; int mGroupSize = 0;
long mUpdateInterval = 1000;
AbsGroupUtil(IDownloadGroupListener listener, DownloadGroupTaskEntity groupEntity) { AbsGroupUtil(IDownloadGroupListener listener, DownloadGroupTaskEntity groupEntity) {
mListener = listener; mListener = listener;
@ -131,6 +132,8 @@ public abstract class AbsGroupUtil implements IUtil {
} }
} }
updateFileSize(); updateFileSize();
mUpdateInterval =
AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getUpdateInterval();
} }
/** /**
@ -371,7 +374,7 @@ public abstract class AbsGroupUtil implements IUtil {
mListener.onProgress(mCurrentLocation); mListener.onProgress(mCurrentLocation);
} }
} }
}, 0, 1000); }, 0, mUpdateInterval);
} }
/** /**

@ -15,6 +15,7 @@
*/ */
package com.arialyy.aria.core.download.downloader; 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.AbsFileer;
import com.arialyy.aria.core.common.AbsThreadTask; import com.arialyy.aria.core.common.AbsThreadTask;
import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.common.SubThreadConfig;
@ -39,6 +40,8 @@ class Downloader extends AbsFileer<DownloadEntity, DownloadTaskEntity> {
Downloader(IDownloadListener listener, DownloadTaskEntity taskEntity) { Downloader(IDownloadListener listener, DownloadTaskEntity taskEntity) {
super(listener, taskEntity); super(listener, taskEntity);
setUpdateInterval(
AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getUpdateInterval());
} }
@Override protected void checkTask() { @Override protected void checkTask() {

@ -36,10 +36,6 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
* HTTP任务组下载 * HTTP任务组下载
*/ */
public static final int DG_HTTP = 0x12; public static final int DG_HTTP = 0x12;
/**
* HTTP单文件上传
*/
public static final int U_HTTP = 0xA1;
/** /**
* FTP单文件下载 * FTP单文件下载
@ -49,6 +45,11 @@ public abstract class AbsTaskEntity<ENTITY extends AbsEntity> extends DbEntity {
* FTP文件夹下载为避免登录过多子任务由单线程进行处理 * FTP文件夹下载为避免登录过多子任务由单线程进行处理
*/ */
public static final int D_FTP_DIR = 0x14; public static final int D_FTP_DIR = 0x14;
/**
* HTTP单文件上传
*/
public static final int U_HTTP = 0xA1;
/** /**
* FTP单文件上传 * FTP单文件上传
*/ */

@ -41,6 +41,7 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
private boolean isConvertSpeed = false; private boolean isConvertSpeed = false;
boolean isWait = false; boolean isWait = false;
private long mLastSaveTime; private long mLastSaveTime;
private long mUpdateInterval;
BaseUListener(TASK task, Handler outHandler) { BaseUListener(TASK task, Handler outHandler) {
this.outHandler = new WeakReference<>(outHandler); this.outHandler = new WeakReference<>(outHandler);
@ -51,6 +52,7 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
isConvertSpeed = manager.getDownloadConfig().isConvertSpeed(); isConvertSpeed = manager.getDownloadConfig().isConvertSpeed();
mLastLen = mEntity.getCurrentProgress(); mLastLen = mEntity.getCurrentProgress();
mLastSaveTime = System.currentTimeMillis(); mLastSaveTime = System.currentTimeMillis();
mUpdateInterval = manager.getUploadConfig().getUpdateInterval();
} }
@Override public void onPre() { @Override public void onPre() {
@ -111,6 +113,9 @@ class BaseUListener<ENTITY extends AbsEntity, TASK_ENTITY extends AbsTaskEntity<
} }
private void handleSpeed(long speed) { private void handleSpeed(long speed) {
if (mUpdateInterval != 1000) {
speed = speed * 1000 / mUpdateInterval;
}
if (isConvertSpeed) { if (isConvertSpeed) {
mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s"); mEntity.setConvertSpeed(CommonUtil.formatFileSize(speed < 0 ? 0 : speed) + "/s");
} }

@ -90,7 +90,7 @@ class HttpThreadTask extends AbsThreadTask<UploadEntity, UploadTaskEntity> {
} }
uploadFile(writer, mTaskEntity.attachment, uploadFile); uploadFile(writer, mTaskEntity.attachment, uploadFile);
finish(writer); finish(writer);
} catch (IOException e) { } catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
fail(); 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.IUtil;
import com.arialyy.aria.core.common.OnFileInfoCallback; 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.inf.IUploadListener;
import com.arialyy.aria.core.upload.UploadEntity; import com.arialyy.aria.core.upload.UploadEntity;
import com.arialyy.aria.core.upload.UploadTaskEntity; import com.arialyy.aria.core.upload.UploadTaskEntity;
@ -47,19 +48,26 @@ public class SimpleUploadUtil implements IUtil, Runnable {
@Override public void run() { @Override public void run() {
mListener.onPre(); mListener.onPre();
new FtpFileInfoThread(mTaskEntity, new OnFileInfoCallback() { switch (mTaskEntity.requestType) {
@Override public void onComplete(String url, int code) { case AbsTaskEntity.U_FTP:
if (code == FtpFileInfoThread.CODE_COMPLETE) { new FtpFileInfoThread(mTaskEntity, new OnFileInfoCallback() {
mListener.onComplete(); @Override public void onComplete(String url, int code) {
} else { if (code == FtpFileInfoThread.CODE_COMPLETE) {
mUploader.start(); mListener.onComplete();
} } else {
} mUploader.start();
}
}
@Override public void onFail(String url, String errorMsg, boolean needRetry) { @Override public void onFail(String url, String errorMsg, boolean needRetry) {
mListener.onFail(needRetry); mListener.onFail(needRetry);
} }
}).start(); }).start();
break;
case AbsTaskEntity.U_HTTP:
mUploader.start();
break;
}
} }
@Override public long getFileSize() { @Override public long getFileSize() {

@ -15,6 +15,7 @@
*/ */
package com.arialyy.aria.core.upload.uploader; 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.AbsFileer;
import com.arialyy.aria.core.common.AbsThreadTask; import com.arialyy.aria.core.common.AbsThreadTask;
import com.arialyy.aria.core.common.SubThreadConfig; import com.arialyy.aria.core.common.SubThreadConfig;
@ -35,6 +36,8 @@ class Uploader extends AbsFileer<UploadEntity, UploadTaskEntity> {
Uploader(IUploadListener listener, UploadTaskEntity taskEntity) { Uploader(IUploadListener listener, UploadTaskEntity taskEntity) {
super(listener, taskEntity); super(listener, taskEntity);
mTempFile = new File(mEntity.getFilePath()); 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"); sql = sql.replace("?", "%s");
Object[] params = new String[expression.length - 1]; Object[] params = new String[expression.length - 1];
for (int i = 0, len = params.length; i < len; i++) { 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); sql = String.format(sql, params);
print(FIND_DATA, sql); print(FIND_DATA, sql);
@ -223,7 +223,7 @@ final class SqlHelper extends SQLiteOpenHelper {
sql = sql.replace("?", "%s"); sql = sql.replace("?", "%s");
Object[] params = new String[expression.length - 1]; Object[] params = new String[expression.length - 1];
for (int i = 0, len = params.length; i < len; i++) { 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); sql = String.format(sql, params);
print(FIND_DATA, sql); print(FIND_DATA, sql);
@ -265,7 +265,7 @@ final class SqlHelper extends SQLiteOpenHelper {
sb.append("SELECT rowid, * FROM ").append(CommonUtil.getClassName(clazz)).append(" where "); sb.append("SELECT rowid, * FROM ").append(CommonUtil.getClassName(clazz)).append(" where ");
int i = 0; int i = 0;
for (Object where : wheres) { 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 "); sb.append(i >= wheres.length - 1 ? "" : " AND ");
i++; i++;
} }
@ -315,7 +315,7 @@ final class SqlHelper extends SQLiteOpenHelper {
sql = sql.replace("?", "%s"); sql = sql.replace("?", "%s");
Object[] params = new String[expression.length - 1]; Object[] params = new String[expression.length - 1];
for (int i = 0, len = params.length; i < len; i++) { 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); sql = String.format(sql, params);
SqlHelper.print(DEL_DATA, sql); SqlHelper.print(DEL_DATA, sql);
@ -350,7 +350,7 @@ final class SqlHelper extends SQLiteOpenHelper {
//sb.append(field.getName()).append("='"); //sb.append(field.getName()).append("='");
String value; String value;
prams.append(i > 0 ? ", " : ""); prams.append(i > 0 ? ", " : "");
prams.append(field.getName()).append("='"); prams.append(field.getName()).append("=\"");
Type type = field.getType(); Type type = field.getType();
if (type == Map.class) { if (type == Map.class) {
value = SqlUtil.map2Str((Map<String, String>) field.get(dbEntity)); 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(value == null ? "" : value);
//sb.append("'"); //sb.append("'");
prams.append(TextUtils.isEmpty(value) ? "" : value); prams.append(TextUtils.isEmpty(value) ? "" : value);
prams.append("'"); prams.append("\"");
} catch (IllegalAccessException e) { } catch (IllegalAccessException e) {
e.printStackTrace(); e.printStackTrace();
} }
@ -415,7 +415,7 @@ final class SqlHelper extends SQLiteOpenHelper {
continue; continue;
} }
sb.append(i > 0 ? ", " : ""); sb.append(i > 0 ? ", " : "");
sb.append("'"); sb.append("\"");
Type type = field.getType(); Type type = field.getType();
if (type == Map.class) { if (type == Map.class) {
sb.append(SqlUtil.map2Str((Map<String, String>) field.get(dbEntity))); sb.append(SqlUtil.map2Str((Map<String, String>) field.get(dbEntity)));
@ -430,7 +430,7 @@ final class SqlHelper extends SQLiteOpenHelper {
} else { } else {
sb.append(field.get(dbEntity)); sb.append(field.get(dbEntity));
} }
sb.append("'"); sb.append("\"");
i++; i++;
} }
} catch (IllegalAccessException e) { } 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 + v_3.3.10
- 修复地址切换导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/181 - 修复地址切换导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/181
- 添加重置状态的api,当下载信息不改变,只是替换了服务器的对应的文件,可用`Aria.download(this).load(url).resetState()`重置下载状态 https://github.com/AriaLyy/Aria/issues/182 - 添加重置状态的api,当下载信息不改变,只是替换了服务器的对应的文件,可用`Aria.download(this).load(url).resetState()`重置下载状态 https://github.com/AriaLyy/Aria/issues/182

@ -28,8 +28,8 @@ Aria有以下特点:
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion) [![Download](https://api.bintray.com/packages/arialyy/maven/AriaApi/images/download.svg)](https://bintray.com/arialyy/maven/AriaApi/_latestVersion)
[![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion) [![Download](https://api.bintray.com/packages/arialyy/maven/AriaCompiler/images/download.svg)](https://bintray.com/arialyy/maven/AriaCompiler/_latestVersion)
```java ```java
compile 'com.arialyy.aria:aria-core:3.3.10' compile 'com.arialyy.aria:aria-core:3.3.11'
annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.10' annotationProcessor 'com.arialyy.aria:aria-compiler:3.3.11'
``` ```
如果你使用的是kotlin,请使用kotlin官方提供的方法配置apt,[kotlin kapt官方配置传送门](https://www.kotlincn.net/docs/reference/kapt.html) 如果你使用的是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) ### [更多说明,见WIKI](https://github.com/AriaLyy/Aria/wiki)
### 升级日志 ### 升级日志
+ v_3.3.10 + v_3.3.11
- 修复地址切换导致下载失败的问题 https://github.com/AriaLyy/Aria/issues/181 - 添加进度更新间隔api,在`aria_config.xml`配置`<updateInterval value="1000"/>`或在代码中调用
- 添加重置状态的api,当下载信息不改变,只是替换了服务器的对应的文件,可用`Aria.download(this).load(url).resetState()`重置下载状态 https://github.com/AriaLyy/Aria/issues/182 `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) [更多版本记录](https://github.com/AriaLyy/Aria/blob/master/DEV_LOG.md)

@ -34,6 +34,9 @@
<!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait--> <!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait-->
<queueMod value="wait"/> <queueMod value="wait"/>
<!--进度更新更新间隔,默认1000毫秒-->
<updateInterval value="1000"/>
</download> </download>
<upload> <upload>
@ -54,6 +57,9 @@
<!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait--> <!--执行队列类型,见com.arialyy.aria.core.QueueMod,默认类型为wait-->
<queueMod value="wait"/> <queueMod value="wait"/>
<!--进度更新更新间隔,默认1000毫秒-->
<updateInterval value="1000"/>
</upload> </upload>
</aria> </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://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"; //"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.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;
@ -157,6 +158,7 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
mStart.setText("开始"); mStart.setText("开始");
setBtState(true); setBtState(true);
getBinding().setSpeed(""); getBinding().setSpeed("");
Log.d(TAG, "cancel");
} }
@Download.onTaskFail void taskFail(DownloadTask task) { @Download.onTaskFail void taskFail(DownloadTask task) {

@ -19,6 +19,7 @@ package com.arialyy.simple.download.multi_download;
import android.os.Bundle; import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.util.Log;
import android.view.Menu; import android.view.Menu;
import android.view.MenuItem; import android.view.MenuItem;
import butterknife.Bind; 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.DownloadGroupTask;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.aria.core.inf.AbsEntity; import com.arialyy.aria.core.inf.AbsEntity;
import com.arialyy.frame.util.FileUtil;
import com.arialyy.frame.util.show.L; import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R; import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityMultiDownloadBinding; import com.arialyy.simple.databinding.ActivityMultiDownloadBinding;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;

@ -21,6 +21,7 @@ import android.os.Bundle;
import android.support.v7.widget.LinearLayoutManager; import android.support.v7.widget.LinearLayoutManager;
import android.support.v7.widget.RecyclerView; import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar; import android.support.v7.widget.Toolbar;
import android.util.Log;
import android.view.View; import android.view.View;
import butterknife.Bind; import butterknife.Bind;
import com.arialyy.annotations.Download; 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.Aria;
import com.arialyy.aria.core.download.DownloadGroupTask; import com.arialyy.aria.core.download.DownloadGroupTask;
import com.arialyy.aria.core.download.DownloadTask; import com.arialyy.aria.core.download.DownloadTask;
import com.arialyy.frame.util.FileUtil;
import com.arialyy.simple.R; import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity; import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivityMultiBinding; import com.arialyy.simple.databinding.ActivityMultiBinding;
import com.arialyy.simple.download.DownloadModule; import com.arialyy.simple.download.DownloadModule;
import java.io.File;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
@ -95,6 +98,10 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
mAdapter.updateBtState(task.getKey(), true); 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) { @DownloadGroup.onTaskComplete void groupTaskComplete(DownloadGroupTask task) {
mAdapter.updateBtState(task.getKey(), true); mAdapter.updateBtState(task.getKey(), true);

@ -35,7 +35,7 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
private static final String TAG = "HttpUploadActivity"; private static final String TAG = "HttpUploadActivity";
@Bind(R.id.pb) HorizontalProgressBarWithNumber mPb; @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() { @Override protected int setLayoutId() {
return R.layout.activity_upload; return R.layout.activity_upload;
@ -50,8 +50,8 @@ public class HttpUploadActivity extends BaseActivity<ActivityUploadBinding> {
@OnClick(R.id.upload) void upload() { @OnClick(R.id.upload) void upload() {
Aria.upload(HttpUploadActivity.this) Aria.upload(HttpUploadActivity.this)
.load(FILE_PATH) .load(FILE_PATH)
.setUploadUrl("http://172.18.104.66:8080/upload/sign_file") .setUploadUrl("http://192.168.1.9:8080/upload/")
.setAttachment("file") .setAttachment("serveFile")
.start(); .start();
} }

@ -19,6 +19,7 @@ import android.text.TextUtils;
import com.arialyy.aria.core.common.QueueMod; import com.arialyy.aria.core.common.QueueMod;
import com.arialyy.aria.core.queue.DownloadTaskQueue; import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.UploadTaskQueue; import com.arialyy.aria.core.queue.UploadTaskQueue;
import com.arialyy.aria.util.ALog;
import com.arialyy.aria.util.CommonUtil; import com.arialyy.aria.util.CommonUtil;
import java.io.File; import java.io.File;
import java.lang.reflect.Field; import java.lang.reflect.Field;
@ -39,6 +40,11 @@ class Configuration {
* 通用配置 * 通用配置
*/ */
public static class BaseConfig { public static class BaseConfig {
/**
* 进度刷新间隔默认1秒
*/
long updateInterval = 1000;
/** /**
* 旧任务数 * 旧任务数
*/ */
@ -73,6 +79,25 @@ class Configuration {
*/ */
String queueMod = "wait"; 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() { public String getQueueMod() {
return queueMod; return queueMod;
} }
@ -272,7 +297,7 @@ class Configuration {
return this; return this;
} }
public void setThreadNum(int threadNum){ public void setThreadNum(int threadNum) {
this.threadNum = threadNum; this.threadNum = threadNum;
saveKey("threadNum", String.valueOf(threadNum)); saveKey("threadNum", String.valueOf(threadNum));
} }

@ -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.10' publishVersion = '3.3.11'
// publishVersion = '1.0.3' //FTP插件 // publishVersion = '1.0.3' //FTP插件
repoName='maven' repoName='maven'
desc = 'android 下载框架' desc = 'android 下载框架'

Loading…
Cancel
Save