DownloadUtil 重命名为 Aria,代码已重构,使用起来更加简便

pull/2/head
AriaLyy 8 years ago
parent 458dca551f
commit 02420fe1f5
  1. 2
      .idea/gradle.xml
  2. 2
      .idea/modules.xml
  3. 0
      Aria/.gitignore
  4. 2
      Aria/build.gradle
  5. 0
      Aria/jcenter.gradle
  6. 0
      Aria/proguard-rules.pro
  7. 0
      Aria/src/androidTest/java/com/arialyy/downloadutil/ApplicationTest.java
  8. 2
      Aria/src/main/AndroidManifest.xml
  9. 5
      Aria/src/main/java/com/arialyy/aria/core/AMReceiver.java
  10. 23
      Aria/src/main/java/com/arialyy/aria/core/AMTarget.java
  11. 2
      Aria/src/main/java/com/arialyy/aria/core/Aria.java
  12. 18
      Aria/src/main/java/com/arialyy/aria/core/AriaManager.java
  13. 6
      Aria/src/main/java/com/arialyy/aria/core/DownloadEntity.java
  14. 14
      Aria/src/main/java/com/arialyy/aria/core/DownloadManager.java
  15. 6
      Aria/src/main/java/com/arialyy/aria/core/command/AddCmd.java
  16. 7
      Aria/src/main/java/com/arialyy/aria/core/command/CancelCmd.java
  17. 6
      Aria/src/main/java/com/arialyy/aria/core/command/CmdFactory.java
  18. 12
      Aria/src/main/java/com/arialyy/aria/core/command/IDownloadCmd.java
  19. 7
      Aria/src/main/java/com/arialyy/aria/core/command/SingleCmd.java
  20. 7
      Aria/src/main/java/com/arialyy/aria/core/command/StartCmd.java
  21. 7
      Aria/src/main/java/com/arialyy/aria/core/command/StopCmd.java
  22. 16
      Aria/src/main/java/com/arialyy/aria/core/queue/DownloadTaskQueue.java
  23. 4
      Aria/src/main/java/com/arialyy/aria/core/queue/IDownloader.java
  24. 4
      Aria/src/main/java/com/arialyy/aria/core/queue/IPool.java
  25. 8
      Aria/src/main/java/com/arialyy/aria/core/queue/ITaskQueue.java
  26. 8
      Aria/src/main/java/com/arialyy/aria/core/queue/pool/CachePool.java
  27. 8
      Aria/src/main/java/com/arialyy/aria/core/queue/pool/ExecutePool.java
  28. 12
      Aria/src/main/java/com/arialyy/aria/core/scheduler/DownloadSchedulers.java
  29. 5
      Aria/src/main/java/com/arialyy/aria/core/scheduler/IDownloadSchedulers.java
  30. 4
      Aria/src/main/java/com/arialyy/aria/core/scheduler/OnSchedulerListener.java
  31. 2
      Aria/src/main/java/com/arialyy/aria/core/task/DownloadListener.java
  32. 6
      Aria/src/main/java/com/arialyy/aria/core/task/DownloadUtil.java
  33. 2
      Aria/src/main/java/com/arialyy/aria/core/task/IDownloadListener.java
  34. 2
      Aria/src/main/java/com/arialyy/aria/core/task/IDownloadUtil.java
  35. 12
      Aria/src/main/java/com/arialyy/aria/core/task/Task.java
  36. 6
      Aria/src/main/java/com/arialyy/aria/core/task/TaskFactory.java
  37. 4
      Aria/src/main/java/com/arialyy/aria/orm/DbEntity.java
  38. 4
      Aria/src/main/java/com/arialyy/aria/orm/DbUtil.java
  39. 2
      Aria/src/main/java/com/arialyy/aria/orm/Id.java
  40. 2
      Aria/src/main/java/com/arialyy/aria/orm/Ignore.java
  41. 2
      Aria/src/main/java/com/arialyy/aria/orm/SqlHelper.java
  42. 4
      Aria/src/main/java/com/arialyy/aria/util/CheckUtil.java
  43. 8
      Aria/src/main/java/com/arialyy/aria/util/CommonUtil.java
  44. 2
      Aria/src/main/java/com/arialyy/aria/util/PathUtil.java
  45. 0
      Aria/src/main/res/values/strings.xml
  46. 2
      app/build.gradle
  47. 5
      app/src/main/AndroidManifest.xml
  48. 7
      app/src/main/java/com/arialyy/simple/activity/MultiTaskActivity.java
  49. 13
      app/src/main/java/com/arialyy/simple/activity/SingleTaskActivity.java
  50. 24
      app/src/main/java/com/arialyy/simple/adapter/DownloadAdapter.java
  51. 12
      app/src/main/java/com/arialyy/simple/base/BaseActivity.java
  52. 2
      app/src/main/java/com/arialyy/simple/base/BaseApplication.java
  53. 6
      app/src/main/java/com/arialyy/simple/module/DownloadModule.java
  54. 1
      app/src/main/res/layout/activity_single.xml
  55. 20
      app/src/main/res/values-v21/styles.xml
  56. 18
      app/src/main/res/values/styles.xml
  57. 2
      settings.gradle

