Reorganization of GPX code.
This commit is contained in:
parent
2dd8f75822
commit
c25fb43434
|
|
@ -28,7 +28,6 @@ public class ImportGpx extends Gpx {
|
|||
|
||||
private String traceName = "";
|
||||
|
||||
|
||||
public ImportGpx(File filePath) {
|
||||
super(filePath);
|
||||
}
|
||||
|
|
@ -37,10 +36,9 @@ public class ImportGpx extends Gpx {
|
|||
return this.traceName;
|
||||
}
|
||||
|
||||
public List parse() throws XmlPullParserException, IOException {
|
||||
public List<MyLocation> parse() throws XmlPullParserException, IOException {
|
||||
InputStream in = new FileInputStream(filePath);
|
||||
try {
|
||||
|
||||
XmlPullParser parser = Xml.newPullParser();
|
||||
parser.setFeature(XmlPullParser.FEATURE_PROCESS_NAMESPACES, false);
|
||||
parser.setInput(in, null);
|
||||
|
|
@ -52,8 +50,8 @@ public class ImportGpx extends Gpx {
|
|||
}
|
||||
|
||||
|
||||
private List readGpx(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
List entries = new ArrayList();
|
||||
private List<MyLocation> readGpx(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
List<MyLocation> entries = new ArrayList<>();
|
||||
|
||||
parser.require(XmlPullParser.START_TAG, null, "gpx");
|
||||
while (parser.next() != XmlPullParser.END_TAG) {
|
||||
|
|
@ -72,8 +70,8 @@ public class ImportGpx extends Gpx {
|
|||
return entries;
|
||||
}
|
||||
|
||||
private List readTrk(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
List entries = new ArrayList();
|
||||
private List<MyLocation> readTrk(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
List<MyLocation> entries = new ArrayList<>();
|
||||
|
||||
parser.require(XmlPullParser.START_TAG, null, "trk");
|
||||
while (parser.next() != XmlPullParser.END_TAG) {
|
||||
|
|
@ -90,8 +88,8 @@ public class ImportGpx extends Gpx {
|
|||
return entries;
|
||||
}
|
||||
|
||||
private List readTrkseq(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
List entries = new ArrayList();
|
||||
private List<MyLocation> readTrkseq(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
List<MyLocation> entries = new ArrayList<>();
|
||||
|
||||
parser.require(XmlPullParser.START_TAG, null, "trkseg");
|
||||
while (parser.next() != XmlPullParser.END_TAG) {
|
||||
|
|
@ -205,7 +203,7 @@ public class ImportGpx extends Gpx {
|
|||
|
||||
|
||||
private boolean readFound(XmlPullParser parser) throws XmlPullParserException, IOException {
|
||||
boolean ret = false;
|
||||
boolean ret;
|
||||
parser.require(XmlPullParser.START_TAG, null, "found");
|
||||
ret = Boolean.parseBoolean(readText(parser));
|
||||
parser.require(XmlPullParser.END_TAG, null, "found");
|
||||
|
|
|
|||
|
|
@ -305,13 +305,13 @@ public class ServiceGps extends Observable implements LocationListener {
|
|||
public void importGpxTrace(File file) {
|
||||
ImportGpx importGpx = new ImportGpx(file);
|
||||
try {
|
||||
List list = importGpx.parse();
|
||||
List<MyLocation> list = importGpx.parse();
|
||||
String traceName = importGpx.getTraceName();
|
||||
if (traceName.equals(Gpx.TRAIL_TRACE_NAME)) {
|
||||
lastExportedTrailFile = file;
|
||||
}
|
||||
for (int i=0; i<list.size(); i++) {
|
||||
Object o = list.get(i);
|
||||
MyLocation o = list.get(i);
|
||||
if (o instanceof WayPointLocation) {
|
||||
if (traceName.equals(Gpx.DOG_TRACE_NAME)) {
|
||||
traces.addPointObjectDog((WayPointLocation) o);
|
||||
|
|
|
|||
Loading…
Reference in New Issue