parent
ba7ad618be
commit
380b05de43
@ -0,0 +1,30 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.command; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
*/ |
||||||
|
public abstract class AbsCmdFactory<CMD extends AbsCmd> { |
||||||
|
|
||||||
|
/** |
||||||
|
* @param target 创建任务的对象 |
||||||
|
* @param entity 下载实体 |
||||||
|
*/ |
||||||
|
public abstract <T extends AbsTaskEntity> CMD createCmd(String target, T entity, int type); |
||||||
|
} |
@ -0,0 +1,47 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.command.group; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.command.AbsCmd; |
||||||
|
import com.arialyy.aria.core.download.DownloadTaskEntity; |
||||||
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
||||||
|
import com.arialyy.aria.core.queue.DownloadTaskQueue; |
||||||
|
import com.arialyy.aria.core.queue.UploadTaskQueue; |
||||||
|
import com.arialyy.aria.core.upload.UploadTaskEntity; |
||||||
|
import com.arialyy.aria.util.CommonUtil; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
* 任务组命令 |
||||||
|
*/ |
||||||
|
public abstract class AbsGroupCmd<T extends AbsTaskEntity> extends AbsCmd<T> { |
||||||
|
|
||||||
|
/** |
||||||
|
* @param targetName 创建任务的对象名 |
||||||
|
*/ |
||||||
|
AbsGroupCmd(String targetName, T entity) { |
||||||
|
mTargetName = targetName; |
||||||
|
mTaskEntity = entity; |
||||||
|
TAG = CommonUtil.getClassName(this); |
||||||
|
if (entity instanceof DownloadTaskEntity) { |
||||||
|
mQueue = DownloadTaskQueue.getInstance(); |
||||||
|
isDownloadCmd = true; |
||||||
|
} else if (entity instanceof UploadTaskEntity) { |
||||||
|
mQueue = UploadTaskQueue.getInstance(); |
||||||
|
isDownloadCmd = false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.command.group; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
* 删除任务组 |
||||||
|
*/ |
||||||
|
class GroupCancelCmd<T extends AbsTaskEntity> extends AbsGroupCmd<T> { |
||||||
|
/** |
||||||
|
* @param targetName 创建任务的对象名 |
||||||
|
*/ |
||||||
|
GroupCancelCmd(String targetName, T entity) { |
||||||
|
super(targetName, entity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void executeCmd() { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,71 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.command.group; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.AriaManager; |
||||||
|
import com.arialyy.aria.core.command.AbsCmdFactory; |
||||||
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
*/ |
||||||
|
public class GroupCmdFactory extends AbsCmdFactory<AbsGroupCmd> { |
||||||
|
/** |
||||||
|
* 启动任务 |
||||||
|
*/ |
||||||
|
public static final int TASK_START = 0xa1; |
||||||
|
/** |
||||||
|
* 停止任务 |
||||||
|
*/ |
||||||
|
public static final int TASK_STOP = 0xa2; |
||||||
|
/** |
||||||
|
* 取消任务 |
||||||
|
*/ |
||||||
|
public static final int TASK_CANCEL = 0xa3; |
||||||
|
|
||||||
|
private static volatile GroupCmdFactory INSTANCE = null; |
||||||
|
|
||||||
|
private GroupCmdFactory() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
public static GroupCmdFactory getInstance() { |
||||||
|
if (INSTANCE == null) { |
||||||
|
synchronized (AriaManager.LOCK) { |
||||||
|
INSTANCE = new GroupCmdFactory(); |
||||||
|
} |
||||||
|
} |
||||||
|
return INSTANCE; |
||||||
|
} |
||||||
|
|
||||||
|
/** |
||||||
|
* @param target 创建任务的对象 |
||||||
|
* @param entity 下载实体 |
||||||
|
* @param type 命令类型{@link #TASK_START}、{@link #TASK_CANCEL}、{@link #TASK_STOP} |
||||||
|
*/ |
||||||
|
public <T extends AbsTaskEntity> AbsGroupCmd<T> createCmd(String target, T entity, int type) { |
||||||
|
switch (type) { |
||||||
|
case TASK_START: |
||||||
|
return new GroupStartCmd<>(target, entity); |
||||||
|
case TASK_STOP: |
||||||
|
return new GroupStopCmd<>(target, entity); |
||||||
|
case TASK_CANCEL: |
||||||
|
return new GroupCancelCmd<>(target, entity); |
||||||
|
default: |
||||||
|
return null; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.command.group; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
* 任务组开始命令,该命令负责开始下载或恢复下载的操作 |
||||||
|
*/ |
||||||
|
class GroupStartCmd<T extends AbsTaskEntity> extends AbsGroupCmd<T> { |
||||||
|
/** |
||||||
|
* @param targetName 创建任务的对象名 |
||||||
|
*/ |
||||||
|
GroupStartCmd(String targetName, T entity) { |
||||||
|
super(targetName, entity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void executeCmd() { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,35 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.command.group; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
* 停止任务组的命令 |
||||||
|
*/ |
||||||
|
class GroupStopCmd<T extends AbsTaskEntity> extends AbsGroupCmd<T>{ |
||||||
|
/** |
||||||
|
* @param targetName 创建任务的对象名 |
||||||
|
*/ |
||||||
|
GroupStopCmd(String targetName, T entity) { |
||||||
|
super(targetName, entity); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void executeCmd() { |
||||||
|
|
||||||
|
} |
||||||
|
} |
@ -0,0 +1,56 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package com.arialyy.aria.core.command.normal; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.command.AbsCmd; |
||||||
|
import com.arialyy.aria.core.download.DownloadTaskEntity; |
||||||
|
import com.arialyy.aria.core.inf.AbsTaskEntity; |
||||||
|
import com.arialyy.aria.core.queue.DownloadTaskQueue; |
||||||
|
import com.arialyy.aria.core.queue.UploadTaskQueue; |
||||||
|
import com.arialyy.aria.core.upload.UploadTaskEntity; |
||||||
|
import com.arialyy.aria.util.CheckUtil; |
||||||
|
import com.arialyy.aria.util.CommonUtil; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by lyy on 2016/8/22. |
||||||
|
* 下载命令 |
||||||
|
*/ |
||||||
|
public abstract class AbsNormalCmd<T extends AbsTaskEntity> extends AbsCmd<T> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 能否执行命令 |
||||||
|
*/ |
||||||
|
boolean canExeCmd = true; |
||||||
|
|
||||||
|
/** |
||||||
|
* @param targetName 产生任务的对象名 |
||||||
|
*/ |
||||||
|
AbsNormalCmd(String targetName, T entity) { |
||||||
|
canExeCmd = CheckUtil.checkCmdEntity(entity, |
||||||
|
!(this instanceof CancelCmd) || !(this instanceof StopCmd)); |
||||||
|
mTargetName = targetName; |
||||||
|
mTaskEntity = entity; |
||||||
|
TAG = CommonUtil.getClassName(this); |
||||||
|
if (entity instanceof DownloadTaskEntity) { |
||||||
|
mQueue = DownloadTaskQueue.getInstance(); |
||||||
|
isDownloadCmd = true; |
||||||
|
} else if (entity instanceof UploadTaskEntity) { |
||||||
|
mQueue = UploadTaskQueue.getInstance(); |
||||||
|
isDownloadCmd = false; |
||||||
|
} |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,38 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.download; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.inf.AbsGroupTarget; |
||||||
|
import com.arialyy.aria.core.inf.ITarget; |
||||||
|
import java.util.List; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
*/ |
||||||
|
public class DownloadGroupTarget extends AbsGroupTarget<DownloadGroupTarget, DownloadTaskEntity> { |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置保存路径组 |
||||||
|
*/ |
||||||
|
public DownloadGroupTarget setDownloadPaths(List<String> paths) { |
||||||
|
|
||||||
|
return this; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public int getPercent() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,140 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.inf; |
||||||
|
|
||||||
|
import android.os.Parcel; |
||||||
|
import android.os.Parcelable; |
||||||
|
import com.arialyy.aria.orm.DbEntity; |
||||||
|
import com.arialyy.aria.orm.Ignore; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/3. |
||||||
|
*/ |
||||||
|
public abstract class AbsGroupEntity<CHILD_ENTITY extends AbsNormalEntity> extends DbEntity implements IEntity, Parcelable { |
||||||
|
/** |
||||||
|
* 速度 |
||||||
|
*/ |
||||||
|
@Ignore private long speed = 0; |
||||||
|
/** |
||||||
|
* 单位转换后的速度 |
||||||
|
*/ |
||||||
|
@Ignore private String convertSpeed = "0b/s"; |
||||||
|
|
||||||
|
/** |
||||||
|
* 扩展字段 |
||||||
|
*/ |
||||||
|
private String str = ""; |
||||||
|
/** |
||||||
|
* 文件大小 |
||||||
|
*/ |
||||||
|
private long fileSize = 1; |
||||||
|
private int state = STATE_WAIT; |
||||||
|
/** |
||||||
|
* 当前下载进度 |
||||||
|
*/ |
||||||
|
private long currentProgress = 0; |
||||||
|
/** |
||||||
|
* 完成时间 |
||||||
|
*/ |
||||||
|
private long completeTime; |
||||||
|
/** |
||||||
|
* 文件名 |
||||||
|
*/ |
||||||
|
private String grooupName = ""; |
||||||
|
|
||||||
|
public long getSpeed() { |
||||||
|
return speed; |
||||||
|
} |
||||||
|
|
||||||
|
public void setSpeed(long speed) { |
||||||
|
this.speed = speed; |
||||||
|
} |
||||||
|
|
||||||
|
public String getConvertSpeed() { |
||||||
|
return convertSpeed; |
||||||
|
} |
||||||
|
|
||||||
|
public void setConvertSpeed(String convertSpeed) { |
||||||
|
this.convertSpeed = convertSpeed; |
||||||
|
} |
||||||
|
|
||||||
|
public String getStr() { |
||||||
|
return str; |
||||||
|
} |
||||||
|
|
||||||
|
public void setStr(String str) { |
||||||
|
this.str = str; |
||||||
|
} |
||||||
|
|
||||||
|
public long getFileSize() { |
||||||
|
return fileSize; |
||||||
|
} |
||||||
|
|
||||||
|
public void setFileSize(long fileSize) { |
||||||
|
this.fileSize = fileSize; |
||||||
|
} |
||||||
|
|
||||||
|
public int getState() { |
||||||
|
return state; |
||||||
|
} |
||||||
|
|
||||||
|
public void setState(int state) { |
||||||
|
this.state = state; |
||||||
|
} |
||||||
|
|
||||||
|
public long getCurrentProgress() { |
||||||
|
return currentProgress; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCurrentProgress(long currentProgress) { |
||||||
|
this.currentProgress = currentProgress; |
||||||
|
} |
||||||
|
|
||||||
|
public long getCompleteTime() { |
||||||
|
return completeTime; |
||||||
|
} |
||||||
|
|
||||||
|
public void setCompleteTime(long completeTime) { |
||||||
|
this.completeTime = completeTime; |
||||||
|
} |
||||||
|
|
||||||
|
public AbsGroupEntity() { |
||||||
|
} |
||||||
|
|
||||||
|
@Override public int describeContents() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void writeToParcel(Parcel dest, int flags) { |
||||||
|
dest.writeLong(this.speed); |
||||||
|
dest.writeString(this.convertSpeed); |
||||||
|
dest.writeString(this.str); |
||||||
|
dest.writeLong(this.fileSize); |
||||||
|
dest.writeInt(this.state); |
||||||
|
dest.writeLong(this.currentProgress); |
||||||
|
dest.writeLong(this.completeTime); |
||||||
|
} |
||||||
|
|
||||||
|
protected AbsGroupEntity(Parcel in) { |
||||||
|
this.speed = in.readLong(); |
||||||
|
this.convertSpeed = in.readString(); |
||||||
|
this.str = in.readString(); |
||||||
|
this.fileSize = in.readLong(); |
||||||
|
this.state = in.readInt(); |
||||||
|
this.currentProgress = in.readLong(); |
||||||
|
this.completeTime = in.readLong(); |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,79 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.inf; |
||||||
|
|
||||||
|
import android.support.annotation.NonNull; |
||||||
|
import com.arialyy.aria.core.RequestEnum; |
||||||
|
import java.util.Map; |
||||||
|
import java.util.Set; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
* 任务组超类 |
||||||
|
*/ |
||||||
|
public abstract class AbsGroupTarget<TARGET extends AbsGroupTarget, TASK_ENTITY extends AbsTaskEntity> |
||||||
|
implements ITarget<TARGET> { |
||||||
|
|
||||||
|
protected TASK_ENTITY mTaskEntity; |
||||||
|
|
||||||
|
@Override public void resume() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override public void start() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override public void stop() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override public void cancel() { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override public long getSize() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public String getConvertSize() { |
||||||
|
return null; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public long getCurrentProgress() { |
||||||
|
return 0; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public TARGET addHeader(@NonNull String key, @NonNull String header) { |
||||||
|
mTaskEntity.headers.put(key, header); |
||||||
|
return (TARGET) this; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public TARGET addHeaders(Map<String, String> headers) { |
||||||
|
if (headers != null && headers.size() > 0) { |
||||||
|
Set<String> keys = headers.keySet(); |
||||||
|
for (String key : keys) { |
||||||
|
mTaskEntity.headers.put(key, headers.get(key)); |
||||||
|
} |
||||||
|
} |
||||||
|
return (TARGET) this; |
||||||
|
} |
||||||
|
|
||||||
|
@Override public TARGET setRequestMode(RequestEnum requestEnum) { |
||||||
|
mTaskEntity.requestEnum = requestEnum; |
||||||
|
return (TARGET) this; |
||||||
|
} |
||||||
|
} |
@ -0,0 +1,86 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
package com.arialyy.aria.core.inf; |
||||||
|
|
||||||
|
import android.support.annotation.NonNull; |
||||||
|
import com.arialyy.aria.core.RequestEnum; |
||||||
|
import java.util.Map; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
*/ |
||||||
|
public interface ITarget<TARGET extends ITarget> { |
||||||
|
/** |
||||||
|
* 任务文件大小 |
||||||
|
*/ |
||||||
|
long getSize(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 转换后的大小 |
||||||
|
*/ |
||||||
|
String getConvertSize(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取任务进度百分比 |
||||||
|
*/ |
||||||
|
int getPercent(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 获取任务进度,如果任务存在,则返回当前进度 |
||||||
|
*/ |
||||||
|
long getCurrentProgress(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 给url请求添加头部 |
||||||
|
* |
||||||
|
* @param key 头部key |
||||||
|
* @param header 头部value |
||||||
|
*/ |
||||||
|
TARGET addHeader(@NonNull String key, @NonNull String header) ; |
||||||
|
|
||||||
|
/** |
||||||
|
* 给url请求添加头部 |
||||||
|
*/ |
||||||
|
TARGET addHeaders(Map<String, String> headers); |
||||||
|
|
||||||
|
/** |
||||||
|
* 设置请求类型 |
||||||
|
* |
||||||
|
* @param requestEnum {@link RequestEnum} |
||||||
|
*/ |
||||||
|
TARGET setRequestMode(RequestEnum requestEnum); |
||||||
|
|
||||||
|
/** |
||||||
|
* 开始下载 |
||||||
|
*/ |
||||||
|
void start(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 停止下载 |
||||||
|
*/ |
||||||
|
void stop(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 恢复下载 |
||||||
|
*/ |
||||||
|
void resume(); |
||||||
|
|
||||||
|
/** |
||||||
|
* 取消下载 |
||||||
|
*/ |
||||||
|
void cancel(); |
||||||
|
|
||||||
|
} |
@ -0,0 +1,24 @@ |
|||||||
|
/* |
||||||
|
* Copyright (C) 2016 AriaLyy(https://github.com/AriaLyy/Aria)
|
||||||
|
* |
||||||
|
* Licensed under the Apache License, Version 2.0 (the "License"); |
||||||
|
* you may not use this file except in compliance with the License. |
||||||
|
* You may obtain a copy of the License at |
||||||
|
* |
||||||
|
* http://www.apache.org/licenses/LICENSE-2.0
|
||||||
|
* |
||||||
|
* Unless required by applicable law or agreed to in writing, software |
||||||
|
* distributed under the License is distributed on an "AS IS" BASIS, |
||||||
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. |
||||||
|
* See the License for the specific language governing permissions and |
||||||
|
* limitations under the License. |
||||||
|
*/ |
||||||
|
|
||||||
|
package com.arialyy.aria.core.queue; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by AriaL on 2017/6/29. |
||||||
|
* 任务组下载队列 |
||||||
|
*/ |
||||||
|
public class DownloadGroupTaskQueue { |
||||||
|
} |
Loading…
Reference in new issue