@ -9,8 +9,8 @@
<option name="modules">
<set>
<option value="$PROJECT_DIR$" />
<option value="$PROJECT_DIR$/Aria" />
<option value="$PROJECT_DIR$/app" />
<option value="$PROJECT_DIR$/downloadutil" />
</set>
</option>
<option name="resolveModulePerSourceSet" value="false" />

@ -2,9 +2,9 @@
<project version="4">
<component name="ProjectModuleManager">
<modules>
<module fileurl="file://$PROJECT_DIR$/Aria/Aria.iml" filepath="$PROJECT_DIR$/Aria/Aria.iml" />
<module fileurl="file://$PROJECT_DIR$/DownloadPrj.iml" filepath="$PROJECT_DIR$/DownloadPrj.iml" />
<module fileurl="file://$PROJECT_DIR$/app/app.iml" filepath="$PROJECT_DIR$/app/app.iml" />
<module fileurl="file://$PROJECT_DIR$/downloadutil/downloadutil.iml" filepath="$PROJECT_DIR$/downloadutil/downloadutil.iml" />
</modules>
</component>
</project>

@ -8,7 +8,7 @@ android {
minSdkVersion 9
targetSdkVersion 23
versionCode 58
versionName "2.1.0"
versionName "2.3.0"
}
buildTypes {
release {

@ -1,5 +1,5 @@
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.arialyy.downloadutil">
package="com.arialyy.aria">
<application
android:allowBackup="true"

@ -13,10 +13,9 @@
* See the License for the specific language governing permissions and
* limitations under the License.
*/
package com.arialyy.downloadutil.core;
package com.arialyy.aria.core;
import android.content.Context;
import com.arialyy.downloadutil.core.scheduler.OnSchedulerListener;
import com.arialyy.aria.core.scheduler.OnSchedulerListener;
/**
* AM 接收器

@ -1,11 +1,10 @@
package com.arialyy.downloadutil.core;
import android.content.Context;
import com.arialyy.downloadutil.core.command.CmdFactory;
import com.arialyy.downloadutil.core.command.IDownloadCmd;
import com.arialyy.downloadutil.core.scheduler.OnSchedulerListener;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.downloadutil.util.CommonUtil;
package com.arialyy.aria.core;
import com.arialyy.aria.core.command.CmdFactory;
import com.arialyy.aria.core.scheduler.OnSchedulerListener;
import com.arialyy.aria.core.command.IDownloadCmd;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.util.CommonUtil;
import java.util.ArrayList;
import java.util.List;
@ -19,6 +18,14 @@ public class AMTarget {
this.receiver = receiver;
}
/**
* 添加任务
*/
public void add() {
receiver.manager.setCmd(
CommonUtil.createCmd(receiver.obj, receiver.entity, CmdFactory.TASK_CREATE)).exe();
}
/**
* 开始下载
*/

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core;
package com.arialyy.aria.core;
import android.annotation.TargetApi;
import android.app.Activity;

@ -1,4 +1,4 @@
package com.arialyy.downloadutil.core;
package com.arialyy.aria.core;
import android.annotation.TargetApi;
import android.app.Activity;
@ -7,9 +7,9 @@ import android.app.Service;
import android.content.Context;
import android.os.Build;
import android.os.Bundle;
import com.arialyy.downloadutil.core.command.CmdFactory;
import com.arialyy.downloadutil.core.command.IDownloadCmd;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.core.command.CmdFactory;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.core.command.IDownloadCmd;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
@ -45,6 +45,16 @@ import java.util.Set;
return getTarget(obj);
}
/**
* 设置同时下载的任务数
*/
public void setDownloadNum(int num){
if (num <= 0){
throw new IllegalArgumentException("下载任务数不能小于1");
}
mManager.getTaskQueue().setDownloadNum(num);
}
/**
* 停止所有正在执行的任务
*/

@ -15,12 +15,12 @@
*/
package com.arialyy.downloadutil.core;
package com.arialyy.aria.core;
import android.os.Parcel;
import android.os.Parcelable;
import com.arialyy.downloadutil.orm.DbEntity;
import com.arialyy.downloadutil.orm.Ignore;
import com.arialyy.aria.orm.Ignore;
import com.arialyy.aria.orm.DbEntity;
/**
* Created by lyy on 2015/12/25.

@ -14,16 +14,14 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core;
package com.arialyy.aria.core;
import android.app.Application;
import android.content.Context;
import android.util.Log;
import com.arialyy.downloadutil.core.command.IDownloadCmd;
import com.arialyy.downloadutil.core.queue.ITaskQueue;
import com.arialyy.downloadutil.core.queue.DownloadTaskQueue;
import com.arialyy.downloadutil.orm.DbEntity;
import com.arialyy.downloadutil.orm.DbUtil;
import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.orm.DbUtil;
import com.arialyy.aria.core.command.IDownloadCmd;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import com.arialyy.aria.orm.DbEntity;
import java.util.ArrayList;
import java.util.List;

@ -14,11 +14,11 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.command;
package com.arialyy.aria.core.command;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/8/22.

@ -15,10 +15,10 @@
*/
package com.arialyy.downloadutil.core.command;
package com.arialyy.aria.core.command;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/9/20.
@ -40,6 +40,7 @@ class CancelCmd extends IDownloadCmd {
task = mQueue.createTask(mTarget, mEntity);
}
if (task != null) {
task.setmTargetName(mTarget.getClass().getName());
mQueue.cancelTask(task);
}
}

