好了,NetroidNetroid的原理基本上就是这些了,讲一下我用的时候遇到的两个问题:
1.下载进度的速度太快,你如果用notifition来显示,会出现ANR,所以我们要控制一下它的速度,具体方法在上面
1
2
3
4
5
6
|
//控制下载进度的速度
if
(currTime - lastUpdateTime >= DEFAULT_TIME) {
lastUpdateTime = currTime;
delivery.postDownloadProgress(
this
, fileSize,
downloadedSize);
}
|
2.第二个问题是当你下载的时候,如果把WiFi关掉,即使没下完,也会被标记为done,修改主要是在在FileDownloader.DownloadController的deploy()中
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
|
@Override
public
void
onFinish() {
// we don't inform FINISH when it was cancel.
if
(!isCanceled) {
mStatus = STATUS_PAUSE;
mListener.onFinish();
// when request was FINISH, remove the task and re-schedule Task Queue.
// remove(DownloadController.this);
}
}
@Override
public
void
onSuccess(Void response) {
// we don't inform SUCCESS when it was cancel.
if
(!isCanceled) {
mListener.onSuccess(response);
mStatus = STATUS_SUCCESS;
remove(DownloadController.
this
);
}
}
|