Search in sources :

Example 1 with ItineraryGroupInfo

use of net.osmand.plus.mapmarkers.ItineraryDataHelper.ItineraryGroupInfo in project Osmand by osmandapp.

the class ItinerarySettingsItem method getReader.

@Nullable
@Override
public SettingsItemReader<ItinerarySettingsItem> getReader() {
    return new SettingsItemReader<ItinerarySettingsItem>(this) {

        @Override
        public void readFromStream(@NonNull InputStream inputStream, String entryName) throws IllegalArgumentException {
            List<ItineraryGroupInfo> groupInfos = new ArrayList<>();
            GPXFile gpxFile = GPXUtilities.loadGPXFile(inputStream, dataHelper.getGPXExtensionsReader(groupInfos));
            if (gpxFile.error != null) {
                warnings.add(app.getString(R.string.settings_item_read_error, String.valueOf(getType())));
                SettingsHelper.LOG.error("Failed read gpx file", gpxFile.error);
            } else {
                Map<String, MapMarker> markers = new LinkedHashMap<>();
                Map<String, MapMarkersGroup> groups = new LinkedHashMap<>();
                dataHelper.collectMarkersGroups(gpxFile, groups, groupInfos, markers);
                items.addAll(groups.values());
            }
        }
    };
}
Also used : MapMarker(net.osmand.plus.mapmarkers.MapMarker) InputStream(java.io.InputStream) ArrayList(java.util.ArrayList) ItineraryGroupInfo(net.osmand.plus.mapmarkers.ItineraryDataHelper.ItineraryGroupInfo) LinkedHashMap(java.util.LinkedHashMap) SettingsItemReader(net.osmand.plus.settings.backend.backup.SettingsItemReader) NonNull(androidx.annotation.NonNull) MapMarkersGroup(net.osmand.plus.mapmarkers.MapMarkersGroup) GPXFile(net.osmand.GPXUtilities.GPXFile) Nullable(androidx.annotation.Nullable)

Aggregations

NonNull (androidx.annotation.NonNull)1 Nullable (androidx.annotation.Nullable)1 InputStream (java.io.InputStream)1 ArrayList (java.util.ArrayList)1 LinkedHashMap (java.util.LinkedHashMap)1 GPXFile (net.osmand.GPXUtilities.GPXFile)1 ItineraryGroupInfo (net.osmand.plus.mapmarkers.ItineraryDataHelper.ItineraryGroupInfo)1 MapMarker (net.osmand.plus.mapmarkers.MapMarker)1 MapMarkersGroup (net.osmand.plus.mapmarkers.MapMarkersGroup)1 SettingsItemReader (net.osmand.plus.settings.backend.backup.SettingsItemReader)1