@ -14,9 +14,9 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.command;
package com.arialyy.aria.core.command;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.aria.core.DownloadEntity;
/**
* Created by Lyy on 2016/9/23.
@ -152,7 +152,7 @@ public class CmdFactory {
private StartCmd createStartCmd(Object target, DownloadEntity entity) {
return new StartCmd(target, entity);
}
/**
* 创建启动下载命令
*

@ -14,13 +14,13 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.command;
package com.arialyy.aria.core.command;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.DownloadManager;
import com.arialyy.downloadutil.core.queue.ITaskQueue;
import com.arialyy.downloadutil.util.CheckUtil;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.core.DownloadManager;
import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.util.CheckUtil;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.core.DownloadEntity;
/**
* Created by lyy on 2016/8/22.

@ -1,8 +1,8 @@
package com.arialyy.downloadutil.core.command;
package com.arialyy.aria.core.command;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/11/30.
@ -27,6 +27,7 @@ class SingleCmd extends IDownloadCmd {
} else {
Log.w(TAG, "添加命令执行失败,【该任务已经存在】");
}
task.setmTargetName(mTarget.getClass().getName());
mQueue.startTask(task);
}
}

@ -14,10 +14,10 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.command;
package com.arialyy.aria.core.command;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/8/22.
@ -39,6 +39,7 @@ class StartCmd extends IDownloadCmd {
task = mQueue.createTask(mTarget, mEntity);
}
if (task != null) {
task.setmTargetName(mTarget.getClass().getName());
mQueue.startTask(task);
}
}

@ -15,11 +15,11 @@
*/
package com.arialyy.downloadutil.core.command;
package com.arialyy.aria.core.command;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/9/20.
@ -48,6 +48,7 @@ class StopCmd extends IDownloadCmd {
Log.w(TAG, "停止命令执行失败,【调度器中没有该任务】");
}
} else {
task.setmTargetName(mTarget.getClass().getName());
mQueue.stopTask(task);
}
}

