diff --git a/OsmAnd/src/net/osmand/plus/AppInitializer.java b/OsmAnd/src/net/osmand/plus/AppInitializer.java index 819590a516..7d3afbffcd 100644 --- a/OsmAnd/src/net/osmand/plus/AppInitializer.java +++ b/OsmAnd/src/net/osmand/plus/AppInitializer.java @@ -39,6 +39,7 @@ import net.osmand.plus.helpers.DayNightHelper; import net.osmand.plus.helpers.LockHelper; import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.inapp.InAppPurchaseHelperImpl; +import net.osmand.plus.itinerary.ItineraryHelper; import net.osmand.plus.liveupdates.LiveUpdatesHelper; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; import net.osmand.plus.mapmarkers.MapMarkersHelper; @@ -471,6 +472,7 @@ public class AppInitializer implements IProgress { app.osmOAuthHelper = startupInit(new OsmOAuthHelper(app), OsmOAuthHelper.class); app.oprAuthHelper = startupInit(new OprAuthHelper(app), OprAuthHelper.class); app.onlineRoutingHelper = startupInit(new OnlineRoutingHelper(app), OnlineRoutingHelper.class); + app.itineraryHelper = startupInit(new ItineraryHelper(app), ItineraryHelper.class); initOpeningHoursParser(); } diff --git a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java index 9fffc074c2..151737a157 100644 --- a/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java +++ b/OsmAnd/src/net/osmand/plus/FavouritesDbHelper.java @@ -272,10 +272,9 @@ public class FavouritesDbHelper { } private void runSyncWithMarkers(FavoriteGroup favGroup) { - MapMarkersHelper helper = context.getMapMarkersHelper(); - MapMarkersGroup group = helper.getMarkersGroup(favGroup); + MapMarkersGroup group = context.getMapMarkersHelper().getMarkersGroup(favGroup); if (group != null) { - helper.runSynchronization(group); + context.getItineraryHelper().runSynchronization(group); } } diff --git a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java index 66dbb1c75e..82b101b2a1 100644 --- a/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java +++ b/OsmAnd/src/net/osmand/plus/GpxSelectionHelper.java @@ -31,7 +31,6 @@ import net.osmand.plus.helpers.GpxUiHelper.GPXInfo; import net.osmand.plus.helpers.SearchHistoryHelper; import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.mapmarkers.MapMarkersGroup; -import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.routing.GPXRouteParams.GPXRouteParamsBuilder; import net.osmand.plus.track.GpxSplitType; import net.osmand.util.Algorithms; @@ -823,10 +822,9 @@ public class GpxSelectionHelper { } private void syncGpxWithMarkers(GPXFile gpxFile) { - MapMarkersHelper mapMarkersHelper = app.getMapMarkersHelper(); - MapMarkersGroup group = mapMarkersHelper.getMarkersGroup(gpxFile); + MapMarkersGroup group = app.getMapMarkersHelper().getMarkersGroup(gpxFile); if (group != null) { - mapMarkersHelper.runSynchronization(group); + app.getItineraryHelper().runSynchronization(group); } } diff --git a/OsmAnd/src/net/osmand/plus/OsmandApplication.java b/OsmAnd/src/net/osmand/plus/OsmandApplication.java index 8f89660c00..731960e66e 100644 --- a/OsmAnd/src/net/osmand/plus/OsmandApplication.java +++ b/OsmAnd/src/net/osmand/plus/OsmandApplication.java @@ -24,6 +24,13 @@ import android.view.View; import android.view.accessibility.AccessibilityManager; import android.widget.Toast; +import androidx.annotation.NonNull; +import androidx.annotation.Nullable; +import androidx.appcompat.app.AlertDialog; +import androidx.appcompat.app.AppCompatDelegate; +import androidx.multidex.MultiDex; +import androidx.multidex.MultiDexApplication; + import net.osmand.AndroidUtils; import net.osmand.FileUtils; import net.osmand.IndexConstants; @@ -59,6 +66,7 @@ import net.osmand.plus.helpers.WaypointHelper; import net.osmand.plus.helpers.enums.DrivingRegion; import net.osmand.plus.helpers.enums.MetricsConstants; import net.osmand.plus.inapp.InAppPurchaseHelper; +import net.osmand.plus.itinerary.ItineraryHelper; import net.osmand.plus.mapmarkers.MapMarkersDbHelper; import net.osmand.plus.mapmarkers.MapMarkersHelper; import net.osmand.plus.measurementtool.MeasurementEditingContext; @@ -99,12 +107,6 @@ import java.util.Map; import java.util.UUID; import java.util.concurrent.ConcurrentHashMap; -import androidx.annotation.NonNull; -import androidx.annotation.Nullable; -import androidx.appcompat.app.AlertDialog; -import androidx.appcompat.app.AppCompatDelegate; -import androidx.multidex.MultiDex; -import androidx.multidex.MultiDexApplication; import btools.routingapp.BRouterServiceConnection; import btools.routingapp.IBRouterService; @@ -166,6 +168,7 @@ public class OsmandApplication extends MultiDexApplication { OprAuthHelper oprAuthHelper; MeasurementEditingContext measurementEditingContext; OnlineRoutingHelper onlineRoutingHelper; + ItineraryHelper itineraryHelper; private Map customRoutingConfigs = new ConcurrentHashMap<>(); private File externalStorageDirectory; @@ -467,6 +470,10 @@ public class OsmandApplication extends MultiDexApplication { return onlineRoutingHelper; } + public ItineraryHelper getItineraryHelper() { + return itineraryHelper; + } + public TransportRoutingHelper getTransportRoutingHelper() { return transportRoutingHelper; } diff --git a/OsmAnd/src/net/osmand/plus/itinerary/ItineraryHelper.java b/OsmAnd/src/net/osmand/plus/itinerary/ItineraryHelper.java new file mode 100644 index 0000000000..8e3c96a08a --- /dev/null +++ b/OsmAnd/src/net/osmand/plus/itinerary/ItineraryHelper.java @@ -0,0 +1,152 @@ +package net.osmand.plus.itinerary; + +import android.os.AsyncTask; + +import androidx.annotation.NonNull; + +import net.osmand.GPXUtilities.GPXFile; +import net.osmand.GPXUtilities.WptPt; +import net.osmand.PlatformUtil; +import net.osmand.data.FavouritePoint; +import net.osmand.data.LatLon; +import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; +import net.osmand.plus.GpxSelectionHelper; +import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; +import net.osmand.plus.OsmandApplication; +import net.osmand.plus.mapmarkers.MapMarker; +import net.osmand.plus.mapmarkers.MapMarkersGroup; +import net.osmand.plus.mapmarkers.MapMarkersHelper; +import net.osmand.plus.mapmarkers.MapMarkersHelper.OnGroupSyncedListener; + +import org.apache.commons.logging.Log; + +import java.io.File; +import java.util.ArrayList; +import java.util.HashSet; +import java.util.List; +import java.util.Set; +import java.util.concurrent.ExecutorService; +import java.util.concurrent.Executors; + +public class ItineraryHelper { + + private static final Log LOG = PlatformUtil.getLog(ItineraryHelper.class); + + private OsmandApplication app; + + private MapMarkersHelper markersHelper; + + private ExecutorService executorService = Executors.newSingleThreadExecutor(); + + private Set syncListeners = new HashSet<>(); + + public ItineraryHelper(@NonNull OsmandApplication app) { + this.app = app; + markersHelper = app.getMapMarkersHelper(); + } + + public void addSyncListener(OnGroupSyncedListener listener) { + syncListeners.add(listener); + } + + public void removeSyncListener(OnGroupSyncedListener listener) { + syncListeners.remove(listener); + } + + public void runSynchronization(final @NonNull MapMarkersGroup group) { + app.runInUIThread(new Runnable() { + @Override + public void run() { + new SyncGroupTask(group).executeOnExecutor(executorService); + } + }); + } + + private class SyncGroupTask extends AsyncTask { + + private MapMarkersGroup group; + + SyncGroupTask(MapMarkersGroup group) { + this.group = group; + } + + @Override + protected void onPreExecute() { + if (!syncListeners.isEmpty()) { + app.runInUIThread(new Runnable() { + @Override + public void run() { + for (OnGroupSyncedListener listener : syncListeners) { + listener.onSyncStarted(); + } + } + }); + } + } + + @Override + protected Void doInBackground(Void... voids) { + runGroupSynchronization(); + return null; + } + + // TODO extract method from Asynctask to Helper directly + private void runGroupSynchronization() { + List groupMarkers = new ArrayList<>(group.getMarkers()); + if (group.getType() == MapMarkersGroup.FAVORITES_TYPE) { + FavoriteGroup favGroup = app.getFavorites().getGroup(group.getName()); + if (favGroup == null) { + return; + } + group.setVisible(favGroup.isVisible()); + if (!group.isVisible() || group.isDisabled()) { + markersHelper.removeGroupActiveMarkers(group, true); + return; + } + List points = new ArrayList<>(favGroup.getPoints()); + for (FavouritePoint fp : points) { + markersHelper.addNewMarkerIfNeeded(group, groupMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), fp, null); + } + } else if (group.getType() == MapMarkersGroup.GPX_TYPE) { + GpxSelectionHelper gpxHelper = app.getSelectedGpxHelper(); + File file = new File(group.getId()); + if (!file.exists()) { + return; + } + + String gpxPath = group.getId(); + SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(gpxPath); + GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile(); + group.setVisible(gpx != null || group.isVisibleUntilRestart()); + if (gpx == null || group.isDisabled()) { + markersHelper.removeGroupActiveMarkers(group, true); + return; + } + + boolean addAll = group.getWptCategories() == null || group.getWptCategories().isEmpty(); + List gpxPoints = new ArrayList<>(gpx.getPoints()); + for (WptPt pt : gpxPoints) { + if (addAll || group.getWptCategories().contains(pt.category) + || (pt.category == null && group.getWptCategories().contains(""))) { + markersHelper.addNewMarkerIfNeeded(group, groupMarkers, new LatLon(pt.lat, pt.lon), pt.name, null, pt); + } + } + } + markersHelper.removeOldMarkersIfPresent(groupMarkers); + } + + @Override + protected void onPostExecute(Void aVoid) { + if (!syncListeners.isEmpty()) { + app.runInUIThread(new Runnable() { + @Override + public void run() { + for (OnGroupSyncedListener listener : syncListeners) { + listener.onSyncDone(); + } + } + }); + } + } + } +} \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java index 2d0654301b..e1c1ac3d61 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragment.java @@ -17,8 +17,6 @@ import net.osmand.GPXUtilities.WptPt; import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.activities.MapActivity; @@ -26,6 +24,7 @@ import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.track.SaveGpxAsyncTask; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.util.Algorithms; @@ -220,10 +219,9 @@ public class WptPtEditorFragment extends PointEditorFragment { private void syncGpx(GPXFile gpxFile) { OsmandApplication app = getMyApplication(); if (app != null) { - MapMarkersHelper helper = app.getMapMarkersHelper(); - MapMarkersGroup group = helper.getMarkersGroup(gpxFile); + MapMarkersGroup group = app.getMapMarkersHelper().getMarkersGroup(gpxFile); if (group != null) { - helper.runSynchronization(group); + app.getItineraryHelper().runSynchronization(group); } } } diff --git a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java index ae30904896..afb86d2e5c 100644 --- a/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java +++ b/OsmAnd/src/net/osmand/plus/mapcontextmenu/editors/WptPtEditorFragmentNew.java @@ -20,8 +20,6 @@ import net.osmand.data.FavouritePoint.BackgroundType; import net.osmand.data.LatLon; import net.osmand.data.WptLocationPoint; import net.osmand.plus.GpxSelectionHelper; -import net.osmand.plus.mapmarkers.MapMarkersHelper; -import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; import net.osmand.plus.UiUtilities; @@ -30,6 +28,7 @@ import net.osmand.plus.activities.SavingTrackHelper; import net.osmand.plus.base.PointImageDrawable; import net.osmand.plus.mapcontextmenu.MapContextMenu; import net.osmand.plus.mapcontextmenu.editors.WptPtEditor.OnDismissListener; +import net.osmand.plus.mapmarkers.MapMarkersGroup; import net.osmand.plus.track.SaveGpxAsyncTask; import net.osmand.plus.track.SaveGpxAsyncTask.SaveGpxListener; import net.osmand.util.Algorithms; @@ -236,10 +235,9 @@ public class WptPtEditorFragmentNew extends PointEditorFragmentNew { private void syncGpx(GPXFile gpxFile) { OsmandApplication app = getMyApplication(); if (app != null) { - MapMarkersHelper helper = app.getMapMarkersHelper(); - MapMarkersGroup group = helper.getMarkersGroup(gpxFile); + MapMarkersGroup group = app.getMapMarkersHelper().getMarkersGroup(gpxFile); if (group != null) { - helper.runSynchronization(group); + app.getItineraryHelper().runSynchronization(group); } } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java index 96d6f9a8f4..31e477fbf1 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/CoordinateInputDialogFragment.java @@ -171,7 +171,7 @@ public class CoordinateInputDialogFragment extends DialogFragment implements Osm MapMarkersHelper helper = getMyApplication().getMapMarkersHelper(); MapMarkersGroup group = helper.getMarkersGroup(gpxFile); if (group != null) { - helper.runSynchronization(group); + getMyApplication().getItineraryHelper().runSynchronization(group); } } diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java index f0b226dd1e..ad453d5fe5 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersDialogFragment.java @@ -218,13 +218,13 @@ public class MapMarkersDialogFragment extends DialogFragment implements OnGroupS @Override public void onResume() { super.onResume(); - getMyApplication().getMapMarkersHelper().addSyncListener(this); + getMyApplication().getItineraryHelper().addSyncListener(this); } @Override public void onPause() { super.onPause(); - getMyApplication().getMapMarkersHelper().removeSyncListener(this); + getMyApplication().getItineraryHelper().removeSyncListener(this); } @Override diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java index 51911e8779..b8bcddbc5c 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/MapMarkersHelper.java @@ -1,7 +1,5 @@ package net.osmand.plus.mapmarkers; -import android.os.AsyncTask; - import androidx.annotation.IntDef; import androidx.annotation.NonNull; import androidx.annotation.Nullable; @@ -20,7 +18,6 @@ import net.osmand.plus.FavouritesDbHelper.FavoriteGroup; import net.osmand.plus.GPXDatabase; import net.osmand.plus.GeocodingLookupService; import net.osmand.plus.GeocodingLookupService.AddressLookupRequest; -import net.osmand.plus.GpxSelectionHelper; import net.osmand.plus.GpxSelectionHelper.SelectedGpxFile; import net.osmand.plus.OsmandApplication; import net.osmand.plus.R; @@ -41,15 +38,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.Date; -import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Locale; import java.util.Map; import java.util.Set; import java.util.TimeZone; -import java.util.concurrent.ExecutorService; -import java.util.concurrent.Executors; import static net.osmand.GPXUtilities.GPX_TIME_FORMAT; import static net.osmand.data.PointDescription.POINT_TYPE_MAP_MARKER; @@ -78,14 +72,11 @@ public class MapMarkersHelper { private OsmandApplication ctx; private MapMarkersDbHelper markersDbHelper; - private ExecutorService executorService = Executors.newSingleThreadExecutor(); - private List mapMarkers = new ArrayList<>(); private List mapMarkersHistory = new ArrayList<>(); private List mapMarkersGroups = new ArrayList<>(); private List listeners = new ArrayList<>(); - private Set syncListeners = new HashSet<>(); private MarkersPlanRouteContext planRouteContext; @@ -186,7 +177,7 @@ public class MapMarkersHelper { public void syncAllGroupsAsync() { for (MapMarkersGroup gr : mapMarkersGroups) { if (gr.getId() != null && gr.getName() != null) { - runSynchronization(gr); + ctx.getItineraryHelper().runSynchronization(gr); } } } @@ -303,15 +294,6 @@ public class MapMarkersHelper { }); } - public void runSynchronization(final @NonNull MapMarkersGroup group) { - ctx.runInUIThread(new Runnable() { - @Override - public void run() { - new SyncGroupTask(group).executeOnExecutor(executorService); - } - }); - } - public MapMarkersGroup getMarkersGroup(GPXFile gpx) { if (gpx == null || gpx.path == null) { return null; @@ -363,7 +345,7 @@ public class MapMarkersHelper { if (gr.isDisabled()) { updateGroupDisabled(gr, false); } - runSynchronization(gr); + ctx.getItineraryHelper().runSynchronization(gr); } private void addGroupInternally(MapMarkersGroup gr) { @@ -415,7 +397,7 @@ public class MapMarkersHelper { } } - private void removeGroupActiveMarkers(MapMarkersGroup group, boolean updateGroup) { + public void removeGroupActiveMarkers(MapMarkersGroup group, boolean updateGroup) { if (group != null) { markersDbHelper.removeActiveMarkersFromGroup(group.getId()); removeFromMapMarkersList(group.getActiveMarkers()); @@ -636,12 +618,12 @@ public class MapMarkersHelper { return null; } - private void addNewMarkerIfNeeded(@NonNull MapMarkersGroup group, - @NonNull List groupMarkers, - @NonNull LatLon latLon, - @NonNull String name, - @Nullable FavouritePoint favouritePoint, - @Nullable WptPt wptPt) { + public void addNewMarkerIfNeeded(@NonNull MapMarkersGroup group, + @NonNull List groupMarkers, + @NonNull LatLon latLon, + @NonNull String name, + @Nullable FavouritePoint favouritePoint, + @Nullable WptPt wptPt) { boolean exists = false; Iterator iterator = groupMarkers.iterator(); @@ -671,7 +653,7 @@ public class MapMarkersHelper { } } - private void removeOldMarkersIfPresent(List markers) { + public void removeOldMarkersIfPresent(List markers) { if (!markers.isEmpty()) { boolean needRefresh = false; for (MapMarker marker : markers) { @@ -970,14 +952,6 @@ public class MapMarkersHelper { } } - public void addSyncListener(OnGroupSyncedListener listener) { - syncListeners.add(listener); - } - - public void removeSyncListener(OnGroupSyncedListener listener) { - syncListeners.remove(listener); - } - public void addListener(MapMarkerChangedListener l) { if (!listeners.contains(l)) { listeners.add(l); @@ -1194,93 +1168,4 @@ public class MapMarkersHelper { void onSyncDone(); } - - private class SyncGroupTask extends AsyncTask { - - private MapMarkersGroup group; - - SyncGroupTask(MapMarkersGroup group) { - this.group = group; - } - - @Override - protected void onPreExecute() { - if (!syncListeners.isEmpty()) { - ctx.runInUIThread(new Runnable() { - @Override - public void run() { - for (OnGroupSyncedListener listener : syncListeners) { - listener.onSyncStarted(); - } - } - }); - } - } - - @Override - protected Void doInBackground(Void... voids) { - runGroupSynchronization(); - return null; - } - - // TODO extract method from Asynctask to Helper directly - private void runGroupSynchronization() { - List groupMarkers = new ArrayList<>(group.getMarkers()); - if (group.getType() == MapMarkersGroup.FAVORITES_TYPE) { - FavoriteGroup favGroup = ctx.getFavorites().getGroup(group.getName()); - if (favGroup == null) { - return; - } - group.setVisible(favGroup.isVisible()); - if (!group.isVisible() || group.isDisabled()) { - removeGroupActiveMarkers(group, true); - return; - } - List points = new ArrayList<>(favGroup.getPoints()); - for (FavouritePoint fp : points) { - addNewMarkerIfNeeded(group, groupMarkers, new LatLon(fp.getLatitude(), fp.getLongitude()), fp.getName(), fp, null); - } - } else if (group.getType() == MapMarkersGroup.GPX_TYPE) { - GpxSelectionHelper gpxHelper = ctx.getSelectedGpxHelper(); - File file = new File(group.getId()); - if (!file.exists()) { - return; - } - - String gpxPath = group.getId(); - SelectedGpxFile selectedGpxFile = gpxHelper.getSelectedFileByPath(gpxPath); - GPXFile gpx = selectedGpxFile == null ? null : selectedGpxFile.getGpxFile(); - group.setVisible(gpx != null || group.isVisibleUntilRestart()); - if (gpx == null || group.isDisabled()) { - removeGroupActiveMarkers(group, true); - return; - } - - boolean addAll = group.getWptCategories() == null || group.getWptCategories().isEmpty(); - List gpxPoints = new ArrayList<>(gpx.getPoints()); - for (WptPt pt : gpxPoints) { - if (addAll || group.getWptCategories().contains(pt.category) - || (pt.category == null && group.getWptCategories().contains(""))) { - addNewMarkerIfNeeded(group, groupMarkers, new LatLon(pt.lat, pt.lon), pt.name, null, pt); - } - } - } - - removeOldMarkersIfPresent(groupMarkers); - } - - @Override - protected void onPostExecute(Void aVoid) { - if (!syncListeners.isEmpty()) { - ctx.runInUIThread(new Runnable() { - @Override - public void run() { - for (OnGroupSyncedListener listener : syncListeners) { - listener.onSyncDone(); - } - } - }); - } - } - } } \ No newline at end of file diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java index 08db4d40fc..1f86a94a1d 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/SelectWptCategoriesBottomSheetDialogFragment.java @@ -147,7 +147,7 @@ public class SelectWptCategoriesBottomSheetDialogFragment extends MenuBottomShee group = mapMarkersHelper.addOrEnableGroup(gpxFile); } mapMarkersHelper.updateGroupWptCategories(group, selectedCategories); - mapMarkersHelper.runSynchronization(group); + app.getItineraryHelper().runSynchronization(group); } private boolean isAllChecked() { diff --git a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java index fb74956b16..4992ee88be 100644 --- a/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java +++ b/OsmAnd/src/net/osmand/plus/mapmarkers/adapters/MapMarkersGroupsAdapter.java @@ -478,7 +478,7 @@ public class MapMarkersGroupsAdapter extends RecyclerView.Adapter { } private void syncGpx(GPXFile gpxFile) { - MapMarkersHelper helper = app.getMapMarkersHelper(); - MapMarkersGroup group = helper.getMarkersGroup(gpxFile); + MapMarkersGroup group = app.getMapMarkersHelper().getMarkersGroup(gpxFile); if (group != null) { - helper.runSynchronization(group); + app.getItineraryHelper().runSynchronization(group); } } diff --git a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java index 674ee76042..b3ff9b91bd 100644 --- a/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java +++ b/OsmAnd/src/net/osmand/plus/myplaces/EditTrackGroupDialogFragment.java @@ -236,7 +236,7 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment } else { mapMarkersHelper.updateGroupWptCategories(markersGroup, selectedCategories); if (!groupCreated) { - mapMarkersHelper.runSynchronization(markersGroup); + app.getItineraryHelper().runSynchronization(markersGroup); } } } @@ -524,10 +524,9 @@ public class EditTrackGroupDialogFragment extends MenuBottomSheetDialogFragment } private void syncGpx(GPXFile gpxFile) { - MapMarkersHelper markersHelper = app.getMapMarkersHelper(); - MapMarkersGroup group = markersHelper.getMarkersGroup(gpxFile); + MapMarkersGroup group = app.getMapMarkersHelper().getMarkersGroup(gpxFile); if (group != null) { - markersHelper.runSynchronization(group); + app.getItineraryHelper().runSynchronization(group); } } } diff --git a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java index 339192e6b6..dfc2cbf426 100644 --- a/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java +++ b/OsmAnd/src/net/osmand/plus/views/layers/GPXLayer.java @@ -1079,7 +1079,7 @@ public class GPXLayer extends OsmandMapLayer implements IContextMenuProvider, IM private void syncGpx(GPXFile gpxFile) { MapMarkersGroup group = view.getApplication().getMapMarkersHelper().getMarkersGroup(gpxFile); if (group != null) { - mapMarkersHelper.runSynchronization(group); + view.getApplication().getItineraryHelper().runSynchronization(group); } } } \ No newline at end of file