Skip to content

Commit

Permalink
Merge branch 'feature/bug-fix' into develop
Browse files Browse the repository at this point in the history
  • Loading branch information
Jacksgong committed Oct 15, 2016
2 parents a9fce1a + 572b51b commit 15494bf
Show file tree
Hide file tree
Showing 3 changed files with 11 additions and 23 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,6 @@
import android.os.Message;

import com.liulishuo.filedownloader.util.FileDownloadExecutors;
import com.liulishuo.filedownloader.util.FileDownloadLog;

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

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

if (messenger.handoverDirectly()) {
messenger.handoverMessage();
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -194,10 +194,18 @@ public void notifyCompleted(MessageSnapshot snapshot) {
}

private void process(MessageSnapshot snapshot) {
offer(snapshot);

FileDownloadMessageStation.getImpl().requestEnqueue(this);
if (mTask.getOrigin().getListener() == null) {
if (FileDownloadMonitor.isValid() &&
snapshot.getStatus() == FileDownloadStatus.blockComplete) {
// there is a FileDownloadMonitor, so we have to ensure the 'BaseDownloadTask#over'
// can be invoked.
mLifeCycleCallback.onOver();
}
} else {
offer(snapshot);

FileDownloadMessageStation.getImpl().requestEnqueue(this);
}
}

private void offer(MessageSnapshot snapshot) {
Expand Down Expand Up @@ -257,11 +265,6 @@ public boolean handoverDirectly() {
return mTask.getOrigin().isSyncCallback();
}

@Override
public boolean hasReceiver() {
return mTask.getOrigin().getListener() != null;
}

@Override
public void reAppointment(BaseDownloadTask.IRunningTask task,
BaseDownloadTask.LifeCycleCallback callback) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -141,12 +141,6 @@ interface IFileDownloadMessenger {
*/
boolean handoverDirectly();

/**
* @return {@code true} if has receiver(or listener) to receiver messages.
* @see BaseDownloadTask#getListener()
*/
boolean hasReceiver();

/**
* @param task Re-appointment for this task, when this messenger has already accomplished the
* old one.
Expand Down

0 comments on commit 15494bf

Please sign in to comment.