@ -14,17 +14,17 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.queue;
package com.arialyy.aria.core.queue;
import android.content.Context;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.queue.pool.CachePool;
import com.arialyy.downloadutil.core.queue.pool.ExecutePool;
import com.arialyy.downloadutil.core.scheduler.DownloadSchedulers;
import com.arialyy.downloadutil.core.scheduler.IDownloadSchedulers;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.downloadutil.core.task.TaskFactory;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.queue.pool.CachePool;
import com.arialyy.aria.core.queue.pool.ExecutePool;
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.task.TaskFactory;
/**
* Created by lyy on 2016/8/17.

@ -15,9 +15,9 @@
*/
package com.arialyy.downloadutil.core.queue;
package com.arialyy.aria.core.queue;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/8/16.

@ -15,9 +15,9 @@
*/
package com.arialyy.downloadutil.core.queue;
package com.arialyy.aria.core.queue;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/8/14.

@ -14,11 +14,11 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.queue;
package com.arialyy.aria.core.queue;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.scheduler.IDownloadSchedulers;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.task.Task;
/**
* Created by lyy on 2016/8/16.

@ -15,13 +15,13 @@
*/
package com.arialyy.downloadutil.core.queue.pool;
package com.arialyy.aria.core.queue.pool;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.downloadutil.core.queue.IPool;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.core.queue.IPool;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.core.task.Task;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.LinkedBlockingQueue;

@ -15,13 +15,13 @@
*/
package com.arialyy.downloadutil.core.queue.pool;
package com.arialyy.aria.core.queue.pool;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.downloadutil.core.queue.IPool;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.aria.core.queue.IPool;
import com.arialyy.aria.core.task.Task;
import java.util.HashMap;
import java.util.Map;
import java.util.concurrent.ArrayBlockingQueue;

@ -14,16 +14,16 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.scheduler;
package com.arialyy.aria.core.scheduler;
import android.os.Message;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.queue.ITaskQueue;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.downloadutil.core.queue.pool.ExecutePool;
import com.arialyy.downloadutil.core.queue.DownloadTaskQueue;
import com.arialyy.aria.core.queue.ITaskQueue;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.core.queue.pool.ExecutePool;
import com.arialyy.aria.core.queue.DownloadTaskQueue;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;

