Ejemplo n.º 1
0
  /**
   * @param activity that supports onCreateDialog({@link #PROGRESS_DIALOG}) and returns @param
   *     progressdialog
   * @param progressDialog - it should be exactly the same as onCreateDialog
   * @return
   */
  public void checkApplicationIsBeingInitialized(Activity activity, ProgressDialog progressDialog) {
    // start application if it was previously closed
    startApplication();
    synchronized (OsmandApplication.this) {
      if (startDialog != null) {
        try {
          SpecialPhrases.setLanguage(this, osmandSettings);
        } catch (IOException e) {
          LOG.error("I/O exception", e);
          Toast error =
              Toast.makeText(
                  this,
                  "Error while reading the special phrases. Restart OsmAnd if possible",
                  Toast.LENGTH_LONG);
          error.show();
        }

        progressDialog.setTitle(getString(R.string.loading_data));
        progressDialog.setMessage(getString(R.string.reading_indexes));
        activity.showDialog(PROGRESS_DIALOG);
        startDialog.setDialog(progressDialog);
      } else if (startingWarnings != null) {
        showWarnings(startingWarnings, activity);
      }
    }
  }
Ejemplo n.º 2
0
 public void checkApplicationIsBeingInitialized(
     Activity activity, AppInitializeListener listener) {
   // start application if it was previously closed
   startApplication();
   if (listener != null) {
     appInitializer.addListener(listener);
   }
 }
Ejemplo n.º 3
0
  @Override
  public void onCreate() {
    long timeToStart = System.currentTimeMillis();
    super.onCreate();
    settingsAPI = new net.osmand.plus.api.SettingsAPIImpl(this);
    externalServiceAPI = new net.osmand.plus.api.ExternalServiceAPIImpl(this);
    internalToDoAPI = new net.osmand.plus.api.InternalToDoAPIImpl(this);
    internalOsmAndAPI = new net.osmand.plus.api.InternalOsmAndAPIImpl(this);
    sqliteAPI = new SQLiteAPIImpl(this);

    // settings used everywhere so they need to be created first
    osmandSettings = createOsmandSettingsInstance();
    // always update application mode to default
    osmandSettings.APPLICATION_MODE.set(osmandSettings.DEFAULT_APPLICATION_MODE.get());

    routingHelper = new RoutingHelper(this, player);
    taskManager = new OsmAndTaskManager(this);
    manager = new ResourceManager(this);
    daynightHelper = new DayNightHelper(this);
    locationProvider = new OsmAndLocationProvider(this);
    savingTrackHelper = new SavingTrackHelper(this);
    liveMonitoringHelper = new LiveMonitoringHelper(this);
    uiHandler = new Handler();
    rendererRegistry = new RendererRegistry();
    targetPointsHelper = new TargetPointsHelper(this);
    checkPrefferedLocale();
    startApplication();
    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "Time to start application "
              + (System.currentTimeMillis() - timeToStart)
              + " ms. Should be less < 800 ms");
    }
    timeToStart = System.currentTimeMillis();
    OsmandPlugin.initPlugins(this);

    if (LOG.isDebugEnabled()) {
      LOG.debug(
          "Time to init plugins "
              + (System.currentTimeMillis() - timeToStart)
              + " ms. Should be less < 800 ms");
    }
  }
Ejemplo n.º 4
0
  @Override
  public void onCreate() {
    long timeToStart = System.currentTimeMillis();
    if (Version.getAppName(this).equals("OsmAnd~")) {
      if (android.os.Build.VERSION.SDK_INT >= 9) {
        try {
          Class.forName("net.osmand.plus.base.EnableStrictMode").newInstance();
        } catch (Exception e) {
          e.printStackTrace();
        }
      }
    }
    super.onCreate();
    createInUiThread();
    uiHandler = new Handler();
    appCustomization = new OsmAndAppCustomization();
    appCustomization.setup(this);
    osmandSettings = appCustomization.getOsmandSettings();
    externalStorageDirectory = osmandSettings.getExternalStorageDirectory();

    checkPreferredLocale();
    appInitializer.onCreateApplication();
    //		if(!osmandSettings.FOLLOW_THE_ROUTE.get()) {
    //			targetPointsHelper.clearPointToNavigate(false);
    //		}
    startApplication();
    System.out.println(
        "Time to start application "
            + (System.currentTimeMillis() - timeToStart)
            + " ms. Should be less < 800 ms");
    timeToStart = System.currentTimeMillis();
    OsmandPlugin.initPlugins(this);
    System.out.println(
        "Time to init plugins "
            + (System.currentTimeMillis() - timeToStart)
            + " ms. Should be less < 800 ms");

    osmandSettings.NUMBER_OF_APPLICATION_STARTS.set(
        osmandSettings.NUMBER_OF_APPLICATION_STARTS.get() + 1);
  }