예제 #1
0
  public void updateApplicationModeSettings() {
    // update vector renderer
    RendererRegistry registry = app.getRendererRegistry();
    RenderingRulesStorage newRenderer = registry.getRenderer(settings.RENDERER.get());
    if (newRenderer == null) {
      newRenderer = registry.defaultRender();
    }
    if (registry.getCurrentSelectedRenderer() != newRenderer) {
      registry.setCurrentSelectedRender(newRenderer);
      app.getResourceManager().getRenderer().clearCache();
    }
    mapViewTrackingUtilities.updateSettings();
    app.getRoutingHelper().setAppMode(settings.getApplicationMode());
    if (mapLayers.getMapInfoLayer() != null) {
      mapLayers.getMapInfoLayer().recreateControls();
    }
    mapLayers.updateLayers(mapView);
    app.getDaynightHelper()
        .startSensorIfNeeded(
            new StateChangedListener<Boolean>() {

              @Override
              public void stateChanged(Boolean change) {
                getMapView().refreshMap(true);
              }
            });
    getMapView().refreshMap(true);
  }
예제 #2
0
 protected String getRenderDescr(final MapActivity activity) {
   RendererRegistry rr = activity.getMyApplication().getRendererRegistry();
   RenderingRulesStorage storage = rr.getCurrentSelectedRenderer();
   if (storage == null) {
     return "";
   }
   return storage.getName();
 }
예제 #3
0
 protected void switchApplicationMode(ApplicationMode oldMode) {
   // change some global settings/ for car
   if (currentMode == ApplicationMode.CAR) {
     SHOW_TRANSPORT_OVER_MAP.set(false);
     SHOW_OSM_BUGS.set(false);
   }
   // update vector renderer
   RendererRegistry registry = ctx.getRendererRegistry();
   BaseOsmandRender newRenderer = registry.getRenderer(RENDERER.get());
   if (newRenderer == null) {
     newRenderer = registry.defaultRender();
   }
   if (registry.getCurrentSelectedRenderer() != newRenderer) {
     registry.setCurrentSelectedRender(newRenderer);
     ctx.getResourceManager().getRenderer().clearCache();
   }
 }
예제 #4
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;
        }
      }
    }
  }