forked from upstream-mirrors/OpenTracks
Simplify TrackExporter interface.
This commit is contained in:
+5
-5
@@ -208,7 +208,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
// 1. export
|
// 1. export
|
||||||
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
|
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
|
||||||
contentProviderUtils.deleteTrack(context, trackId);
|
contentProviderUtils.deleteTrack(context, trackId);
|
||||||
|
|
||||||
// 2. import
|
// 2. import
|
||||||
@@ -290,7 +290,7 @@ public class ExportImportTest {
|
|||||||
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.createTrackExporter(context, contentProviderUtils);
|
TrackExporter trackExporter = TrackFileFormat.KML_WITH_TRACKDETAIL_AND_SENSORDATA.createTrackExporter(context, contentProviderUtils);
|
||||||
|
|
||||||
// when
|
// when
|
||||||
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
|
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
|
||||||
|
|
||||||
// 2. import
|
// 2. import
|
||||||
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
|
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
|
||||||
@@ -314,7 +314,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
// 1. export
|
// 1. export
|
||||||
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
|
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
|
||||||
contentProviderUtils.deleteTrack(context, trackId);
|
contentProviderUtils.deleteTrack(context, trackId);
|
||||||
|
|
||||||
// 2. import
|
// 2. import
|
||||||
@@ -432,7 +432,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
// 1. export
|
// 1. export
|
||||||
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
|
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
|
||||||
|
|
||||||
// 2. import
|
// 2. import
|
||||||
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
|
InputStream inputStream = context.getContentResolver().openInputStream(tmpFileUri);
|
||||||
@@ -457,7 +457,7 @@ public class ExportImportTest {
|
|||||||
|
|
||||||
// when
|
// when
|
||||||
// 1. export
|
// 1. export
|
||||||
trackExporter.writeTrack(track, context.getContentResolver().openOutputStream(tmpFileUri));
|
trackExporter.writeTrack(List.of(track), context.getContentResolver().openOutputStream(tmpFileUri));
|
||||||
contentProviderUtils.deleteTrack(context, trackId);
|
contentProviderUtils.deleteTrack(context, trackId);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
|
|||||||
+1
-1
@@ -232,7 +232,7 @@ public class GPXTrackImporterTest {
|
|||||||
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
Track importedTrack = contentProviderUtils.getTrack(importTrackId);
|
||||||
|
|
||||||
TrackExporter trackExporter = TrackFileFormat.GPX.createTrackExporter(context, contentProviderUtils);
|
TrackExporter trackExporter = TrackFileFormat.GPX.createTrackExporter(context, contentProviderUtils);
|
||||||
trackExporter.writeTrack(importedTrack, outputStream);
|
trackExporter.writeTrack(List.of(importedTrack), outputStream);
|
||||||
|
|
||||||
// then
|
// then
|
||||||
String expected = new BufferedReader(
|
String expected = new BufferedReader(
|
||||||
|
|||||||
@@ -23,8 +23,6 @@ import androidx.annotation.NonNull;
|
|||||||
import java.io.OutputStream;
|
import java.io.OutputStream;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.text.NumberFormat;
|
import java.text.NumberFormat;
|
||||||
import java.util.Arrays;
|
|
||||||
import java.util.Collections;
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import java.util.function.Function;
|
import java.util.function.Function;
|
||||||
@@ -86,11 +84,6 @@ public class CSVTrackExporter implements TrackExporter {
|
|||||||
this.contentProviderUtils = contentProviderUtils;
|
this.contentProviderUtils = contentProviderUtils;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
|
|
||||||
return writeTrack(List.of(track), outputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTrack(@NonNull List<Track> tracks, @NonNull OutputStream outputStream) {
|
public boolean writeTrack(@NonNull List<Track> tracks, @NonNull OutputStream outputStream) {
|
||||||
List<Column> columns = List.of(
|
List<Column> columns = List.of(
|
||||||
|
|||||||
@@ -97,11 +97,6 @@ public class GPXTrackExporter implements TrackExporter {
|
|||||||
this.creator = creator;
|
this.creator = creator;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
|
|
||||||
return writeTrack(List.of(track), outputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
|
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -99,10 +99,6 @@ public class KMLTrackExporter implements TrackExporter {
|
|||||||
this.contentProviderUtils = contentProviderUtils;
|
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) {
|
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
|
||||||
try {
|
try {
|
||||||
prepare(outputStream);
|
prepare(outputStream);
|
||||||
|
|||||||
@@ -64,11 +64,6 @@ public class KmzTrackExporter implements TrackExporter {
|
|||||||
this.exportPhotos = exportPhotos;
|
this.exportPhotos = exportPhotos;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
|
|
||||||
return writeTrack(List.of(track), outputStream);
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
|
public boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream) {
|
||||||
try (ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)) {
|
try (ZipOutputStream zipOutputStream = new ZipOutputStream(outputStream)) {
|
||||||
|
|||||||
@@ -31,7 +31,4 @@ import de.dennisguse.opentracks.data.models.Track;
|
|||||||
public interface TrackExporter {
|
public interface TrackExporter {
|
||||||
|
|
||||||
boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream);
|
boolean writeTrack(List<Track> tracks, @NonNull OutputStream outputStream);
|
||||||
|
|
||||||
@Deprecated // Only used for tests
|
|
||||||
boolean writeTrack(Track track, @NonNull OutputStream outputStream);
|
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user