Skip to content

Commit 15494bf

Browse files
committed
Merge branch 'feature/bug-fix' into develop
2 parents a9fce1a + 572b51b commit 15494bf

File tree

3 files changed

+11
-23
lines changed

3 files changed

+11
-23
lines changed

library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessageStation.java

Lines changed: 0 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,6 @@
2121
import android.os.Message;
2222

2323
import com.liulishuo.filedownloader.util.FileDownloadExecutors;
24-
import com.liulishuo.filedownloader.util.FileDownloadLog;
2524

2625
import java.util.ArrayList;
2726
import java.util.concurrent.Executor;
@@ -58,14 +57,6 @@ void requestEnqueue(final IFileDownloadMessenger messenger) {
5857

5958
void requestEnqueue(final IFileDownloadMessenger messenger,
6059
@SuppressWarnings("SameParameterValue") boolean immediately) {
61-
/** @see #notify(FileDownloadEvent) **/
62-
if (!messenger.hasReceiver()) {
63-
if (FileDownloadLog.NEED_LOG) {
64-
FileDownloadLog.d(this, "can't handover the message[%s], " +
65-
"no listener be found in task to receive.", messenger);
66-
}
67-
return;
68-
}
6960

7061
if (messenger.handoverDirectly()) {
7162
messenger.handoverMessage();

library/src/main/java/com/liulishuo/filedownloader/FileDownloadMessenger.java

Lines changed: 11 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -194,10 +194,18 @@ public void notifyCompleted(MessageSnapshot snapshot) {
194194
}
195195

196196
private void process(MessageSnapshot snapshot) {
197-
offer(snapshot);
198-
199-
FileDownloadMessageStation.getImpl().requestEnqueue(this);
197+
if (mTask.getOrigin().getListener() == null) {
198+
if (FileDownloadMonitor.isValid() &&
199+
snapshot.getStatus() == FileDownloadStatus.blockComplete) {
200+
// there is a FileDownloadMonitor, so we have to ensure the 'BaseDownloadTask#over'
201+
// can be invoked.
202+
mLifeCycleCallback.onOver();
203+
}
204+
} else {
205+
offer(snapshot);
200206

207+
FileDownloadMessageStation.getImpl().requestEnqueue(this);
208+
}
201209
}
202210

203211
private void offer(MessageSnapshot snapshot) {
@@ -257,11 +265,6 @@ public boolean handoverDirectly() {
257265
return mTask.getOrigin().isSyncCallback();
258266
}
259267

260-
@Override
261-
public boolean hasReceiver() {
262-
return mTask.getOrigin().getListener() != null;
263-
}
264-
265268
@Override
266269
public void reAppointment(BaseDownloadTask.IRunningTask task,
267270
BaseDownloadTask.LifeCycleCallback callback) {

library/src/main/java/com/liulishuo/filedownloader/IFileDownloadMessenger.java

Lines changed: 0 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -141,12 +141,6 @@ interface IFileDownloadMessenger {
141141
*/
142142
boolean handoverDirectly();
143143

144-
/**
145-
* @return {@code true} if has receiver(or listener) to receiver messages.
146-
* @see BaseDownloadTask#getListener()
147-
*/
148-
boolean hasReceiver();
149-
150144
/**
151145
* @param task Re-appointment for this task, when this messenger has already accomplished the
152146
* old one.

0 commit comments

Comments
 (0)