From 266c7145354ab59ee70f530c924883f9a38faec1 Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Thu, 8 Jun 2017 18:05:27 +0800 Subject: [PATCH] jcenter --- Aria/build.gradle | 52 +++++++++++++- .../aria/core/download/DownloadReceiver.java | 12 ++-- .../aria/core/scheduler/AbsSchedulers.java | 14 +++- AriaAnnotations/build.gradle | 16 ++++- .../com/arialyy/annotations/Download.java | 14 ++-- .../java/com/arialyy/annotations/Upload.java | 12 ++-- AriaCompiler/build.gradle | 17 +++-- app/src/main/assets/aria_config.xml | 4 +- .../simple/download/DownloadDialog.java | 54 +++++++-------- .../simple/download/DownloadPopupWindow.java | 50 ++++++-------- .../simple/download/SingleTaskActivity.java | 21 ++---- .../fragment_download/DownloadFragment.java | 68 ++++++++----------- .../multi_download/MultiDownloadActivity.java | 7 +- .../multi_download/MultiTaskActivity.java | 6 +- .../service_download/DownloadService.java | 59 +++++++--------- .../arialyy/simple/upload/UploadActivity.java | 7 +- {Aria => aria}/src/main/AndroidManifest.xml | 0 .../com/arialyy/aria/core/Configuration.java | 0 .../core/scheduler/AbsSchedulerListener.java | 0 .../arialyy/aria/core/upload/UploadTask.java | 0 .../aria/core/upload/UploadTaskEntity.java | 0 .../arialyy/aria/exception/FileException.java | 0 build.gradle | 52 +++++++++----- cache/build/mPro.properties | 0 gradle/wrapper/gradle-wrapper.properties | 2 +- 25 files changed, 261 insertions(+), 206 deletions(-) rename {Aria => aria}/src/main/AndroidManifest.xml (100%) rename {Aria => aria}/src/main/java/com/arialyy/aria/core/Configuration.java (100%) rename {Aria => aria}/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulerListener.java (100%) rename {Aria => aria}/src/main/java/com/arialyy/aria/core/upload/UploadTask.java (100%) rename {Aria => aria}/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java (100%) rename {Aria => aria}/src/main/java/com/arialyy/aria/exception/FileException.java (100%) delete mode 100644 cache/build/mPro.properties diff --git a/Aria/build.gradle b/Aria/build.gradle index 7f0264be..1588b680 100644 --- a/Aria/build.gradle +++ b/Aria/build.gradle @@ -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') +//} diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java index d32800de..0ef0d5ad 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadReceiver.java @@ -62,8 +62,11 @@ public class DownloadReceiver implements IReceiver { /** * 添加调度器回调 + * + * @see #register() */ - public DownloadReceiver addSchedulerListener(ISchedulerListener listener) { + @Deprecated public DownloadReceiver addSchedulerListener( + ISchedulerListener listener) { this.listener = listener; DownloadSchedulers.getInstance().addSchedulerListener(targetName, listener); return this; @@ -80,15 +83,16 @@ public class DownloadReceiver implements IReceiver { /** * 取消注册 */ - @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); } diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java b/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java index 351bd07d..2f601917 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java +++ b/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulers.java @@ -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 { 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 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) clazz.newInstance(); } catch (ClassNotFoundException e) { Log.e(TAG, targetName + ",没有Aria的Download或Upload注解方法"); diff --git a/AriaAnnotations/build.gradle b/AriaAnnotations/build.gradle index 65ee1cf4..fef879df 100644 --- a/AriaAnnotations/build.gradle +++ b/AriaAnnotations/build.gradle @@ -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 } \ No newline at end of file diff --git a/AriaAnnotations/src/main/java/com/arialyy/annotations/Download.java b/AriaAnnotations/src/main/java/com/arialyy/annotations/Download.java index 0e5d1ea5..136b662d 100644 --- a/AriaAnnotations/src/main/java/com/arialyy/annotations/Download.java +++ b/AriaAnnotations/src/main/java/com/arialyy/annotations/Download.java @@ -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} + *
+ *   
+ *       protected void onPre(DownloadTask task) {
+ *        if (task.getKey().equals(DOWNLOAD_URL)) {
+ *           mUpdateHandler.obtainMessage(DOWNLOAD_PRE, task.getDownloadEntity().getFileSize()).sendToTarget();
+ *        }
+ *       }
+ *   
+ * 
*/ @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 { } diff --git a/AriaAnnotations/src/main/java/com/arialyy/annotations/Upload.java b/AriaAnnotations/src/main/java/com/arialyy/annotations/Upload.java index d224d14f..46fb0664 100644 --- a/AriaAnnotations/src/main/java/com/arialyy/annotations/Upload.java +++ b/AriaAnnotations/src/main/java/com/arialyy/annotations/Upload.java @@ -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} + *
+ *   
+ *       protected void onPre(UploadTask task) {
+ *        L.d(TAG, "fileSize = " + task.getConvertFileSize());
+ *       }
+ *   
+ * 
*/ @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 { } diff --git a/AriaCompiler/build.gradle b/AriaCompiler/build.gradle index 523d9a5d..84cc9758 100644 --- a/AriaCompiler/build.gradle +++ b/AriaCompiler/build.gradle @@ -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 +} \ No newline at end of file diff --git a/app/src/main/assets/aria_config.xml b/app/src/main/assets/aria_config.xml index 01c497ee..522cfa0c 100644 --- a/app/src/main/assets/aria_config.xml +++ b/app/src/main/assets/aria_config.xml @@ -7,7 +7,7 @@ - + @@ -37,7 +37,7 @@ - + diff --git a/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java b/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java index e4a92340..1f8bf46a 100644 --- a/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java +++ b/app/src/main/java/com/arialyy/simple/download/DownloadDialog.java @@ -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,43 +90,36 @@ public class DownloadDialog extends AbsDialog { } } - @Override protected void dataCallback(int result, Object obj) { - + @Download.onTaskPre public void onTaskPre(DownloadTask task) { + mSize.setText(CommonUtil.formatFileSize(task.getFileSize())); + setBtState(false); } - private void setBtState(boolean startEnable) { - mStart.setEnabled(startEnable); - mCancel.setEnabled(!startEnable); - mStop.setEnabled(!startEnable); + @Download.onTaskStop public void onTaskStop(DownloadTask task) { + setBtState(true); + mSpeed.setText(task.getConvertSpeed()); } - private class MyDialogDownloadCallback extends Aria.DownloadSchedulerListener { - - @Override public void onTaskPre(DownloadTask task) { - super.onTaskPre(task); - mSize.setText(CommonUtil.formatFileSize(task.getFileSize())); - setBtState(false); - } + @Download.onTaskCancel public void onTaskCancel(DownloadTask task) { + setBtState(true); + mPb.setProgress(0); + mSpeed.setText(task.getConvertSpeed()); + } - @Override public void onTaskStop(DownloadTask task) { - super.onTaskStop(task); - setBtState(true); + @Download.onTaskRunning public void onTaskRunning(DownloadTask task) { + if (task.getKey().equals(DOWNLOAD_URL)) { + mPb.setProgress(task.getPercent()); mSpeed.setText(task.getConvertSpeed()); } + } - @Override public void onTaskCancel(DownloadTask task) { - super.onTaskCancel(task); - setBtState(true); - mPb.setProgress(0); - mSpeed.setText(task.getConvertSpeed()); - } + @Override protected void dataCallback(int result, Object obj) { - @Override public void onTaskRunning(DownloadTask task) { - super.onTaskRunning(task); - if (task.getKey().equals(DOWNLOAD_URL)) { - mPb.setProgress(task.getPercent()); - mSpeed.setText(task.getConvertSpeed()); - } - } + } + + private void setBtState(boolean startEnable) { + mStart.setEnabled(startEnable); + mCancel.setEnabled(!startEnable); + mStop.setEnabled(!startEnable); } } diff --git a/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java b/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java index b82de2bc..a8c7188d 100644 --- a/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java +++ b/app/src/main/java/com/arialyy/simple/download/DownloadPopupWindow.java @@ -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()); } } diff --git a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java index 7de2db02..91fe5a3f 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -72,15 +72,6 @@ public class SingleTaskActivity extends BaseActivity { @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 { } }; + @Override protected void onCreate(Bundle savedInstanceState) { + super.onCreate(savedInstanceState); + Aria.download(this).register(); + } + /** * 设置start 和 stop 按钮状态 */ @@ -141,13 +137,6 @@ public class SingleTaskActivity extends BaseActivity { 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); diff --git a/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java b/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java index 3365a4be..d78f82fe 100644 --- a/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java +++ b/app/src/main/java/com/arialyy/simple/download/fragment_download/DownloadFragment.java @@ -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 { } 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 { } } + @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 { 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()); - } - } } diff --git a/app/src/main/java/com/arialyy/simple/download/multi_download/MultiDownloadActivity.java b/app/src/main/java/com/arialyy/simple/download/multi_download/MultiDownloadActivity.java index f49309f1..cefec9a0 100644 --- a/app/src/main/java/com/arialyy/simple/download/multi_download/MultiDownloadActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/multi_download/MultiDownloadActivity.java @@ -47,6 +47,7 @@ public class MultiDownloadActivity extends BaseActivity temps = Aria.download(this).getTaskList(); if (temps != null && !temps.isEmpty()) { @@ -57,12 +58,6 @@ public class MultiDownloadActivity extends BaseActivity { @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 { } } - @Override protected void onResume() { - super.onResume(); - Aria.download(this).register(); - } - @Download.onTaskStart void taskStart(DownloadTask task) { mAdapter.updateBtState(task.getKey(), false); } diff --git a/app/src/main/java/com/arialyy/simple/download/service_download/DownloadService.java b/app/src/main/java/com/arialyy/simple/download/service_download/DownloadService.java index 5e2038c0..258d1739 100644 --- a/app/src/main/java/com/arialyy/simple/download/service_download/DownloadService.java +++ b/app/src/main/java/com/arialyy/simple/download/service_download/DownloadService.java @@ -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 { - - @Override public void onNoSupportBreakPoint(DownloadTask task) { - super.onNoSupportBreakPoint(task); - T.showShort(getApplicationContext(), "该下载链接不支持断点"); - } - - @Override public void onTaskStart(DownloadTask task) { - T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",开始下载"); - } + @Download.onNoSupportBreakPoint public void onNoSupportBreakPoint(DownloadTask task) { + T.showShort(getApplicationContext(), "该下载链接不支持断点"); + } - @Override public void onTaskResume(DownloadTask task) { - super.onTaskResume(task); - } + @Download.onTaskStart public void onTaskStart(DownloadTask task) { + T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",开始下载"); + } - @Override public void onTaskStop(DownloadTask task) { - T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",停止下载"); - } + @Download.onTaskStop public void onTaskStop(DownloadTask task) { + T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",停止下载"); + } - @Override public void onTaskCancel(DownloadTask task) { - T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",取消下载"); - } + @Download.onTaskCancel public void onTaskCancel(DownloadTask task) { + T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",取消下载"); + } - @Override public void onTaskFail(DownloadTask task) { - T.showShort(getApplicationContext(), task.getDownloadEntity().getFileName() + ",下载失败"); - } + @Download.onTaskFail 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); - } + @Download.onTaskComplete 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); } } diff --git a/app/src/main/java/com/arialyy/simple/upload/UploadActivity.java b/app/src/main/java/com/arialyy/simple/upload/UploadActivity.java index be6351e6..881293fc 100644 --- a/app/src/main/java/com/arialyy/simple/upload/UploadActivity.java +++ b/app/src/main/java/com/arialyy/simple/upload/UploadActivity.java @@ -79,6 +79,7 @@ public class UploadActivity extends BaseActivity { @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 { 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) { } diff --git a/Aria/src/main/AndroidManifest.xml b/aria/src/main/AndroidManifest.xml similarity index 100% rename from Aria/src/main/AndroidManifest.xml rename to aria/src/main/AndroidManifest.xml diff --git a/Aria/src/main/java/com/arialyy/aria/core/Configuration.java b/aria/src/main/java/com/arialyy/aria/core/Configuration.java similarity index 100% rename from Aria/src/main/java/com/arialyy/aria/core/Configuration.java rename to aria/src/main/java/com/arialyy/aria/core/Configuration.java diff --git a/Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulerListener.java b/aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulerListener.java similarity index 100% rename from Aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulerListener.java rename to aria/src/main/java/com/arialyy/aria/core/scheduler/AbsSchedulerListener.java diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java b/aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java similarity index 100% rename from Aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java rename to aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java b/aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java similarity index 100% rename from Aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java rename to aria/src/main/java/com/arialyy/aria/core/upload/UploadTaskEntity.java diff --git a/Aria/src/main/java/com/arialyy/aria/exception/FileException.java b/aria/src/main/java/com/arialyy/aria/exception/FileException.java similarity index 100% rename from Aria/src/main/java/com/arialyy/aria/exception/FileException.java rename to aria/src/main/java/com/arialyy/aria/exception/FileException.java diff --git a/build.gradle b/build.gradle index 03fa24bb..feb7eb91 100644 --- a/build.gradle +++ b/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'] } diff --git a/cache/build/mPro.properties b/cache/build/mPro.properties deleted file mode 100644 index e69de29b..00000000 diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 1be3bb7c..2d992c4b 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -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