public List<String> reloadIndexesOnStart(AppInitializer progress, List<String> warnings) { close(); // check we have some assets to copy to sdcard warnings.addAll(checkAssets(progress)); progress.notifyEvent(InitEvents.ASSETS_COPIED); reloadIndexes(progress, warnings); progress.notifyEvent(InitEvents.MAPS_INITIALIZED); return warnings; }
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; } } } }