예제 #1
0
 private void checkDownloadIsSuccessful(final Download download) {
   int actualProgress = 0;
   int status = Download.DOWNLOADED;
   // If any page has an error, the download result will be error
   for (Page page : download.pages) {
     actualProgress += page.getProgress();
     if (page.getStatus() != Page.READY) status = Download.ERROR;
   }
   // Ensure that the chapter folder has all the images
   if (!isChapterDownloaded(download.directory, download.pages)) {
     status = Download.ERROR;
   }
   download.totalProgress = actualProgress;
   download.setStatus(status);
   // Delete successful downloads from queue after notifying
   if (status == Download.DOWNLOADED) {
     queue.remove(download);
   }
 }