Пример #1
0
 private String reindexFiles(List<File> filesToReindex) {
   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 = app.getResourceManager();
   manager.indexVoiceFiles(this);
   List<String> warnings = new ArrayList<String>();
   if (vectorMapsToReindex) {
     warnings = manager.indexingMaps(this);
   }
   if (cachedSRTMFiles != null) {
     for (SrtmIndexItem i : cachedSRTMFiles) {
       ((SrtmIndexItem) i).updateExistingTiles(app.getResourceManager().getIndexFileNames());
     }
   }
   if (!warnings.isEmpty()) {
     return warnings.get(0);
   }
   return null;
 }
Пример #2
0
  public void closeApplicationAnywayImpl(final Activity activity, boolean disableService) {
    if (appInitializer.isAppInitializing()) {
      resourceManager.close();
    }
    activity.finish();
    if (getNavigationService() == null) {
      fullExit();
    } else if (disableService) {
      final Intent serviceIntent = new Intent(this, NavigationService.class);
      stopService(serviceIntent);

      new Thread(
              new Runnable() {
                public void run() {
                  // wait until the service has fully stopped
                  while (getNavigationService() != null) {
                    try {
                      Thread.sleep(100);
                    } catch (InterruptedException e) {
                    }
                  }

                  fullExit();
                }
              })
          .start();
    }
  }
Пример #3
0
 public boolean downloadFile(DownloadEntry de, List<File> filesToReindex, boolean forceWifi)
     throws InterruptedException {
   boolean res = false;
   if (de.isAsset) {
     try {
       if (uiActivity != null) {
         ResourceManager.copyAssets(uiActivity.getAssets(), de.assetName, de.targetFile);
         boolean changedDate = de.targetFile.setLastModified(de.dateModified);
         if (!changedDate) {
           log.error("Set last timestamp is not supported");
         }
         res = true;
       }
     } catch (IOException e) {
       log.error("Copy exception", e);
     }
   } else {
     res = downloadFileHelper.downloadFile(de, this, filesToReindex, this, forceWifi);
   }
   if (res && de.attachedEntry != null) {
     return downloadFile(de.attachedEntry, filesToReindex, forceWifi);
   }
   return res;
 }
Пример #4
0
 @Override
 public void onLowMemory() {
   super.onLowMemory();
   resourceManager.onLowMemory();
 }
Пример #5
0
  private void startApplicationBackground() {
    List<String> warnings = new ArrayList<String>();
    try {
      if (!Version.isBlackberry(this)) {
        if (osmandSettings.NATIVE_RENDERING_FAILED.get()) {
          osmandSettings.SAFE_MODE.set(true);
          osmandSettings.NATIVE_RENDERING_FAILED.set(false);
          warnings.add(getString(R.string.native_library_not_supported));
        } else if (!osmandSettings.SAFE_MODE.get()) {
          osmandSettings.NATIVE_RENDERING_FAILED.set(true);
          startDialog.startTask(getString(R.string.init_native_library), -1);
          RenderingRulesStorage storage = rendererRegistry.getCurrentSelectedRenderer();
          boolean initialized = NativeOsmandLibrary.getLibrary(storage, this) != null;
          osmandSettings.NATIVE_RENDERING_FAILED.set(false);
          if (!initialized) {
            LOG.info("Native library could not be loaded!");
          }
        } else {
          warnings.add(getString(R.string.native_library_not_running));
        }
      }
      warnings.addAll(manager.reloadIndexes(startDialog));
      player = null;
      if (savingTrackHelper.hasDataToSave()) {
        startDialog.startTask(getString(R.string.saving_gpx_tracks), -1);
        warnings.addAll(savingTrackHelper.saveDataToGpx());
      }

      // restore backuped favorites to normal file
      final File appDir = getAppPath(null);
      File save = new File(appDir, FavouritesDbHelper.FILE_TO_SAVE);
      File bak = new File(appDir, FavouritesDbHelper.FILE_TO_BACKUP);
      if (bak.exists() && (!save.exists() || bak.lastModified() > save.lastModified())) {
        if (save.exists()) {
          save.delete();
        }
        bak.renameTo(save);
      }
    } finally {
      synchronized (OsmandApplication.this) {
        final ProgressDialog toDismiss;
        if (startDialog != null) {
          toDismiss = startDialog.getDialog();
        } else {
          toDismiss = null;
        }
        startDialog = null;

        if (toDismiss != null) {
          uiHandler.post(
              new Runnable() {
                @Override
                public void run() {
                  if (toDismiss != null) {
                    // TODO handling this dialog is bad, we need a better standard way
                    toDismiss.dismiss();
                    // toDismiss.getOwnerActivity().dismissDialog(PROGRESS_DIALOG);
                  }
                }
              });
          showWarnings(warnings, toDismiss.getContext());
        } else {
          startingWarnings = warnings;
        }
      }
    }
  }
Пример #6
0
 @Override
 public void onLowMemory() {
   super.onLowMemory();
   manager.onLowMemory();
 }