Skip to content
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.

Commit c84b381

Browse files
committedFeb 14, 2016
feat(QueueSet): support add FinishListener to each task in a queue
1 parent ac92ab3 commit c84b381

File tree

1 file changed

+21
-0
lines changed

1 file changed

+21
-0
lines changed
 

‎library/src/main/java/com/liulishuo/filedownloader/FileDownloadQueueSet.java

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
package com.liulishuo.filedownloader;
1818

19+
import java.util.ArrayList;
1920
import java.util.List;
2021

2122
/**
@@ -27,6 +28,7 @@ public class FileDownloadQueueSet {
2728
private boolean isSerial;
2829

2930

31+
private List<BaseDownloadTask.FinishListener> taskFinishListenerList;
3032
private Integer autoRetryTimes;
3133
private Boolean syncCallback;
3234
private Boolean isForceReDownload;
@@ -122,6 +124,12 @@ public void start() {
122124
task.setTag(tag);
123125
}
124126

127+
if (taskFinishListenerList != null) {
128+
for (BaseDownloadTask.FinishListener finishListener : taskFinishListenerList) {
129+
task.addFinishListener(finishListener);
130+
}
131+
}
132+
125133
task.ready();
126134
}
127135

@@ -172,4 +180,17 @@ public FileDownloadQueueSet setTag(final Object tag) {
172180
return this;
173181
}
174182

183+
/**
184+
* @see BaseDownloadTask#addFinishListener(BaseDownloadTask.FinishListener)
185+
*/
186+
public FileDownloadQueueSet addTaskFinishListener(
187+
final BaseDownloadTask.FinishListener finishListener) {
188+
if (this.taskFinishListenerList == null) {
189+
this.taskFinishListenerList = new ArrayList<>();
190+
}
191+
192+
this.taskFinishListenerList.add(finishListener);
193+
return this;
194+
}
195+
175196
}

0 commit comments

Comments
 (0)
Failed to load comments.