Simplify TrackExporter interface.

This commit is contained in:
Dennis Guse
2023-05-24 20:12:04 +02:00
parent 3aadf6d5d8
commit f48c4806b5
7 changed files with 6 additions and 30 deletions
@@ -208,7 +208,7 @@ public class ExportImportTest {
// when
// 1. export
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
contentProviderUtils.deleteTrack(context, trackId);
// 2. import
@@ -290,7 +290,7 @@ public class ExportImportTest {
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.createTrackExporter(context, contentProviderUtils);
// when
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
// 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
@@ -314,7 +314,7 @@ public class ExportImportTest {
// when
// 1. export
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
contentProviderUtils.deleteTrack(context, trackId);
// 2. import
@@ -432,7 +432,7 @@ public class ExportImportTest {
// when
// 1. export
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
// 2. import
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
@@ -457,7 +457,7 @@ public class ExportImportTest {
// when
// 1. export
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
contentProviderUtils.deleteTrack(context, trackId);
// then
@@ -232,7 +232,7 @@ public class GPXTrackImporterTest {
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
TrackExporter trackExporter = TrackFileFormat.GPX.createTrackExporter(context, contentProviderUtils);
trackExporter.writeTrack(importedTrack, outputStream);
trackExporter.writeTrack(List.of(importedTrack), outputStream);
// then
String expected = new BufferedReader(
@@ -23,8 +23,6 @@ import androidx.annotation.NonNull;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.text.NumberFormat;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Locale;
import java.util.function.Function;
@@ -86,11 +84,6 @@ public class CSVTrackExporter implements TrackExporter {
this.contentProviderUtils = contentProviderUtils;
}
@Override
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
return writeTrack(List.of(track), outputStream);
}
@Override
public boolean writeTrack(@NonNull List<Track> tracks, @NonNull OutputStream outputStream) {
List<Column> columns = List.of(
@@ -97,11 +97,6 @@ public class GPXTrackExporter implements TrackExporter {
this.creator = creator;
}
@Override
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
return writeTrack(List.of(track), outputStream);
}
@Override
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
try {
@@ -99,10 +99,6 @@ public class KMLTrackExporter implements TrackExporter {
this.contentProviderUtils = contentProviderUtils;
}
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
return writeTrack(List.of(track), outputStream);
}
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
try {
prepare(outputStream);
@@ -64,11 +64,6 @@ public class KmzTrackExporter implements TrackExporter {
this.exportPhotos = exportPhotos;
}
@Override
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
return writeTrack(List.of(track), outputStream);
}
@Override
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
try (ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)) {
@@ -31,7 +31,4 @@ import de.dennisguse.opentracks.data.models.Track;
public interface TrackExporter {
boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream);
@Deprecated // Only used for tests
boolean writeTrack(Track track, @NonNull OutputStream outputStream);
}