Search in sources :

Example 1 with ParkingPositionPlugin

use of net.osmand.plus.plugins.parking.ParkingPositionPlugin in project Osmand by osmandapp.

the class FavoritesSettingsItem method apply.

@Override
public void apply() {
    List<FavoriteGroup> newItems = getNewItems();
    if (personalGroup != null) {
        duplicateItems.add(personalGroup);
    }
    if (!newItems.isEmpty() || !duplicateItems.isEmpty()) {
        appliedItems = new ArrayList<>(newItems);
        for (FavoriteGroup duplicate : duplicateItems) {
            boolean isPersonal = duplicate.isPersonal();
            boolean replace = shouldReplace || isPersonal;
            if (replace) {
                FavoriteGroup existingGroup = favoritesHelper.getGroup(duplicate.getName());
                if (existingGroup != null) {
                    List<FavouritePoint> favouritePoints = new ArrayList<>(existingGroup.getPoints());
                    for (FavouritePoint favouritePoint : favouritePoints) {
                        favoritesHelper.deleteFavourite(favouritePoint, false);
                    }
                }
            }
            if (!isPersonal) {
                appliedItems.add(shouldReplace ? duplicate : renameItem(duplicate));
            } else {
                for (FavouritePoint item : duplicate.getPoints()) {
                    if (item.getSpecialPointType() == FavouritePoint.SpecialPointType.PARKING) {
                        ParkingPositionPlugin plugin = OsmandPlugin.getPlugin(ParkingPositionPlugin.class);
                        if (plugin != null) {
                            plugin.clearParkingPosition();
                            boolean isTimeRestricted = item.getTimestamp() > 0;
                            plugin.setParkingType(isTimeRestricted);
                            plugin.setParkingTime(isTimeRestricted ? item.getTimestamp() : 0);
                            plugin.setParkingStartTime(item.getCreationDate());
                            plugin.setParkingPosition(item.getLatitude(), item.getLongitude());
                            plugin.addOrRemoveParkingEvent(item.getCalendarEvent());
                            if (item.getCalendarEvent()) {
                                plugin.addCalendarEvent(app);
                            }
                        }
                    }
                }
            }
        }
        List<FavouritePoint> favourites = getPointsFromGroups(appliedItems);
        for (FavouritePoint favourite : favourites) {
            favoritesHelper.addFavourite(favourite, false, false);
        }
        favoritesHelper.sortAll();
        favoritesHelper.saveCurrentPointsIntoFile();
        favoritesHelper.loadFavorites();
    }
}
Also used : ParkingPositionPlugin(net.osmand.plus.plugins.parking.ParkingPositionPlugin) FavouritePoint(net.osmand.data.FavouritePoint) FavoriteGroup(net.osmand.plus.myplaces.FavoriteGroup) ArrayList(java.util.ArrayList)

Example 2 with ParkingPositionPlugin

use of net.osmand.plus.plugins.parking.ParkingPositionPlugin in project Osmand by osmandapp.

the class OsmandPlugin method initPlugins.

public static void initPlugins(@NonNull OsmandApplication app) {
    Set<String> enabledPlugins = app.getSettings().getEnabledPlugins();
    allPlugins.clear();
    allPlugins.add(new WikipediaPlugin(app));
    allPlugins.add(new OsmandRasterMapsPlugin(app));
    allPlugins.add(new OsmandMonitoringPlugin(app));
    checkMarketPlugin(app, new SRTMPlugin(app));
    checkMarketPlugin(app, new NauticalMapsPlugin(app));
    checkMarketPlugin(app, new SkiMapsPlugin(app));
    allPlugins.add(new AudioVideoNotesPlugin(app));
    checkMarketPlugin(app, new ParkingPositionPlugin(app));
    allPlugins.add(new OsmEditingPlugin(app));
    allPlugins.add(new OpenPlaceReviewsPlugin(app));
    allPlugins.add(new MapillaryPlugin(app));
    allPlugins.add(new AccessibilityPlugin(app));
    allPlugins.add(new OsmandDevelopmentPlugin(app));
    loadCustomPlugins(app);
    registerAppInitializingDependedProperties(app);
    enablePluginsByDefault(app, enabledPlugins);
    activatePlugins(app, enabledPlugins);
}
Also used : SRTMPlugin(net.osmand.plus.plugins.srtm.SRTMPlugin) AudioVideoNotesPlugin(net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin) OpenPlaceReviewsPlugin(net.osmand.plus.plugins.openplacereviews.OpenPlaceReviewsPlugin) OsmandMonitoringPlugin(net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin) OsmEditingPlugin(net.osmand.plus.plugins.osmedit.OsmEditingPlugin) MapillaryPlugin(net.osmand.plus.plugins.mapillary.MapillaryPlugin) SkiMapsPlugin(net.osmand.plus.plugins.skimaps.SkiMapsPlugin) ParkingPositionPlugin(net.osmand.plus.plugins.parking.ParkingPositionPlugin) OsmandDevelopmentPlugin(net.osmand.plus.plugins.development.OsmandDevelopmentPlugin) NauticalMapsPlugin(net.osmand.plus.plugins.openseamaps.NauticalMapsPlugin) WikipediaPlugin(net.osmand.plus.wikipedia.WikipediaPlugin) AccessibilityPlugin(net.osmand.plus.plugins.accessibility.AccessibilityPlugin) OsmandRasterMapsPlugin(net.osmand.plus.plugins.rastermaps.OsmandRasterMapsPlugin)

Aggregations

ParkingPositionPlugin (net.osmand.plus.plugins.parking.ParkingPositionPlugin)2 ArrayList (java.util.ArrayList)1 FavouritePoint (net.osmand.data.FavouritePoint)1 FavoriteGroup (net.osmand.plus.myplaces.FavoriteGroup)1 AccessibilityPlugin (net.osmand.plus.plugins.accessibility.AccessibilityPlugin)1 AudioVideoNotesPlugin (net.osmand.plus.plugins.audionotes.AudioVideoNotesPlugin)1 OsmandDevelopmentPlugin (net.osmand.plus.plugins.development.OsmandDevelopmentPlugin)1 MapillaryPlugin (net.osmand.plus.plugins.mapillary.MapillaryPlugin)1 OsmandMonitoringPlugin (net.osmand.plus.plugins.monitoring.OsmandMonitoringPlugin)1 OpenPlaceReviewsPlugin (net.osmand.plus.plugins.openplacereviews.OpenPlaceReviewsPlugin)1 NauticalMapsPlugin (net.osmand.plus.plugins.openseamaps.NauticalMapsPlugin)1 OsmEditingPlugin (net.osmand.plus.plugins.osmedit.OsmEditingPlugin)1 OsmandRasterMapsPlugin (net.osmand.plus.plugins.rastermaps.OsmandRasterMapsPlugin)1 SkiMapsPlugin (net.osmand.plus.plugins.skimaps.SkiMapsPlugin)1 SRTMPlugin (net.osmand.plus.plugins.srtm.SRTMPlugin)1 WikipediaPlugin (net.osmand.plus.wikipedia.WikipediaPlugin)1