pull/330/head
parent
5ebe94c905
commit
e20ab6a3c9
@ -0,0 +1,66 @@ |
|||||||
|
/* |
||||||
|
* 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 android.os.Handler; |
||||||
|
import android.util.Log; |
||||||
|
import com.arialyy.aria.core.download.downloader.IDownloadGroupListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by Aria.Lao on 2017/7/20. |
||||||
|
* 任务组下载事件 |
||||||
|
*/ |
||||||
|
class DownloadGroupListener extends BaseListener<DownloadGroupEntity, DownloadGroupTask> |
||||||
|
implements IDownloadGroupListener { |
||||||
|
private final String TAG = "DownloadGroupListener"; |
||||||
|
|
||||||
|
DownloadGroupListener(DownloadGroupTask task, Handler outHandler) { |
||||||
|
super(task, outHandler); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void supportBreakpoint(boolean support, DownloadEntity subEntity) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override public void onSubStart(DownloadEntity subEntity) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
@Override public void onSubStop(DownloadEntity subEntity) { |
||||||
|
saveCurrentLocation(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void onSubComplete(DownloadEntity subEntity) { |
||||||
|
saveCurrentLocation(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void onSubFail(DownloadEntity subEntity) { |
||||||
|
saveCurrentLocation(); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void onSubCancel(DownloadEntity entity) { |
||||||
|
saveCurrentLocation(); |
||||||
|
} |
||||||
|
|
||||||
|
private void saveCurrentLocation() { |
||||||
|
long location = 0; |
||||||
|
for (DownloadEntity e : mEntity.getSubTask()) { |
||||||
|
location += e.getCurrentProgress(); |
||||||
|
} |
||||||
|
mEntity.setCurrentProgress(location); |
||||||
|
mEntity.update(); |
||||||
|
} |
||||||
|
} |
@ -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.download; |
||||||
|
|
||||||
|
import android.os.Handler; |
||||||
|
import com.arialyy.aria.core.download.downloader.IDownloadListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by Aria.Lao on 2017/7/20. |
||||||
|
* 普通任务下载的事件监听器 |
||||||
|
*/ |
||||||
|
class DownloadListener extends BaseListener<DownloadEntity, DownloadTask> |
||||||
|
implements IDownloadListener { |
||||||
|
DownloadListener(DownloadTask task, Handler outHandler) { |
||||||
|
super(task, outHandler); |
||||||
|
} |
||||||
|
|
||||||
|
@Override public void supportBreakpoint(boolean support) { |
||||||
|
|
||||||
|
} |
||||||
|
|
||||||
|
} |
@ -1,72 +0,0 @@ |
|||||||
/* |
|
||||||
* 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.downloader; |
|
||||||
|
|
||||||
|
|
||||||
/** |
|
||||||
* @author lyy |
|
||||||
*/ |
|
||||||
public class DownloadListener implements IDownloadListener { |
|
||||||
|
|
||||||
@Override public void onResume(long resumeLocation) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void supportBreakpoint(boolean support) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onCancel() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onFail() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onPre() { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onPostPre(long fileSize) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onProgress(long currentLocation) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onChildComplete(long finishLocation) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onStart(long startLocation) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onChildResume(long resumeLocation) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onStop(long stopLocation) { |
|
||||||
|
|
||||||
} |
|
||||||
|
|
||||||
@Override public void onComplete() { |
|
||||||
|
|
||||||
} |
|
||||||
} |
|
@ -0,0 +1,58 @@ |
|||||||
|
/* |
||||||
|
* 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.downloader; |
||||||
|
|
||||||
|
import com.arialyy.aria.core.download.DownloadEntity; |
||||||
|
import com.arialyy.aria.core.inf.IEventListener; |
||||||
|
|
||||||
|
/** |
||||||
|
* Created by Aria.Lao on 2017/7/20. |
||||||
|
* 下载任务组事件 |
||||||
|
*/ |
||||||
|
public interface IDownloadGroupListener extends IEventListener { |
||||||
|
|
||||||
|
/** |
||||||
|
* 子任务支持断点回调 |
||||||
|
* |
||||||
|
* @param support true,支持;false 不支持 |
||||||
|
*/ |
||||||
|
void supportBreakpoint(boolean support, DownloadEntity subEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 子任务开始下载\恢复下载 |
||||||
|
*/ |
||||||
|
void onSubStart(DownloadEntity subEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 子任务停止下载 |
||||||
|
*/ |
||||||
|
void onSubStop(DownloadEntity subEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 子任务下载完成 |
||||||
|
*/ |
||||||
|
void onSubComplete(DownloadEntity subEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 子任务下载失败 |
||||||
|
*/ |
||||||
|
void onSubFail(DownloadEntity subEntity); |
||||||
|
|
||||||
|
/** |
||||||
|
* 子任务取消下载 |
||||||
|
*/ |
||||||
|
void onSubCancel(DownloadEntity subEntity); |
||||||
|
} |
Loading…
Reference in new issue