Skip to content

Commit

Permalink
fix: replace listener
Browse files Browse the repository at this point in the history
  • Loading branch information
Tianhua Ran committed Nov 7, 2019
1 parent 7fc3157 commit 7a5159b
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -567,6 +567,16 @@ public boolean isContainFinishListener() {
return !finishListeners.isEmpty();
}

public void replaceListener(FileDownloadListener fileDownloadListener) {
setListener(fileDownloadListener);
if (downloadTask == null) {
return;
}

compatListener = CompatListenerAdapter.create(listener);
downloadTask.replaceListener(compatListener);
}

static final class Builder {

private String url;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -472,8 +472,9 @@ public int replaceListener(int id, FileDownloadListener listener) {
return 0;
}

task.getOrigin().setListener(listener);
return task.getOrigin().getId();
final DownloadTaskAdapter downloadTask = (DownloadTaskAdapter) task.getOrigin();
downloadTask.replaceListener(listener);
return downloadTask.getId();
}

/**
Expand Down

0 comments on commit 7a5159b

Please sign in to comment.