forked from upstream-mirrors/OpenTracks
Removed TrackImporter interface.
This commit is contained in:
@@ -46,24 +46,23 @@ public class ImportService extends JobIntentService {
|
||||
}
|
||||
|
||||
private void importFile(DocumentFile file) {
|
||||
TrackImporter trackImporter;
|
||||
ArrayList<Track.Id> trackIds = new ArrayList<>();
|
||||
|
||||
String fileExtension = FileUtils.getExtension(file);
|
||||
try {
|
||||
|
||||
if (TrackFileFormat.GPX.getExtension().equals(fileExtension)) {
|
||||
trackImporter = new XMLImporter(new GpxFileTrackImporter(this));
|
||||
trackIds.addAll(new XMLImporter(new GpxFileTrackImporter(this)).importFile(this, file.getUri()));
|
||||
} else if (TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.getExtension().equals(fileExtension)) {
|
||||
trackImporter = new XMLImporter(new KmlFileTrackImporter(this));
|
||||
trackIds.addAll(new XMLImporter(new KmlFileTrackImporter(this)).importFile(this, file.getUri()));
|
||||
} else if (TrackFileFormat.KMZ_WITH_TRACKDETAIL_AND_SENSORDATA_AND_PICTURES.getExtension().equals(fileExtension)) {
|
||||
trackImporter = new KmzTrackImporter();
|
||||
trackIds.addAll(new KmzTrackImporter().importFile(this, file.getUri()));
|
||||
} else {
|
||||
Log.d(TAG, "Unsupported file format.");
|
||||
sendResult(ImportServiceResultReceiver.RESULT_CODE_ERROR, null, file, getString(R.string.import_unsupported_format));
|
||||
return;
|
||||
}
|
||||
|
||||
ArrayList<Track.Id> trackIds = new ArrayList<>(trackImporter.importFile(this, file.getUri()));
|
||||
|
||||
if (!trackIds.isEmpty()) {
|
||||
sendResult(ImportServiceResultReceiver.RESULT_CODE_IMPORTED, trackIds, file, getString(R.string.import_file_imported, file.getName()));
|
||||
} else {
|
||||
|
||||
@@ -46,7 +46,7 @@ import de.dennisguse.opentracks.util.FileUtils;
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public class KmzTrackImporter implements TrackImporter {
|
||||
public class KmzTrackImporter {
|
||||
|
||||
private static final String TAG = KmzTrackImporter.class.getSimpleName();
|
||||
|
||||
|
||||
@@ -1,34 +0,0 @@
|
||||
/*
|
||||
* Copyright 2013 Google Inc.
|
||||
*
|
||||
* Licensed under the Apache License, Version 2.0 (the "License"); you may not
|
||||
* use this file except in compliance with the License. You may obtain a copy of
|
||||
* the License at
|
||||
*
|
||||
* http://www.apache.org/licenses/LICENSE-2.0
|
||||
*
|
||||
* Unless required by applicable law or agreed to in writing, software
|
||||
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
||||
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
||||
* License for the specific language governing permissions and limitations under
|
||||
* the License.
|
||||
*/
|
||||
package de.dennisguse.opentracks.io.file.importer;
|
||||
|
||||
import android.content.Context;
|
||||
import android.net.Uri;
|
||||
|
||||
import java.io.IOException;
|
||||
import java.util.List;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
|
||||
/**
|
||||
* Interface for a track importer.
|
||||
*
|
||||
* @author Jimmy Shih
|
||||
*/
|
||||
public interface TrackImporter {
|
||||
|
||||
List<Track.Id> importFile(Context context, Uri uri) throws IOException, ImportParserException;
|
||||
}
|
||||
@@ -19,7 +19,7 @@ import javax.xml.parsers.SAXParserFactory;
|
||||
|
||||
import de.dennisguse.opentracks.content.data.Track;
|
||||
|
||||
public class XMLImporter implements TrackImporter {
|
||||
public class XMLImporter {
|
||||
|
||||
private static final String TAG = XMLImporter.class.getSimpleName();
|
||||
|
||||
@@ -29,7 +29,6 @@ public class XMLImporter implements TrackImporter {
|
||||
this.parser = parser;
|
||||
}
|
||||
|
||||
@Override
|
||||
@NonNull
|
||||
public List<Track.Id> importFile(Context context, Uri uri) throws ImportParserException, ImportAlreadyExistsException, IOException {
|
||||
try (InputStream inputStream = context.getContentResolver().openInputStream(uri)) {
|
||||
|
||||
Reference in New Issue
Block a user