@ -14,11 +14,10 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.scheduler;
package com.arialyy.aria.core.scheduler;
import android.content.Context;
import android.os.Handler;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.aria.core.DownloadEntity;
/**
* Created by AriaLyy@outlook.com on 2016/11/2.

@ -1,6 +1,6 @@
package com.arialyy.downloadutil.core.scheduler;
package com.arialyy.aria.core.scheduler;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.task.Task;
/**
* Target处理任务监听

@ -15,7 +15,7 @@
*/
package com.arialyy.downloadutil.core.task;
package com.arialyy.aria.core.task;
class DownloadListener implements IDownloadListener {

@ -15,13 +15,13 @@
*/
package com.arialyy.downloadutil.core.task;
package com.arialyy.aria.core.task;
import android.content.Context;
import android.util.Log;
import android.util.SparseArray;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.util.CommonUtil;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;

@ -15,7 +15,7 @@
*/
package com.arialyy.downloadutil.core.task;
package com.arialyy.aria.core.task;
/**
* 下载监听

@ -15,7 +15,7 @@
*/
package com.arialyy.downloadutil.core.task;
package com.arialyy.aria.core.task;
/**
* Created by AriaLyy@outlook.com on 2016/10/31.

@ -14,17 +14,17 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.task;
package com.arialyy.aria.core.task;
import android.content.Context;
import android.content.Intent;
import android.net.Uri;
import android.os.Handler;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.DownloadManager;
import com.arialyy.downloadutil.core.scheduler.IDownloadSchedulers;
import com.arialyy.downloadutil.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.DownloadManager;
import com.arialyy.aria.core.scheduler.DownloadSchedulers;
import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.DownloadEntity;
/**
* Created by lyy on 2016/8/11.
@ -156,7 +156,7 @@ public class Task {
}
}
public static class Builder {
static class Builder {
DownloadEntity downloadEntity;
Handler outHandler;
Context context;

@ -14,11 +14,11 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.core.task;
package com.arialyy.aria.core.task;
import android.content.Context;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.scheduler.IDownloadSchedulers;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.scheduler.IDownloadSchedulers;
/**
* Created by lyy on 2016/8/18.

@ -15,10 +15,10 @@
*/
package com.arialyy.downloadutil.orm;
package com.arialyy.aria.orm;
import android.support.annotation.NonNull;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.util.CommonUtil;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.List;

@ -14,7 +14,7 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.orm;
package com.arialyy.aria.orm;
import android.app.Application;
import android.content.Context;
@ -22,7 +22,7 @@ import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;
import android.support.annotation.NonNull;
import android.util.Log;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.util.CommonUtil;
import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Date;

@ -15,7 +15,7 @@
*/
package com.arialyy.downloadutil.orm;
package com.arialyy.aria.orm;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

@ -15,7 +15,7 @@
*/
package com.arialyy.downloadutil.orm;
package com.arialyy.aria.orm;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;

@ -15,7 +15,7 @@
*/
package com.arialyy.downloadutil.orm;
package com.arialyy.aria.orm;
import android.content.Context;
import android.database.sqlite.SQLiteDatabase;

@ -15,11 +15,11 @@
*/
package com.arialyy.downloadutil.util;
package com.arialyy.aria.util;
import android.text.TextUtils;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.aria.core.DownloadEntity;
import java.io.File;
/**

@ -14,12 +14,12 @@
* limitations under the License.
*/
package com.arialyy.downloadutil.util;
package com.arialyy.aria.util;
import android.util.Log;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.command.CmdFactory;
import com.arialyy.downloadutil.core.command.IDownloadCmd;
import com.arialyy.aria.core.command.CmdFactory;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.command.IDownloadCmd;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;

@ -15,7 +15,7 @@
*/
package com.arialyy.downloadutil.util;
package com.arialyy.aria.util;
import android.os.Environment;
import java.security.MessageDigest;

@ -37,5 +37,5 @@ dependencies {
compile 'com.squareup.okhttp3:okhttp:3.2.0'
compile 'com.arialyy.frame:MVVM2:2.2.0'
compile 'com.arialyy.absadapter:AbsAdapter:1.1.2'
compile project(':downloadutil')
compile project(':Aria')
}

@ -12,12 +12,11 @@
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:supportsRtl="true"
android:theme="@style/AppTheme">
android:theme="@style/AppTheme.NoActionBar">
<!--android:name=".activity.SingleTaskActivity"-->
<activity
android:name=".activity.MainActivity"
android:label="@string/app_name"
android:theme="@style/AppTheme.NoActionBar">
android:label="@string/app_name">
<intent-filter>
<action android:name="android.intent.action.MAIN"/>

@ -23,9 +23,9 @@ import android.support.v7.widget.RecyclerView;
import android.support.v7.widget.Toolbar;
import android.view.View;
import butterknife.Bind;
import com.arialyy.downloadutil.core.AMTarget;
import com.arialyy.downloadutil.core.Aria;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.aria.core.AMTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.task.Task;
import com.arialyy.frame.util.show.L;
import com.arialyy.simple.R;
import com.arialyy.simple.adapter.DownloadAdapter;
@ -135,6 +135,7 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
@Override public void onTaskStart(Task task) {
super.onTaskStart(task);
L.d(TAG, "download start");
mAdapter.updateState(task.getDownloadEntity());
}
@Override public void onTaskResume(Task task) {

@ -24,16 +24,15 @@ import android.os.Message;
import android.support.v7.widget.Toolbar;
import android.view.View;
import android.widget.Button;
import android.widget.ProgressBar;
import android.widget.TextView;
import android.widget.Toast;
import butterknife.Bind;
import com.arialyy.downloadutil.core.AMTarget;
import com.arialyy.downloadutil.core.Aria;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.task.Task;
import com.arialyy.downloadutil.orm.DbEntity;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.core.AMTarget;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.task.Task;
import com.arialyy.aria.orm.DbEntity;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.simple.R;
import com.arialyy.simple.base.BaseActivity;
import com.arialyy.simple.databinding.ActivitySingleBinding;

@ -25,16 +25,11 @@ import android.widget.TextView;
import butterknife.Bind;
import com.arialyy.absadapter.common.AbsHolder;
import com.arialyy.absadapter.recycler_view.AbsRVAdapter;
import com.arialyy.downloadutil.core.Aria;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.DownloadManager;
import com.arialyy.downloadutil.core.command.CmdFactory;
import com.arialyy.downloadutil.core.command.IDownloadCmd;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.core.Aria;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.simple.R;
import com.arialyy.simple.widget.HorizontalProgressBarWithNumber;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import java.util.Set;
@ -46,22 +41,16 @@ import java.util.concurrent.ConcurrentHashMap;
*/
public class DownloadAdapter extends AbsRVAdapter<DownloadEntity, DownloadAdapter.MyHolder> {
private static final String TAG = "DownloadAdapter";
private DownloadManager mManager;
private CmdFactory mFactory;
private Map<String, Integer> mPositions = new ConcurrentHashMap<>();
public DownloadAdapter(Context context, List<DownloadEntity> data) {
super(context, data);
mFactory = CmdFactory.getInstance();
mManager = DownloadManager.getInstance();
List<IDownloadCmd> addCmd = new ArrayList<>();
int i = 0;
for (DownloadEntity entity : data) {
mPositions.put(entity.getDownloadUrl(), i);
addCmd.add(mFactory.createCmd(entity, CmdFactory.TASK_CREATE));
Aria.whit(getContext()).load(entity).add();
i++;
}
mManager.setCmds(addCmd).exe();
}
@Override protected MyHolder getViewHolder(View convertView, int viewType) {
@ -152,14 +141,13 @@ public class DownloadAdapter extends AbsRVAdapter<DownloadEntity, DownloadAdapte
@Override public void onClick(View v) {
mData.remove(item);
notifyDataSetChanged();
IDownloadCmd cancelCmd = mFactory.createCmd(item, CmdFactory.TASK_CANCEL);
mManager.setCmd(cancelCmd).exe();
Aria.whit(getContext()).load(item).cancel();
}
});
}
public void setDownloadNum(int num) {
mManager.getTaskQueue().setDownloadNum(num);
Aria.get(getContext()).setDownloadNum(num);
}
private String covertCurrentSize(long currentSize) {

@ -14,17 +14,27 @@
* limitations under the License.
*/
package com.arialyy.simple.base;
import android.databinding.ViewDataBinding;
import android.os.Bundle;
import android.os.PersistableBundle;
import com.arialyy.frame.core.AbsActivity;
import com.arialyy.frame.util.AndroidVersionUtil;
import com.arialyy.simple.R;
/**
* Created by Lyy on 2016/9/27.
*/
public abstract class BaseActivity<VB extends ViewDataBinding> extends AbsActivity<VB> {
@Override protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
if (AndroidVersionUtil.hasLollipop()) {
getWindow().setStatusBarColor(getResources().getColor(R.color.colorPrimaryDark));
}
}
@Override protected void dataCallback(int result, Object data) {
}

@ -18,7 +18,7 @@
package com.arialyy.simple.base;
import android.app.Application;
import com.arialyy.downloadutil.core.DownloadManager;
import com.arialyy.aria.core.DownloadManager;
import com.arialyy.frame.core.AbsFrame;
/**

@ -22,9 +22,9 @@ import android.content.Intent;
import android.content.IntentFilter;
import android.os.Environment;
import android.os.Handler;
import com.arialyy.downloadutil.core.DownloadEntity;
import com.arialyy.downloadutil.core.DownloadManager;
import com.arialyy.downloadutil.util.CommonUtil;
import com.arialyy.aria.core.DownloadEntity;
import com.arialyy.aria.core.DownloadManager;
import com.arialyy.aria.util.CommonUtil;
import com.arialyy.frame.util.AndroidUtils;
import com.arialyy.frame.util.StringUtil;
import com.arialyy.frame.util.show.L;

@ -12,7 +12,6 @@
<android.support.design.widget.AppBarLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:theme="@style/AppTheme.AppBarOverlay"
>
<include layout="@layout/layout_bar"/>

@ -1,16 +1,16 @@
<resources>
<style name="AppTheme.NoActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="android:windowDrawsSystemBarBackgrounds">true</item>
<item name="android:statusBarColor">@android:color/transparent</item>
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
</style>
<!--<style name="AppTheme.NoActionBar">-->
<!--<item name="windowActionBar">false</item>-->
<!--<item name="windowNoTitle">true</item>-->
<!--<item name="android:windowDrawsSystemBarBackgrounds">true</item>-->
<!--<item name="android:statusBarColor">@android:color/transparent</item>-->
<!--<item name="colorPrimary">@color/colorPrimary</item>-->
<!--<item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
<!--<item name="colorAccent">@color/colorAccent</item>-->
<!--</style>-->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>

@ -1,16 +1,16 @@
<resources>
<!-- Base application theme. -->
<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">
<!-- Customize your theme here. -->
<item name="colorPrimary">@color/colorPrimary</item>
<item name="colorPrimaryDark">@color/colorPrimaryDark</item>
<item name="colorAccent">@color/colorAccent</item>
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
</style>
<!--<style name="AppTheme" parent="Theme.AppCompat.Light.DarkActionBar">-->
<!--&lt;!&ndash; Customize your theme here. &ndash;&gt;-->
<!--<item name="colorPrimary">@color/colorPrimary</item>-->
<!--<item name="colorPrimaryDark">@color/colorPrimaryDark</item>-->
<!--<item name="colorAccent">@color/colorAccent</item>-->
<!--<item name="windowActionBar">false</item>-->
<!--<item name="windowNoTitle">true</item>-->
<!--</style>-->
<style name="AppTheme.NoActionBar">
<style name="AppTheme.NoActionBar" parent="Theme.AppCompat.Light.DarkActionBar">
<item name="windowActionBar">false</item>
<item name="windowNoTitle">true</item>
<item name="colorPrimary">@color/colorPrimary</item>

@ -1 +1 @@
include ':app', ':downloadutil'
include ':app', ':Aria'

Loading…
Cancel
Save