File tree Expand file tree Collapse file tree 3 files changed +11
-23
lines changed 
library/src/main/java/com/liulishuo/filedownloader Expand file tree Collapse file tree 3 files changed +11
-23
lines changed Original file line number Diff line number Diff line change 2121import  android .os .Message ;
2222
2323import  com .liulishuo .filedownloader .util .FileDownloadExecutors ;
24- import  com .liulishuo .filedownloader .util .FileDownloadLog ;
2524
2625import  java .util .ArrayList ;
2726import  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 ();
Original file line number Diff line number Diff 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 ) {
Original file line number Diff line number Diff 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. 
    
 
   
 
     
   
   
          
     
  
    
     
 
    
      
     
 
     
    You can’t perform that action at this time.
  
 
    
  
     
    
      
        
     
 
       
      
     
   
 
    
    
  
 
  
 
     
    
0 commit comments