pull/330/head
AriaLyy 7 years ago
parent 9ae1d8b530
commit b191bb2470
  1. 22
      Aria/src/main/java/com/arialyy/aria/core/common/AbsFileer.java
  2. 4
      Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  3. 3
      DEV_LOG.md
  4. 13
      README.md
  5. 3
      app/src/main/java/com/arialyy/simple/download/multi_download/MultiDownloadActivity.java
  6. 7
      app/src/main/java/com/arialyy/simple/download/multi_download/MultiTaskActivity.java
  7. 4
      app/src/main/java/com/arialyy/simple/upload/HttpUploadActivity.java
  8. 2
      build.gradle

@ -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;
@ -265,19 +268,22 @@ public abstract class AbsFileer<ENTITY extends AbsNormalEntity, TASK_ENTITY exte
for (Object key : keys) { for (Object key : keys) {
String str = String.valueOf(key); String str = String.valueOf(key);
Object state = pro.getProperty(str); Object state = pro.getProperty(str);
if (str.contains("_record_")) { if (str.contains(RECORD)) {
num++; num++;
} else if (state != null && str.contains("_state_") && Integer.parseInt(state + "") == 1) { } 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++; mCompleteThreadNum++;
} }
} }
}
if (num == 0) { if (num == 0) {
return true; return true;
} }
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;
} }
@ -348,13 +354,13 @@ 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 + "");

@ -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)) {

@ -2,6 +2,9 @@
+ v_3.3.11 + v_3.3.11
- 添加进度更新间隔api,在`aria_config.xml`配置`<updateInterval value="1000"/>`或在代码中调用 - 添加进度更新间隔api,在`aria_config.xml`配置`<updateInterval value="1000"/>`或在代码中调用
`AriaManager.getInstance(AriaManager.APP).getDownloadConfig().setUpdateInterval(3000)`便可以改变进度刷新间隔 `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)

@ -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);

@ -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://127.0.0.1:8080/upload/") .setUploadUrl("http://192.168.1.9:8080/upload/")
.setAttachment("file") .setAttachment("serveFile")
.start(); .start();
} }

@ -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