예제 #1
0
 @Override
 protected String doInBackground(String... filesToDownload) {
   try {
     List<File> filesToReindex = new ArrayList<File>();
     boolean forceWifi = downloadFileHelper.isWifiConnected();
     for (int i = 0; i < filesToDownload.length; i++) {
       String filename = filesToDownload[i];
       DownloadEntry entry = entriesToDownload.get(filename);
       if (entry != null) {
         String indexOfAllFiles =
             filesToDownload.length <= 1
                 ? ""
                 : (" [" + (i + 1) + "/" + filesToDownload.length + "]");
         boolean result =
             entry.downloadFile(
                 downloadFileHelper,
                 filename,
                 filesToReindex,
                 progress,
                 indexOfAllFiles,
                 this,
                 forceWifi,
                 getAssets());
         if (result) {
           entriesToDownload.remove(filename);
           downloads.set(downloads.get() + 1);
           if (entry.existingBackupFile != null) {
             Algoritms.removeAllFiles(entry.existingBackupFile);
           }
           publishProgress(entry);
         }
       }
     }
     boolean vectorMapsToReindex = false;
     for (File f : filesToReindex) {
       if (f.getName().endsWith(IndexConstants.BINARY_MAP_INDEX_EXT)) {
         vectorMapsToReindex = true;
         break;
       }
     }
     // reindex vector maps all at one time
     ResourceManager manager = getMyApplication().getResourceManager();
     manager.indexVoiceFiles(progress);
     if (vectorMapsToReindex) {
       List<String> warnings = manager.indexingMaps(progress);
       if (!warnings.isEmpty()) {
         return warnings.get(0);
       }
     }
   } catch (InterruptedException e) {
     // do not dismiss dialog
   } finally {
     if (progressFileDlg != null) {
       removeDialog(DIALOG_PROGRESS_FILE);
       progressFileDlg = null;
     }
   }
   return null;
 }