/* Copyright (C) 2023-2024 José Rebelo This file is part of Gadgetbridge. Gadgetbridge is free software: you can redistribute it and/or modify it under the terms of the GNU Affero General Public License as published by the Free Software Foundation, either version 3 of the License, or (at your option) any later version. Gadgetbridge is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more details. You should have received a copy of the GNU Affero General Public License along with this program. If not, see . */ package nodomain.freeyourgadget.gadgetbridge.util.gpx; import androidx.annotation.Nullable; import com.google.gson.internal.bind.util.ISO8601Utils; import org.slf4j.Logger; import org.slf4j.LoggerFactory; import org.xmlpull.v1.XmlPullParser; import org.xmlpull.v1.XmlPullParserException; import org.xmlpull.v1.XmlPullParserFactory; import java.io.ByteArrayInputStream; import java.io.IOException; import java.io.InputStream; import java.text.ParsePosition; import java.util.Date; import nodomain.freeyourgadget.gadgetbridge.util.ArrayUtils; import nodomain.freeyourgadget.gadgetbridge.util.gpx.model.GpxFile; import nodomain.freeyourgadget.gadgetbridge.util.gpx.model.GpxTrack; import nodomain.freeyourgadget.gadgetbridge.util.gpx.model.GpxTrackPoint; import nodomain.freeyourgadget.gadgetbridge.util.gpx.model.GpxTrackSegment; import nodomain.freeyourgadget.gadgetbridge.util.gpx.model.GpxWaypoint; public class GpxParser { private static final Logger LOG = LoggerFactory.getLogger(GpxParser.class); public static final byte[] XML_HEADER = new byte[]{ '<', '?', 'x', 'm', 'l' }; // Some gpx files start with "