jcenter
This commit is contained in:
@ -1,4 +1,5 @@
|
||||
apply plugin: 'com.android.library'
|
||||
apply plugin: 'bintray-release'
|
||||
|
||||
android {
|
||||
compileSdkVersion 23
|
||||
@ -22,6 +23,53 @@ dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
testCompile 'junit:junit:4.12'
|
||||
compile 'com.android.support:appcompat-v7:23.1.1'
|
||||
compile project(':AriaCompiler')
|
||||
// compile project(':AriaCompiler')
|
||||
compile project(':AriaAnnotations')
|
||||
}
|
||||
apply from: 'jcenter.gradle'
|
||||
//apply from: 'jcenter.gradle'
|
||||
|
||||
// Jar
|
||||
task androidJar(type: Jar) {
|
||||
dependsOn assemble
|
||||
group 'Build'
|
||||
description 'blah blah'
|
||||
from zipTree(
|
||||
'build/intermediates/bundles/release/classes.jar')
|
||||
from zipTree(
|
||||
'../AriaCompiler/build/libs/AriaCompiler.jar')
|
||||
from zipTree(
|
||||
'../AriaAnnotation/build/libs/AriaAnnotation.jar')
|
||||
|
||||
}
|
||||
|
||||
|
||||
// javadoc tasks
|
||||
android.libraryVariants.all { variant ->
|
||||
task("javadoc${variant.name.capitalize()}", type: Javadoc) {
|
||||
description "Generates Javadoc for $variant.name."
|
||||
group 'Docs'
|
||||
source = variant.javaCompile.source
|
||||
source "../AriaAnnotation/src/main/java"
|
||||
|
||||
exclude '**/BuildConfig.java'
|
||||
exclude '**/R.java'
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
publish {
|
||||
artifactId = 'Aria'
|
||||
userOrg = rootProject.userOrg
|
||||
groupId = rootProject.groupId
|
||||
uploadName = rootProject.uploadName
|
||||
publishVersion = rootProject.publishVersion
|
||||
description = rootProject.description
|
||||
website = rootProject.website
|
||||
licences = rootProject.licences
|
||||
}
|
||||
|
||||
//task copyJar(type: Copy) {
|
||||
// from('build/libs/permission-lib.jar')
|
||||
// into('../output/')
|
||||
// rename ('permission-lib.jar', 'mpermissions.jar')
|
||||
//}
|
||||
|
@ -62,8 +62,11 @@ public class DownloadReceiver implements IReceiver<DownloadEntity> {
|
||||
|
||||
/**
|
||||
* 添加调度器回调
|
||||
*
|
||||
* @see #register()
|
||||
*/
|
||||
public DownloadReceiver addSchedulerListener(ISchedulerListener<DownloadTask> listener) {
|
||||
@Deprecated public DownloadReceiver addSchedulerListener(
|
||||
ISchedulerListener<DownloadTask> listener) {
|
||||
this.listener = listener;
|
||||
DownloadSchedulers.getInstance().addSchedulerListener(targetName, listener);
|
||||
return this;
|
||||
@ -80,15 +83,16 @@ public class DownloadReceiver implements IReceiver<DownloadEntity> {
|
||||
/**
|
||||
* 取消注册
|
||||
*/
|
||||
@Override
|
||||
public void unRegister() {
|
||||
@Override public void unRegister() {
|
||||
DownloadSchedulers.getInstance().unRegister(obj);
|
||||
}
|
||||
|
||||
/**
|
||||
* 移除回调
|
||||
*
|
||||
* @see #unRegister()
|
||||
*/
|
||||
@Override public void removeSchedulerListener() {
|
||||
@Deprecated @Override public void removeSchedulerListener() {
|
||||
if (listener != null) {
|
||||
DownloadSchedulers.getInstance().removeSchedulerListener(targetName, listener);
|
||||
}
|
||||
|
@ -26,7 +26,6 @@ import com.arialyy.aria.core.inf.IEntity;
|
||||
import com.arialyy.aria.core.inf.ITask;
|
||||
import com.arialyy.aria.core.queue.ITaskQueue;
|
||||
import com.arialyy.aria.core.upload.UploadTask;
|
||||
import com.arialyy.compiler.ProxyConstance;
|
||||
import java.util.Iterator;
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
@ -39,6 +38,16 @@ public abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY ex
|
||||
implements ISchedulers<TASK> {
|
||||
private static final String TAG = "AbsSchedulers";
|
||||
|
||||
/**
|
||||
* 下载的动态生成的代理类后缀
|
||||
*/
|
||||
String DOWNLOAD_PROXY_CLASS_SUFFIX = "$$DownloadListenerProxy";
|
||||
|
||||
/**
|
||||
* 上传的动态生成的代理类后缀
|
||||
*/
|
||||
String UPLOAD_PROXY_CLASS_SUFFIX = "$$UploadListenerProxy";
|
||||
|
||||
protected QUEUE mQueue;
|
||||
protected boolean isDownload = true;
|
||||
|
||||
@ -97,8 +106,7 @@ public abstract class AbsSchedulers<TASK_ENTITY extends AbsTaskEntity, ENTITY ex
|
||||
AbsSchedulerListener<TASK> listener = null;
|
||||
try {
|
||||
Class clazz = Class.forName(
|
||||
targetName + (isDownload ? ProxyConstance.DOWNLOAD_PROXY_CLASS_SUFFIX
|
||||
: ProxyConstance.UPLOAD_PROXY_CLASS_SUFFIX));
|
||||
targetName + (isDownload ? DOWNLOAD_PROXY_CLASS_SUFFIX : UPLOAD_PROXY_CLASS_SUFFIX));
|
||||
listener = (AbsSchedulerListener<TASK>) clazz.newInstance();
|
||||
} catch (ClassNotFoundException e) {
|
||||
Log.e(TAG, targetName + ",没有Aria的Download或Upload注解方法");
|
||||
|
@ -1,12 +1,24 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'bintray-release'
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
dependencies {
|
||||
compile fileTree(dir: 'libs', include: ['*.jar'])
|
||||
}
|
||||
|
||||
sourceCompatibility = "1.7"
|
||||
targetCompatibility = "1.7"
|
||||
publish {
|
||||
artifactId = 'aria-annotations'
|
||||
userOrg = rootProject.userOrg
|
||||
groupId = rootProject.groupId
|
||||
uploadName = rootProject.uploadName
|
||||
publishVersion = rootProject.publishVersion
|
||||
description = rootProject.description
|
||||
website = rootProject.website
|
||||
licences = rootProject.licences
|
||||
}
|
@ -22,7 +22,16 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Created by Aria.Lao on 2017/6/6.
|
||||
* 下载注解
|
||||
* Aria下载事件被注解的方法中,参数仅能有一个,参数类型为{@link com.arialyy.aria.core.download.DownloadTask}
|
||||
* <pre>
|
||||
* <code>
|
||||
* protected void onPre(DownloadTask task) {
|
||||
* if (task.getKey().equals(DOWNLOAD_URL)) {
|
||||
* mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize()).sendToTarget();
|
||||
* }
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
@Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) public @interface Download {
|
||||
/**
|
||||
@ -43,9 +52,6 @@ import java.lang.annotation.Target;
|
||||
@Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) public @interface onTaskResume {
|
||||
}
|
||||
|
||||
/**
|
||||
* 如果你在方法中添加{@code @Download.onTaskStart}注解,在任务开始下载时,Aria会调用该方法
|
||||
*/
|
||||
@Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) public @interface onTaskStart {
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,14 @@ import java.lang.annotation.Target;
|
||||
|
||||
/**
|
||||
* Created by lyy on 2017/6/6.
|
||||
* Aria下载事件注解
|
||||
* Aria下载事件被注解的方法中,参数仅能有一个,参数类型为{@link com.arialyy.aria.core.upload.UploadTask}
|
||||
* <pre>
|
||||
* <code>
|
||||
* protected void onPre(UploadTask task) {
|
||||
* L.d(TAG, "fileSize = " + task.getConvertFileSize());
|
||||
* }
|
||||
* </code>
|
||||
* </pre>
|
||||
*/
|
||||
@Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) public @interface Upload {
|
||||
|
||||
@ -44,9 +51,6 @@ import java.lang.annotation.Target;
|
||||
//@Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) public @interface onTaskResume {
|
||||
//}
|
||||
|
||||
/**
|
||||
* 如果你在方法中添加{@code @Upload.onTaskStart}注解,在任务开始下载时,Aria会调用该方法
|
||||
*/
|
||||
@Retention(RetentionPolicy.CLASS) @Target(ElementType.METHOD) public @interface onTaskStart {
|
||||
}
|
||||
|
||||
|
@ -1,8 +1,11 @@
|
||||
apply plugin: 'java'
|
||||
apply plugin: 'bintray-release'
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
options.encoding = "UTF-8"
|
||||
}
|
||||
sourceCompatibility = JavaVersion.VERSION_1_7
|
||||
targetCompatibility = JavaVersion.VERSION_1_7
|
||||
|
||||
dependencies {
|
||||
compile fileTree(include: ['*.jar'], dir: 'libs')
|
||||
@ -10,9 +13,15 @@ dependencies {
|
||||
compile 'com.google.auto.service:auto-service:1.0-rc2'
|
||||
compile 'com.squareup:javapoet:1.9.0'
|
||||
compile project(':AriaAnnotations')
|
||||
|
||||
sourceCompatibility = "1.7"
|
||||
targetCompatibility = "1.7"
|
||||
}
|
||||
|
||||
|
||||
publish {
|
||||
artifactId = 'aria-compiler'
|
||||
userOrg = rootProject.userOrg
|
||||
groupId = rootProject.groupId
|
||||
uploadName = rootProject.uploadName
|
||||
publishVersion = rootProject.publishVersion
|
||||
description = rootProject.description
|
||||
website = rootProject.website
|
||||
licences = rootProject.licences
|
||||
}
|
@ -7,7 +7,7 @@
|
||||
<!--设置下载线程,线程下载数改变后,新的下载任务才会生效-->
|
||||
<threadNum value="4"/>
|
||||
|
||||
<!--是否打开下载广播,默认为false-->
|
||||
<!--是否打开下载广播,默认为false,不建议使用广播,你可以使用Download注解来实现事件回调-->
|
||||
<openBroadcast value="false"/>
|
||||
|
||||
<!--设置下载队列最大任务数, 默认为2-->
|
||||
@ -37,7 +37,7 @@
|
||||
</download>
|
||||
|
||||
<upload>
|
||||
<!--是否打开上传广播,默认为false-->
|
||||
<!--是否打开上传广播,默认为false,不建议使用广播,你可以使用Upload注解来实现事件回调-->
|
||||
<openBroadcast value="false"/>
|
||||
|
||||
<!--设置上传队列最大任务数, 默认为2-->
|
||||
|
@ -23,6 +23,7 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.download.DownloadTarget;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
@ -61,7 +62,7 @@ public class DownloadDialog extends AbsDialog {
|
||||
int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
|
||||
mPb.setProgress(p);
|
||||
}
|
||||
Aria.download(this).addSchedulerListener(new MyDialogDownloadCallback());
|
||||
Aria.download(this).register();
|
||||
DownloadEntity entity = Aria.download(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
if (entity != null) {
|
||||
mSize.setText(CommonUtil.formatFileSize(entity.getFileSize()));
|
||||
@ -89,6 +90,29 @@ public class DownloadDialog extends AbsDialog {
|
||||
}
|
||||
}
|
||||
|
||||
@Download.onTaskPre public void onTaskPre(DownloadTask task) {
|
||||
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
|
||||
setBtState(false);
|
||||
}
|
||||
|
||||
@Download.onTaskStop public void onTaskStop(DownloadTask task) {
|
||||
setBtState(true);
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
|
||||
@Download.onTaskCancel public void onTaskCancel(DownloadTask task) {
|
||||
setBtState(true);
|
||||
mPb.setProgress(0);
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
|
||||
@Download.onTaskRunning public void onTaskRunning(DownloadTask task) {
|
||||
if (task.getKey().equals(DOWNLOAD_URL)) {
|
||||
mPb.setProgress(task.getPercent());
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected void dataCallback(int result, Object obj) {
|
||||
|
||||
}
|
||||
@ -98,34 +122,4 @@ public class DownloadDialog extends AbsDialog {
|
||||
mCancel.setEnabled(!startEnable);
|
||||
mStop.setEnabled(!startEnable);
|
||||
}
|
||||
|
||||
private class MyDialogDownloadCallback extends Aria.DownloadSchedulerListener {
|
||||
|
||||
@Override public void onTaskPre(DownloadTask task) {
|
||||
super.onTaskPre(task);
|
||||
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
|
||||
setBtState(false);
|
||||
}
|
||||
|
||||
@Override public void onTaskStop(DownloadTask task) {
|
||||
super.onTaskStop(task);
|
||||
setBtState(true);
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
|
||||
@Override public void onTaskCancel(DownloadTask task) {
|
||||
super.onTaskCancel(task);
|
||||
setBtState(true);
|
||||
mPb.setProgress(0);
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
|
||||
@Override public void onTaskRunning(DownloadTask task) {
|
||||
super.onTaskRunning(task);
|
||||
if (task.getKey().equals(DOWNLOAD_URL)) {
|
||||
mPb.setProgress(task.getPercent());
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -25,6 +25,7 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.download.DownloadTarget;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
@ -63,7 +64,7 @@ public class DownloadPopupWindow extends AbsPopupWindow {
|
||||
int p = (int) (target.getCurrentProgress() * 100 / target.getFileSize());
|
||||
mPb.setProgress(p);
|
||||
}
|
||||
Aria.download(this).addSchedulerListener(new MyDialogDownloadCallback());
|
||||
Aria.download(this).register();
|
||||
DownloadEntity entity = Aria.download(this).getDownloadEntity(DOWNLOAD_URL);
|
||||
if (entity != null) {
|
||||
mSize.setText(CommonUtil.formatFileSize(entity.getFileSize()));
|
||||
@ -101,37 +102,30 @@ public class DownloadPopupWindow extends AbsPopupWindow {
|
||||
mStop.setEnabled(!startEnable);
|
||||
}
|
||||
|
||||
private class MyDialogDownloadCallback extends Aria.DownloadSchedulerListener {
|
||||
@Download.onTaskPre public void onTaskPre(DownloadTask task) {
|
||||
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
|
||||
setBtState(false);
|
||||
}
|
||||
|
||||
@Override public void onTaskPre(DownloadTask task) {
|
||||
super.onTaskPre(task);
|
||||
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
|
||||
setBtState(false);
|
||||
}
|
||||
@Download.onTaskStop public void onTaskStop(DownloadTask task) {
|
||||
setBtState(true);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
|
||||
@Override public void onTaskStop(DownloadTask task) {
|
||||
super.onTaskStop(task);
|
||||
setBtState(true);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
@Download.onTaskCancel public void onTaskCancel(DownloadTask task) {
|
||||
setBtState(true);
|
||||
mPb.setProgress(0);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
|
||||
@Override public void onTaskCancel(DownloadTask task) {
|
||||
super.onTaskCancel(task);
|
||||
setBtState(true);
|
||||
@Download.onTaskRunning public void onTaskRunning(DownloadTask task) {
|
||||
long current = task.getCurrentProgress();
|
||||
long len = task.getFileSize();
|
||||
if (len == 0) {
|
||||
mPb.setProgress(0);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
|
||||
@Override public void onTaskRunning(DownloadTask task) {
|
||||
super.onTaskRunning(task);
|
||||
long current = task.getCurrentProgress();
|
||||
long len = task.getFileSize();
|
||||
if (len == 0) {
|
||||
mPb.setProgress(0);
|
||||
} else {
|
||||
mPb.setProgress((int) ((current * 100) / len));
|
||||
}
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
} else {
|
||||
mPb.setProgress((int) ((current * 100) / len));
|
||||
}
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
}
|
||||
|
@ -72,15 +72,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
@Bind(R.id.size) TextView mSize;
|
||||
@Bind(R.id.speed) TextView mSpeed;
|
||||
@Bind(R.id.speeds) RadioGroup mRg;
|
||||
private DownloadEntity mEntity;
|
||||
private BroadcastReceiver mReceiver = new BroadcastReceiver() {
|
||||
@Override public void onReceive(Context context, Intent intent) {
|
||||
String action = intent.getAction();
|
||||
if (action.equals(Aria.ACTION_START)) {
|
||||
L.d("START");
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
private Handler mUpdateHandler = new Handler() {
|
||||
@Override public void handleMessage(Message msg) {
|
||||
@ -133,6 +124,11 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
}
|
||||
};
|
||||
|
||||
@Override protected void onCreate(Bundle savedInstanceState) {
|
||||
super.onCreate(savedInstanceState);
|
||||
Aria.download(this).register();
|
||||
}
|
||||
|
||||
/**
|
||||
* 设置start 和 stop 按钮状态
|
||||
*/
|
||||
@ -141,13 +137,6 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
mStop.setEnabled(!state);
|
||||
}
|
||||
|
||||
@Override protected void onResume() {
|
||||
super.onResume();
|
||||
Aria.download(this).register();
|
||||
//Aria.download(this).addSchedulerListener(new MySchedulerListener());
|
||||
//registerReceiver(mReceiver, getModule(DownloadModule.class).getDownloadFilter());
|
||||
}
|
||||
|
||||
@Override public boolean onCreateOptionsMenu(Menu menu) {
|
||||
getMenuInflater().inflate(R.menu.menu_single_task_activity, menu);
|
||||
return super.onCreateOptionsMenu(menu);
|
||||
|
@ -23,6 +23,7 @@ import android.widget.Button;
|
||||
import android.widget.TextView;
|
||||
import butterknife.Bind;
|
||||
import butterknife.OnClick;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.download.DownloadTarget;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadEntity;
|
||||
@ -61,11 +62,7 @@ public class DownloadFragment extends AbsFragment<FragmentDownloadBinding> {
|
||||
} else {
|
||||
setBtState(true);
|
||||
}
|
||||
}
|
||||
|
||||
@Override public void onResume() {
|
||||
super.onResume();
|
||||
Aria.download(this).addSchedulerListener(new DownloadFragment.MyDialogDownloadCallback());
|
||||
Aria.download(this).register();
|
||||
}
|
||||
|
||||
@OnClick({ R.id.start, R.id.stop, R.id.cancel }) public void onClick(View view) {
|
||||
@ -85,6 +82,33 @@ public class DownloadFragment extends AbsFragment<FragmentDownloadBinding> {
|
||||
}
|
||||
}
|
||||
|
||||
@Download.onTaskPre public void onTaskPre(DownloadTask task) {
|
||||
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
|
||||
setBtState(false);
|
||||
}
|
||||
|
||||
@Download.onTaskStop public void onTaskStop(DownloadTask task) {
|
||||
setBtState(true);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
|
||||
@Download.onTaskCancel public void onTaskCancel(DownloadTask task) {
|
||||
setBtState(true);
|
||||
mPb.setProgress(0);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
|
||||
@Download.onTaskRunning public void onTaskRunning(DownloadTask task) {
|
||||
long current = task.getCurrentProgress();
|
||||
long len = task.getFileSize();
|
||||
if (len == 0) {
|
||||
mPb.setProgress(0);
|
||||
} else {
|
||||
mPb.setProgress((int) ((current * 100) / len));
|
||||
}
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
|
||||
@Override protected void onDelayLoad() {
|
||||
|
||||
}
|
||||
@ -102,38 +126,4 @@ public class DownloadFragment extends AbsFragment<FragmentDownloadBinding> {
|
||||
mCancel.setEnabled(!startEnable);
|
||||
mStop.setEnabled(!startEnable);
|
||||
}
|
||||
|
||||
private class MyDialogDownloadCallback extends Aria.DownloadSchedulerListener {
|
||||
|
||||
@Override public void onTaskPre(DownloadTask task) {
|
||||
super.onTaskPre(task);
|
||||
mSize.setText(CommonUtil.formatFileSize(task.getFileSize()));
|
||||
setBtState(false);
|
||||
}
|
||||
|
||||
@Override public void onTaskStop(DownloadTask task) {
|
||||
super.onTaskStop(task);
|
||||
setBtState(true);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
|
||||
@Override public void onTaskCancel(DownloadTask task) {
|
||||
super.onTaskCancel(task);
|
||||
setBtState(true);
|
||||
mPb.setProgress(0);
|
||||
mSpeed.setText("0.0kb/s");
|
||||
}
|
||||
|
||||
@Override public void onTaskRunning(DownloadTask task) {
|
||||
super.onTaskRunning(task);
|
||||
long current = task.getCurrentProgress();
|
||||
long len = task.getFileSize();
|
||||
if (len == 0) {
|
||||
mPb.setProgress(0);
|
||||
} else {
|
||||
mPb.setProgress((int) ((current * 100) / len));
|
||||
}
|
||||
mSpeed.setText(task.getConvertSpeed());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,6 +47,7 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
Aria.download(this).register();
|
||||
setTitle("下载列表");
|
||||
List<DownloadEntity> temps = Aria.download(this).getTaskList();
|
||||
if (temps != null && !temps.isEmpty()) {
|
||||
@ -57,12 +58,6 @@ public class MultiDownloadActivity extends BaseActivity<ActivityMultiDownloadBin
|
||||
mList.setAdapter(mAdapter);
|
||||
}
|
||||
|
||||
@Override protected void onResume() {
|
||||
super.onResume();
|
||||
//Aria.download(this).addSchedulerListener(new MySchedulerListener());
|
||||
Aria.download(this).register();
|
||||
}
|
||||
|
||||
@Download.onPre void onPre(DownloadTask task) {
|
||||
L.d(TAG, "download onPre");
|
||||
mAdapter.updateState(task.getDownloadEntity());
|
||||
|
@ -50,6 +50,7 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
Aria.download(this).register();
|
||||
setTitle("多任务下载");
|
||||
mData.addAll(getModule(DownloadModule.class).createMultiTestList());
|
||||
mAdapter = new FileListAdapter(this, mData);
|
||||
@ -72,11 +73,6 @@ public class MultiTaskActivity extends BaseActivity<ActivityMultiBinding> {
|
||||
}
|
||||
}
|
||||
|
||||
@Override protected void onResume() {
|
||||
super.onResume();
|
||||
Aria.download(this).register();
|
||||
}
|
||||
|
||||
@Download.onTaskStart void taskStart(DownloadTask task) {
|
||||
mAdapter.updateBtState(task.getKey(), false);
|
||||
}
|
||||
|
@ -20,6 +20,7 @@ import android.content.Intent;
|
||||
import android.os.Environment;
|
||||
import android.os.IBinder;
|
||||
import android.support.annotation.Nullable;
|
||||
import com.arialyy.annotations.Download;
|
||||
import com.arialyy.aria.core.Aria;
|
||||
import com.arialyy.aria.core.download.DownloadTask;
|
||||
import com.arialyy.frame.util.show.T;
|
||||
@ -45,7 +46,7 @@ public class DownloadService extends Service {
|
||||
@Override public void onCreate() {
|
||||
super.onCreate();
|
||||
mNotify = new DownloadNotification(getApplicationContext());
|
||||
Aria.download(this).addSchedulerListener(new MySchedulerListener());
|
||||
Aria.download(this).register();
|
||||
Aria.download(this)
|
||||
.load(DOWNLOAD_URL)
|
||||
.setDownloadPath(Environment.getExternalStorageDirectory().getPath() + "/service_task.apk")
|
||||
@ -54,45 +55,37 @@ public class DownloadService extends Service {
|
||||
|
||||
@Override public void onDestroy() {
|
||||
super.onDestroy();
|
||||
Aria.download(this).removeSchedulerListener();
|
||||
Aria.download(this).unRegister();
|
||||
}
|
||||
|
||||
private class MySchedulerListener extends Aria.DownloadSchedulerListener {
|
||||
@Download.onNoSupportBreakPoint public void onNoSupportBreakPoint(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), "该下载链接不支持断点");
|
||||
}
|
||||
|
||||
@Override public void onNoSupportBreakPoint(DownloadTask task) {
|
||||
super.onNoSupportBreakPoint(task);
|
||||
T.showShort(getApplicationContext(), "该下载链接不支持断点");
|
||||
}
|
||||
@Download.onTaskStart public void onTaskStart(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",开始下载");
|
||||
}
|
||||
|
||||
@Override public void onTaskStart(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",开始下载");
|
||||
}
|
||||
@Download.onTaskStop public void onTaskStop(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",停止下载");
|
||||
}
|
||||
|
||||
@Override public void onTaskResume(DownloadTask task) {
|
||||
super.onTaskResume(task);
|
||||
}
|
||||
@Download.onTaskCancel public void onTaskCancel(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",取消下载");
|
||||
}
|
||||
|
||||
@Override public void onTaskStop(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",停止下载");
|
||||
}
|
||||
@Download.onTaskFail public void onTaskFail(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",下载失败");
|
||||
}
|
||||
|
||||
@Override public void onTaskCancel(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",取消下载");
|
||||
}
|
||||
@Download.onTaskComplete public void onTaskComplete(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",下载完成");
|
||||
mNotify.upload(100);
|
||||
}
|
||||
|
||||
@Override public void onTaskFail(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",下载失败");
|
||||
}
|
||||
|
||||
@Override public void onTaskComplete(DownloadTask task) {
|
||||
T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",下载完成");
|
||||
mNotify.upload(100);
|
||||
}
|
||||
|
||||
@Override public void onTaskRunning(DownloadTask task) {
|
||||
long len = task.getFileSize();
|
||||
int p = (int) (task.getCurrentProgress() * 100 / len);
|
||||
mNotify.upload(p);
|
||||
}
|
||||
@Download.onTaskRunning public void onTaskRunning(DownloadTask task) {
|
||||
long len = task.getFileSize();
|
||||
int p = (int) (task.getCurrentProgress() * 100 / len);
|
||||
mNotify.upload(p);
|
||||
}
|
||||
}
|
||||
|
@ -79,6 +79,7 @@ public class UploadActivity extends BaseActivity<ActivityUploadMeanBinding> {
|
||||
|
||||
@Override protected void init(Bundle savedInstanceState) {
|
||||
super.init(savedInstanceState);
|
||||
Aria.upload(this).register();
|
||||
}
|
||||
|
||||
@OnClick(R.id.upload) void upload() {
|
||||
@ -97,12 +98,6 @@ public class UploadActivity extends BaseActivity<ActivityUploadMeanBinding> {
|
||||
Aria.upload(this).load(FILE_PATH).cancel();
|
||||
}
|
||||
|
||||
@Override protected void onResume() {
|
||||
super.onResume();
|
||||
//Aria.upload(this).addSchedulerListener(new UploadListener(mHandler));
|
||||
Aria.upload(this).register();
|
||||
}
|
||||
|
||||
@Upload.onPre public void onPre(UploadTask task) {
|
||||
}
|
||||
|
||||
|
52
build.gradle
52
build.gradle
@ -1,27 +1,45 @@
|
||||
// Top-level build file where you can add configuration options common to all sub-projects/modules.
|
||||
|
||||
buildscript {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
|
||||
classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||
classpath 'com.neenbedankt.gradle.plugins:android-apt:1.4'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
dependencies {
|
||||
classpath 'com.android.tools.build:gradle:2.2.2'
|
||||
classpath 'com.novoda:bintray-release:0.5.0'
|
||||
// classpath 'com.jfrog.bintray.gradle:gradle-bintray-plugin:1.7'
|
||||
// classpath 'com.github.dcendents:android-maven-gradle-plugin:1.5'
|
||||
// NOTE: Do not place your application dependencies here; they belong
|
||||
// in the individual module build.gradle files
|
||||
}
|
||||
}
|
||||
|
||||
allprojects {
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
repositories {
|
||||
jcenter()
|
||||
mavenCentral()
|
||||
}
|
||||
|
||||
tasks.withType(Javadoc) {
|
||||
options {
|
||||
encoding "UTF-8"
|
||||
charSet 'UTF-8'
|
||||
links "http://docs.oracle.com/javase/7/docs/api"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
task clean(type: Delete) {
|
||||
delete rootProject.buildDir
|
||||
delete rootProject.buildDir
|
||||
}
|
||||
|
||||
ext {
|
||||
userOrg = 'arialyy'
|
||||
groupId = 'com.arialyy.aria'
|
||||
uploadName = 'AriaPre'
|
||||
publishVersion = '0.0.1'
|
||||
repoName='maven'
|
||||
desc = 'android 下载框架'
|
||||
website = 'https://github.com/AriaLyy/Aria'
|
||||
licences = ['Apache-2.0']
|
||||
}
|
||||
|
0
cache/build/mPro.properties
vendored
0
cache/build/mPro.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
2
gradle/wrapper/gradle-wrapper.properties
vendored
@ -3,4 +3,4 @@ distributionBase=GRADLE_USER_HOME
|
||||
distributionPath=wrapper/dists
|
||||
zipStoreBase=GRADLE_USER_HOME
|
||||
zipStorePath=wrapper/dists
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-2.14.1-all.zip
|
||||
distributionUrl=https\://services.gradle.org/distributions/gradle-3.5-all.zip
|
||||
|
Reference in New Issue
Block a user