mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 09:33:06 +02:00
add overload for exporter that takes single track
This commit is contained in:
+5
-5
@@ -111,7 +111,7 @@ public class ExportImportTest {
|
||||
// when
|
||||
// 1. export
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
trackExporter.writeTrack(new Track[]{track}, outputStream);
|
||||
trackExporter.writeTrack(track, outputStream);
|
||||
contentProviderUtils.deleteTrack(context, trackId);
|
||||
|
||||
// 2. import
|
||||
@@ -147,7 +147,7 @@ public class ExportImportTest {
|
||||
// when
|
||||
// 1. export
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
trackExporter.writeTrack(new Track[]{track}, outputStream);
|
||||
trackExporter.writeTrack(track, outputStream);
|
||||
contentProviderUtils.deleteTrack(context, trackId);
|
||||
|
||||
// 2. import
|
||||
@@ -183,7 +183,7 @@ public class ExportImportTest {
|
||||
// when
|
||||
// 1. export
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
trackExporter.writeTrack(new Track[]{track}, outputStream);
|
||||
trackExporter.writeTrack(track, outputStream);
|
||||
|
||||
// 2. import
|
||||
InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
@@ -234,7 +234,7 @@ public class ExportImportTest {
|
||||
// when
|
||||
// 1. export
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
trackExporter.writeTrack(new Track[]{track}, outputStream);
|
||||
trackExporter.writeTrack(track, outputStream);
|
||||
contentProviderUtils.deleteTrack(context, trackId);
|
||||
|
||||
// 2. import
|
||||
@@ -272,7 +272,7 @@ public class ExportImportTest {
|
||||
// when
|
||||
// 1. export
|
||||
ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
|
||||
trackExporter.writeTrack(new Track[]{track}, outputStream);
|
||||
trackExporter.writeTrack(track, outputStream);
|
||||
|
||||
// 2. import
|
||||
InputStream inputStream = new ByteArrayInputStream(outputStream.toByteArray());
|
||||
|
||||
@@ -218,7 +218,7 @@ public class ExportProgressDialogFragment extends DialogFragment {
|
||||
}
|
||||
|
||||
try (OutputStream outputStream = context.getContentResolver().openOutputStream(file.getUri())) {
|
||||
if (trackExporter.writeTrack(new Track[]{track}, outputStream)) {
|
||||
if (trackExporter.writeTrack(track, outputStream)) {
|
||||
return true;
|
||||
} else {
|
||||
if (!file.delete()) {
|
||||
|
||||
@@ -54,6 +54,11 @@ public class FileTrackExporter implements TrackExporter {
|
||||
this.trackWriter = trackWriter;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
|
||||
return writeTrack(new Track[]{track}, outputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean writeTrack(Track[] tracks, @NonNull OutputStream outputStream) {
|
||||
try {
|
||||
|
||||
@@ -69,6 +69,11 @@ public class KmzTrackExporter implements TrackExporter {
|
||||
this.exportPhotos = exportPhotos;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean writeTrack(Track track, @NonNull OutputStream outputStream) {
|
||||
return writeTrack(new Track[]{track}, outputStream);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean writeTrack(Track[] tracks, @NonNull OutputStream outputStream) {
|
||||
ZipOutputStream zipOutputStream = null;
|
||||
|
||||
@@ -29,12 +29,7 @@ import de.dennisguse.opentracks.content.data.Track;
|
||||
*/
|
||||
public interface TrackExporter {
|
||||
|
||||
/**
|
||||
* Write track to an output stream.
|
||||
* Depending on the implementation a context might be required.
|
||||
*
|
||||
* @param tracks
|
||||
* @param outputStream the output stream
|
||||
*/
|
||||
boolean writeTrack(Track[] tracks, @NonNull OutputStream outputStream);
|
||||
|
||||
boolean writeTrack(Track track, @NonNull OutputStream outputStream);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user