From 3095dc353cdf4c2fbc49b799475417e7b1d1ae3e Mon Sep 17 00:00:00 2001 From: Alex Sytnyk Date: Mon, 16 Apr 2018 01:57:27 +0300 Subject: [PATCH] Add small refactoring --- OsmAnd/src/net/osmand/plus/AppInitializer.java | 6 +++++- .../src/net/osmand/plus/activities/MapActivityActions.java | 2 -- .../src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java | 6 +----- 3 files changed, 6 insertions(+), 8 deletions(-) diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 2c12d35383..32de395e28 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -13,7 +13,7 @@ import android.content.res.Configuration; import android.content.res.Resources; import android.os.Build; import android.support.v7.app.AlertDialog; -import android.util.Log; + import net.osmand.IProgress; import net.osmand.IndexConstants; import net.osmand.PlatformUtil; @@ -66,6 +66,7 @@ import java.util.Locale; import java.util.Random; import btools.routingapp.BRouterServiceConnection; + import static net.osmand.plus.liveupdates.LiveUpdatesHelper.getPendingIntent; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLastCheck; import static net.osmand.plus.liveupdates.LiveUpdatesHelper.preferenceLiveUpdatesOn; @@ -446,6 +447,9 @@ public class AppInitializer implements IProgress { app.mapMarkersHelper = startupInit(new MapMarkersHelper(app), MapMarkersHelper.class); app.searchUICore = startupInit(new QuickSearchHelper(app), QuickSearchHelper.class); app.travelDbHelper = startupInit(new TravelDbHelper(app), TravelDbHelper.class); + if (app.getSettings().SELECTED_TRAVEL_BOOK.get() != null) { + app.travelDbHelper.initTravelBooks(); + } initOpeningHoursParser(); } diff --git a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java index 4680db276b..4ecaf1de5e 100644 --- a/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java +++ b/OsmAnd/src/net/osmand/plus/activities/MapActivityActions.java @@ -63,7 +63,6 @@ import net.osmand.plus.views.MapControlsLayer; import net.osmand.plus.views.MapTileLayer; import net.osmand.plus.views.OsmandMapTileView; import net.osmand.plus.wikivoyage.explore.WikivoyageExploreDialogFragment; -import net.osmand.plus.wikivoyage.data.TravelDbHelper; import net.osmand.router.GeneralRouter; import org.apache.commons.logging.Log; @@ -771,7 +770,6 @@ public class MapActivityActions implements DialogProvider { .setListener(new ItemClickListener() { @Override public boolean onContextMenuClick(ArrayAdapter adapter, int itemId, int pos, boolean isChecked, int[] viewCoordinates) { - getMyApplication().getTravelDbHelper().initTravelBooks(); MapActivity.clearPrevActivityIntent(); WikivoyageExploreDialogFragment.showInstance(mapActivity.getSupportFragmentManager()); return true; diff --git a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java index 91ee8efecc..84d67df73f 100644 --- a/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/wikivoyage/data/TravelDbHelper.java @@ -82,13 +82,10 @@ public class TravelDbHelper { public TravelDbHelper(OsmandApplication application) { this.application = application; collator = OsmAndCollator.primaryCollator(); - if (application.getSettings().SELECTED_TRAVEL_BOOK.get() != null) { - initTravelBooks(); - } + localDataHelper = new TravelLocalDataHelper(application); } public TravelLocalDataHelper getLocalDataHelper() { - initTravelBooks(); return localDataHelper; } @@ -100,7 +97,6 @@ public class TravelDbHelper { File[] possibleFiles = application.getAppPath(IndexConstants.WIKIVOYAGE_INDEX_DIR).listFiles(); String travelBook = application.getSettings().SELECTED_TRAVEL_BOOK.get(); existingTravelBooks.clear(); - localDataHelper = new TravelLocalDataHelper(application); if (possibleFiles != null) { for (File f : possibleFiles) { if (f.getName().endsWith(IndexConstants.BINARY_WIKIVOYAGE_MAP_INDEX_EXT)) {