From 5aeb8ec4bb01881388e090170e7cfb9200e1377e Mon Sep 17 00:00:00 2001 From: AriaLyy <511455842@qq.com> Date: Thu, 6 Jul 2017 11:14:15 +0800 Subject: [PATCH] .. --- .../aria/core/download/DownloadReceiver.java | 1 - .../aria/core/download/DownloadTask.java | 7 ++--- .../arialyy/aria/core/queue/AbsTaskQueue.java | 1 - .../aria/core/upload/UploadTarget.java | 3 +- app/build.gradle | 4 +-- .../simple/download/SingleTaskActivity.java | 4 +-- .../arialyy/aria/core/upload/UploadTask.java | 28 +++++++++---------- 7 files changed, 21 insertions(+), 27 deletions(-) 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 6aa171ca..130b75c3 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 @@ -17,7 +17,6 @@ package com.arialyy.aria.core.download; import android.support.annotation.NonNull; import com.arialyy.aria.core.AriaManager; -import com.arialyy.aria.core.inf.ICmd; import com.arialyy.aria.core.inf.IEntity; import com.arialyy.aria.core.inf.IReceiver; import com.arialyy.aria.core.command.CmdFactory; diff --git a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java index f72d68b2..dddad2d2 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java +++ b/Aria/src/main/java/com/arialyy/aria/core/download/DownloadTask.java @@ -24,7 +24,6 @@ import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.IEntity; -import com.arialyy.aria.core.scheduler.DownloadSchedulers; import com.arialyy.aria.core.scheduler.ISchedulers; import com.arialyy.aria.util.CheckUtil; import com.arialyy.aria.util.CommonUtil; @@ -141,7 +140,7 @@ public class DownloadTask extends AbsTask { mEntity.setState(isWait ? IEntity.STATE_WAIT : IEntity.STATE_STOP); mEntity.save(); if (mOutHandler != null) { - mOutHandler.obtainMessage(DownloadSchedulers.STOP, this).sendToTarget(); + mOutHandler.obtainMessage(ISchedulers.STOP, this).sendToTarget(); } // 发送停止下载的广播 Intent intent = CommonUtil.createIntent(mContext.getPackageName(), Aria.ACTION_STOP); @@ -158,7 +157,7 @@ public class DownloadTask extends AbsTask { if (!mEntity.isDownloadComplete()) { if (!mUtil.isDownloading()) { if (mOutHandler != null) { - mOutHandler.obtainMessage(DownloadSchedulers.CANCEL, this).sendToTarget(); + mOutHandler.obtainMessage(ISchedulers.CANCEL, this).sendToTarget(); } //发送取消下载的广播 Intent intent = CommonUtil.createIntent(mContext.getPackageName(), Aria.ACTION_CANCEL); @@ -333,7 +332,7 @@ public class DownloadTask extends AbsTask { /** * 将任务状态发送给下载器 * - * @param state {@link DownloadSchedulers#START} + * @param state {@link ISchedulers#START} */ private void sendInState2Target(int state) { if (outHandler.get() != null) { diff --git a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java index 67f55038..faab3440 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java +++ b/Aria/src/main/java/com/arialyy/aria/core/queue/AbsTaskQueue.java @@ -17,7 +17,6 @@ package com.arialyy.aria.core.queue; import android.util.Log; -import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.AriaManager; import com.arialyy.aria.core.inf.AbsEntity; import com.arialyy.aria.core.inf.ITask; diff --git a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java index 1868d51c..f991f7f9 100644 --- a/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java +++ b/Aria/src/main/java/com/arialyy/aria/core/upload/UploadTarget.java @@ -19,7 +19,6 @@ import android.support.annotation.NonNull; import com.arialyy.aria.core.RequestEnum; import com.arialyy.aria.core.inf.AbsTarget; import com.arialyy.aria.core.queue.UploadTaskQueue; -import com.arialyy.aria.orm.DbEntity; import java.util.Map; /** @@ -117,7 +116,7 @@ public class UploadTarget extends AbsTarget { return this; } - private UploadEntity getDownloadEntity() { + private UploadEntity getUploadEntity() { return entity; } diff --git a/app/build.gradle b/app/build.gradle index 58c03308..cb5f0bd7 100644 --- a/app/build.gradle +++ b/app/build.gradle @@ -42,7 +42,7 @@ dependencies { compile 'com.squareup.okhttp3:okhttp:3.2.0' compile 'com.arialyy.frame:MVVM2:2.2.0' compile project(':Aria') -// compile 'com.arialyy.aria:aria-core:3.1.9' -// annotationProcessor 'com.arialyy.aria:aria-compiler:3.1.9' +// compile 'com.arialyy.aria:aria-core:3.2.0' +// annotationProcessor 'com.arialyy.aria:aria-compiler:3.2.0' } 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 76585966..ecef722d 100644 --- a/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java +++ b/app/src/main/java/com/arialyy/simple/download/SingleTaskActivity.java @@ -62,10 +62,10 @@ public class SingleTaskActivity extends BaseActivity { private static final String DOWNLOAD_URL = //"http://kotlinlang.org/docs/kotlin-docs.pdf"; //"https://atom-installer.github.com/v1.13.0/AtomSetup.exe?s=1484074138&ext=.exe"; - //"http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"; + "http://static.gaoshouyou.com/d/22/94/822260b849944492caadd2983f9bb624.apk"; //"http://down2.xiaoshuofuwuqi.com/d/file/filetxt/20170608/14/%BA%DA%CE%D7%CA%A6%E1%C8%C6%F0.txt"; //"http://tinghuaapp.oss-cn-shanghai.aliyuncs.com/20170612201739607815"; - "http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk"; + //"http://static.gaoshouyou.com/d/36/69/2d3699acfa69e9632262442c46516ad8.apk"; //"http://oqcpqqvuf.bkt.clouddn.com/ceshi.txt"; //"http://down8.androidgame-store.com/201706122321/97967927DD4E53D9905ECAA7874C8128/new/game1/19/45319/com.neuralprisma-2.5.2.174-2000174_1494784835.apk?f=web_1"; //不支持断点的链接 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 index ba799ca0..5aee834b 100644 --- a/aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java +++ b/aria/src/main/java/com/arialyy/aria/core/upload/UploadTask.java @@ -21,10 +21,8 @@ import android.os.Handler; import android.util.Log; import com.arialyy.aria.core.Aria; import com.arialyy.aria.core.AriaManager; -import com.arialyy.aria.core.download.DownloadEntity; import com.arialyy.aria.core.inf.AbsTask; import com.arialyy.aria.core.inf.IEntity; -import com.arialyy.aria.core.scheduler.DownloadSchedulers; import com.arialyy.aria.core.scheduler.ISchedulers; import com.arialyy.aria.util.CommonUtil; import java.lang.ref.WeakReference; @@ -77,7 +75,7 @@ public class UploadTask extends AbsTask { mUtil.cancel(); mEntity.deleteData(); if (mOutHandler != null) { - mOutHandler.obtainMessage(DownloadSchedulers.CANCEL, this).sendToTarget(); + mOutHandler.obtainMessage(ISchedulers.CANCEL, this).sendToTarget(); } //发送取消下载的广播 Intent intent = CommonUtil.createIntent(AriaManager.APP.getPackageName(), Aria.ACTION_CANCEL); @@ -132,15 +130,15 @@ public class UploadTask extends AbsTask { } @Override public void onResume(long resumeLocation) { - uploadEntity.setState(DownloadEntity.STATE_RUNNING); - sendInState2Target(DownloadSchedulers.RESUME); + uploadEntity.setState(IEntity.STATE_RUNNING); + sendInState2Target(ISchedulers.RESUME); sendIntent(Aria.ACTION_RESUME, resumeLocation); } @Override public void onStop(long stopLocation) { - uploadEntity.setState(DownloadEntity.STATE_STOP); + uploadEntity.setState(IEntity.STATE_STOP); handleSpeed(0); - sendInState2Target(DownloadSchedulers.STOP); + sendInState2Target(ISchedulers.STOP); sendIntent(Aria.ACTION_STOP, stopLocation); } @@ -157,32 +155,32 @@ public class UploadTask extends AbsTask { handleSpeed(speed); uploadEntity.setCurrentProgress(currentLocation); lastLen = currentLocation; - sendInState2Target(DownloadSchedulers.RUNNING); + sendInState2Target(ISchedulers.RUNNING); AriaManager.APP.sendBroadcast(sendIntent); } } @Override public void onCancel() { - uploadEntity.setState(DownloadEntity.STATE_CANCEL); + uploadEntity.setState(IEntity.STATE_CANCEL); handleSpeed(0); - sendInState2Target(DownloadSchedulers.CANCEL); + sendInState2Target(ISchedulers.CANCEL); sendIntent(Aria.ACTION_CANCEL, -1); uploadEntity.deleteData(); } @Override public void onComplete() { - uploadEntity.setState(DownloadEntity.STATE_COMPLETE); + uploadEntity.setState(IEntity.STATE_COMPLETE); uploadEntity.setComplete(true); handleSpeed(0); - sendInState2Target(DownloadSchedulers.COMPLETE); + sendInState2Target(ISchedulers.COMPLETE); sendIntent(Aria.ACTION_COMPLETE, uploadEntity.getFileSize()); } @Override public void onFail() { uploadEntity.setFailNum(uploadEntity.getFailNum() + 1); - uploadEntity.setState(DownloadEntity.STATE_FAIL); + uploadEntity.setState(IEntity.STATE_FAIL); handleSpeed(0); - sendInState2Target(DownloadSchedulers.FAIL); + sendInState2Target(ISchedulers.FAIL); sendIntent(Aria.ACTION_FAIL, -1); } @@ -197,7 +195,7 @@ public class UploadTask extends AbsTask { /** * 将任务状态发送给下载器 * - * @param state {@link DownloadSchedulers#START} + * @param state {@link ISchedulers#START} */ private void sendInState2Target(int state) { if (outHandler.get() != null) {