@@ -214,6 +214,14 @@ public boolean handleMessage(final Message msg) {
214
214
return true ;
215
215
}
216
216
217
+ final BaseDownloadTask task = this .list .get (msg .arg1 );
218
+ if (!FileDownloadList .getImpl ().contains (task )) {
219
+ // pause?
220
+ FileDownloadLog .d (SerialHandlerCallback .class , "direct go next by not contains %s %d" , task , msg .arg1 );
221
+ goNext (msg .arg1 + 1 );
222
+ return true ;
223
+ }
224
+
217
225
list .get (msg .arg1 )
218
226
.setFinishListener (new BaseDownloadTask .FinishListener () {
219
227
private int index ;
@@ -225,20 +233,29 @@ public BaseDownloadTask.FinishListener setIndex(int index) {
225
233
226
234
@ Override
227
235
public void over () {
228
- Message nextMsg = SerialHandlerCallback .this .handler .obtainMessage ();
229
- nextMsg .what = WHAT_SERIAL_NEXT ;
230
- nextMsg .arg1 = this .index ;
231
- FileDownloadLog .d (SerialHandlerCallback .class , "start next %s %s" ,
232
- SerialHandlerCallback .this .list == null ? null : SerialHandlerCallback .this .list .get (0 ) == null ? null :
233
- SerialHandlerCallback .this .list .get (0 ).getListener (), nextMsg .arg1 );
234
- SerialHandlerCallback .this .handler .sendMessage (nextMsg );
236
+ goNext (this .index );
235
237
}
236
238
}.setIndex (msg .arg1 + 1 ))
237
239
.start ();
238
240
239
241
}
240
242
return true ;
241
243
}
244
+
245
+ private void goNext (final int nextIndex ) {
246
+ if (this .handler == null || this .list == null ) {
247
+ FileDownloadLog .w (this , "need go next %d, but params is not ready %s %s" , nextIndex , this .handler , this .list );
248
+ return ;
249
+ }
250
+
251
+ Message nextMsg = this .handler .obtainMessage ();
252
+ nextMsg .what = WHAT_SERIAL_NEXT ;
253
+ nextMsg .arg1 = nextIndex ;
254
+ FileDownloadLog .d (SerialHandlerCallback .class , "start next %s %s" ,
255
+ this .list == null ? null : this .list .get (0 ) == null ? null :
256
+ this .list .get (0 ).getListener (), nextMsg .arg1 );
257
+ this .handler .sendMessage (nextMsg );
258
+ }
242
259
}
243
260
244
261
}
0 commit comments