..
This commit is contained in:
@ -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;
|
||||
|
@ -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<DownloadTaskEntity, DownloadEntity> {
|
||||
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<DownloadTaskEntity, DownloadEntity> {
|
||||
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<DownloadTaskEntity, DownloadEntity> {
|
||||
/**
|
||||
* 将任务状态发送给下载器
|
||||
*
|
||||
* @param state {@link DownloadSchedulers#START}
|
||||
* @param state {@link ISchedulers#START}
|
||||
*/
|
||||
private void sendInState2Target(int state) {
|
||||
if (outHandler.get() != null) {
|
||||
|
@ -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;
|
||||
|
@ -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<UploadEntity, UploadTaskEntity> {
|
||||
return this;
|
||||
}
|
||||
|
||||
private UploadEntity getDownloadEntity() {
|
||||
private UploadEntity getUploadEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
|
@ -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'
|
||||
|
||||
}
|
||||
|
@ -62,10 +62,10 @@ public class SingleTaskActivity extends BaseActivity<ActivitySingleBinding> {
|
||||
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";
|
||||
//不支持断点的链接
|
||||
|
@ -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<UploadTaskEntity, UploadEntity> {
|
||||
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<UploadTaskEntity, UploadEntity> {
|
||||
}
|
||||
|
||||
@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<UploadTaskEntity, UploadEntity> {
|
||||
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<UploadTaskEntity, UploadEntity> {
|
||||
/**
|
||||
* 将任务状态发送给下载器
|
||||
*
|
||||
* @param state {@link DownloadSchedulers#START}
|
||||
* @param state {@link ISchedulers#START}
|
||||
*/
|
||||
private void sendInState2Target(int state) {
|
||||
if (outHandler.get() != null) {
|
||||
|
Reference in New Issue
Block a user