pull/330/head
laoyuyu 7 years ago
parent 554b5bf63e
commit ed369db0f7
  1. 2
      Aria/src/main/java/com/arialyy/aria/core/ConfigHelper.java
  2. 2
      Aria/src/main/java/com/arialyy/aria/core/common/AbsThreadTask.java
  3. 3
      Aria/src/main/java/com/arialyy/aria/core/download/BaseNormalTarget.java
  4. 2
      Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java
  5. 1
      Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java
  6. 5
      Aria/src/main/java/com/arialyy/aria/util/Regular.java
  7. 5
      DEV_LOG.md
  8. 24
      app/src/main/java/com/arialyy/simple/test/AnyRunActivity.java
  9. 10
      app/src/main/java/com/arialyy/simple/test/AnyRunnModule.java
  10. 16
      aria/src/main/java/com/arialyy/aria/core/Configuration.java
  11. 2
      build.gradle

@ -163,7 +163,7 @@ class ConfigHelper extends DefaultHandler {
private void loadMaxSpeed(String value) { private void loadMaxSpeed(String value) {
int maxSpeed = checkInt(value) ? Integer.parseInt(value) : 0; int maxSpeed = checkInt(value) ? Integer.parseInt(value) : 0;
if (isDownloadConfig) { if (isDownloadConfig) {
mDownloadConfig.msxSpeed = maxSpeed; mDownloadConfig.maxSpeed = maxSpeed;
} }
} }

@ -86,7 +86,7 @@ public abstract class AbsThreadTask<ENTITY extends AbsNormalEntity, TASK_ENTITY
mEntity = mTaskEntity.getEntity(); mEntity = mTaskEntity.getEntity();
mConfigFPath = info.CONFIG_FILE_PATH; mConfigFPath = info.CONFIG_FILE_PATH;
mBufSize = manager.getDownloadConfig().getBuffSize(); mBufSize = manager.getDownloadConfig().getBuffSize();
setMaxSpeed(AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getMsxSpeed()); setMaxSpeed(AriaManager.getInstance(AriaManager.APP).getDownloadConfig().getMaxSpeed());
mTaskType = getTaskType(); mTaskType = getTaskType();
mLastSaveTime = System.currentTimeMillis(); mLastSaveTime = System.currentTimeMillis();
mConfigThreadPool = Executors.newCachedThreadPool(); mConfigThreadPool = Executors.newCachedThreadPool();

@ -141,8 +141,7 @@ abstract class BaseNormalTarget<TARGET extends BaseNormalTarget>
//设置文件保存路径,如果新文件路径和就文件路径不同,则修改路径 //设置文件保存路径,如果新文件路径和就文件路径不同,则修改路径
if (!filePath.equals(mEntity.getDownloadPath())) { if (!filePath.equals(mEntity.getDownloadPath())) {
if (!mTaskEntity.isRefreshInfo() && DbEntity.checkDataExist(DownloadEntity.class, if (DbEntity.checkDataExist(DownloadEntity.class, "downloadPath=?", filePath)) {
"downloadPath=?", filePath)) {
ALog.e(TAG, "下载失败,保存路径【" + filePath + "】已经被其它任务占用,请设置其它保存路径"); ALog.e(TAG, "下载失败,保存路径【" + filePath + "】已经被其它任务占用,请设置其它保存路径");
return false; return false;
} }

@ -51,7 +51,7 @@ public class DownloadReceiver extends AbsReceiver {
* @param maxSpeed 为0表示不限速 * @param maxSpeed 为0表示不限速
*/ */
@Deprecated public void setMaxSpeed(int maxSpeed) { @Deprecated public void setMaxSpeed(int maxSpeed) {
AriaManager.getInstance(AriaManager.APP).getDownloadConfig().setMsxSpeed(maxSpeed); AriaManager.getInstance(AriaManager.APP).getDownloadConfig().setMaxSpeed(maxSpeed);
} }
/** /**

@ -202,6 +202,7 @@ abstract class AbsTaskQueue<TASK extends AbsTask, TASK_ENTITY extends AbsTaskEnt
if (!task.isRunning()) { if (!task.isRunning()) {
task.start(); task.start();
} else { } else {
task.stop();
ALog.e(TAG, "任务【" + task.getTaskName() + "】重试失败,原因:任务没有完全停止,"); ALog.e(TAG, "任务【" + task.getTaskName() + "】重试失败,原因:任务没有完全停止,");
} }
} }

@ -29,4 +29,9 @@ public interface Regular {
* 匹配双字节字符空格制表符换行符 * 匹配双字节字符空格制表符换行符
*/ */
String REG_DOUBLE_CHAR_AND_SPACE = "[^\\x00-\\xff]|[\\s\\p{Zs}]"; String REG_DOUBLE_CHAR_AND_SPACE = "[^\\x00-\\xff]|[\\s\\p{Zs}]";
/**
* 匹配window.location.replace
*/
String REG_WINLOD_REPLACE = "\\.*replace(\\.*)\\.*";
} }

@ -1,4 +1,9 @@
## 开发日志 ## 开发日志
+ v_3.4
- 优化大量代码
- 重构Aria的ORM模型
- 可在任意类中使用Aria了,[使用方法](http://aria.laoyuyu.me/aria_doc/start/any_java.html)
- window.location.replace("http://xxxx")类型的重定向支持
+ v_3.3.16 + v_3.3.16
- 修复一个activity启动多次,无法进行回掉的bug https://github.com/AriaLyy/Aria/issues/200 - 修复一个activity启动多次,无法进行回掉的bug https://github.com/AriaLyy/Aria/issues/200
- 优化target代码结构,移除路径被占用的提示 - 优化target代码结构,移除路径被占用的提示

@ -3,9 +3,12 @@ package com.arialyy.simple.test;
import android.os.Bundle; import android.os.Bundle;
import android.view.View; import android.view.View;
import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.download.DownloadEntity;
import com.arialyy.aria.core.inf.AbsEntity;
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.ActivityTestBinding; import com.arialyy.simple.databinding.ActivityTestBinding;
import java.util.List;
/** /**
* Created by laoyuyu on 2018/4/13. * Created by laoyuyu on 2018/4/13.
@ -15,6 +18,7 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
AnyRunnModule module; AnyRunnModule module;
String[] urls; String[] urls;
int index = 0; int index = 0;
String URL = "http://static.gaoshouyou.com/d/12/0d/7f120f50c80d2e7b8c4ba24ece4f9cdd.apk";
@Override protected int setLayoutId() { @Override protected int setLayoutId() {
return R.layout.activity_test; return R.layout.activity_test;
@ -26,22 +30,30 @@ public class AnyRunActivity extends BaseActivity<ActivityTestBinding> {
mBar.setVisibility(View.GONE); mBar.setVisibility(View.GONE);
module = new AnyRunnModule(this); module = new AnyRunnModule(this);
urls = getResources().getStringArray(R.array.group_urls); urls = getResources().getStringArray(R.array.group_urls);
} }
public void onClick(View view) { public void onClick(View view) {
switch (view.getId()) { switch (view.getId()) {
case R.id.start: case R.id.start:
//module.start(); //module.start();
if (index < urls.length) { //if (index < urls.length) {
module.start(urls[index]); // module.start(urls[index]);
index++; // index++;
} //}
//module.start("https://www.baidu.com/link?url=_LFCuTPtnzFxVJByJ504QymRywIA1Z_T5xUxe9ZLuxcGM0C_RcdpWyB1eGjbJC-e5wv5wAKM4WmLMAS5KeF6EZJHB8Va3YqZUiaErqK_pxm&wd=&eqid=e8583fe70002d126000000065a99f864");
module.start(URL);
break; break;
case R.id.stop: case R.id.stop:
module.stop(); List<AbsEntity> list = Aria.download(this).getTotalTaskList();
//module.stop();
module.stop(URL);
break; break;
case R.id.cancel: case R.id.cancel:
module.cancel(); module.cancel(URL);
//module.cancel();
break; break;
} }
} }

@ -69,17 +69,17 @@ public class AnyRunnModule {
.load(url) .load(url)
.addHeader("Accept-Encoding", "gzip, deflate") .addHeader("Accept-Encoding", "gzip, deflate")
.setRequestMode(RequestEnum.GET) .setRequestMode(RequestEnum.GET)
.setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg1.apk") .setFilePath(Environment.getExternalStorageDirectory().getPath() + "/ggsg123.apk")
.resetState() .resetState()
.start(); .start();
} }
void stop() { void stop(String url) {
Aria.download(this).load(mUrl).stop(); Aria.download(this).load(url).stop();
} }
void cancel() { void cancel(String url) {
Aria.download(this).load(mUrl).cancel(); Aria.download(this).load(url).cancel();
} }
void unRegister() { void unRegister() {

@ -111,7 +111,7 @@ class Configuration {
field.setFloat(this, Float.parseFloat(value)); field.setFloat(this, Float.parseFloat(value));
} else if (type == double.class || type == Double.class) { } else if (type == double.class || type == Double.class) {
if (TextUtils.isEmpty(value)) { if (TextUtils.isEmpty(value)) {
value = "0.0"; value = "0";
} }
field.setDouble(this, Double.parseDouble(value)); field.setDouble(this, Double.parseDouble(value));
} else if (type == long.class || type == Long.class) { } else if (type == long.class || type == Long.class) {
@ -333,7 +333,7 @@ class Configuration {
/** /**
* 设置最大下载速度单位kb, 为0表示不限速 * 设置最大下载速度单位kb, 为0表示不限速
*/ */
int msxSpeed = 0; int maxSpeed = 0;
public DownloadConfig setMaxTaskNum(int maxTaskNum) { public DownloadConfig setMaxTaskNum(int maxTaskNum) {
oldMaxTaskNum = this.maxTaskNum; oldMaxTaskNum = this.maxTaskNum;
@ -347,14 +347,14 @@ class Configuration {
return iOTimeOut; return iOTimeOut;
} }
public int getMsxSpeed() { public int getMaxSpeed() {
return msxSpeed; return maxSpeed;
} }
public DownloadConfig setMsxSpeed(int msxSpeed) { public DownloadConfig setMaxSpeed(int maxSpeed) {
this.msxSpeed = msxSpeed; this.maxSpeed = maxSpeed;
saveKey("msxSpeed", String.valueOf(msxSpeed)); saveKey("maxSpeed", String.valueOf(maxSpeed));
DownloadTaskQueue.getInstance().setMaxSpeed(msxSpeed); DownloadTaskQueue.getInstance().setMaxSpeed(maxSpeed);
return this; return this;
} }

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

Loading…
Cancel
Save