mirror of
https://codeberg.org/OpenTracksApp/OpenTracks.git
synced 2026-10-02 17:43:06 +02:00
Rename TrackWriter to TrackExporter
This commit is contained in:
@@ -52,7 +52,7 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
|
||||
private WakeLock wakeLock;
|
||||
private TrackWriter trackWriter;
|
||||
private TrackExporter trackExporter;
|
||||
|
||||
// true if the AsyncTask has completed
|
||||
private boolean completed;
|
||||
@@ -163,8 +163,8 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
|
||||
@Override
|
||||
protected void onCancelled() {
|
||||
if (trackWriter != null) {
|
||||
trackWriter.stopWriteTrack();
|
||||
if (trackExporter != null) {
|
||||
trackExporter.stopWriteTrack();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -186,8 +186,8 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
return false;
|
||||
}
|
||||
|
||||
trackWriter = new TrackWriter(
|
||||
context, myTracksProviderUtils, tracks, trackFileFormat, new TrackWriter.OnWriteListener() {
|
||||
trackExporter = new TrackExporter(
|
||||
context, myTracksProviderUtils, tracks, trackFileFormat, new TrackExporter.OnWriteListener() {
|
||||
@Override
|
||||
public void onWrite(int number, int max) {
|
||||
/*
|
||||
@@ -204,20 +204,20 @@ public class SaveAsyncTask extends AsyncTask<Void, Integer, Boolean> {
|
||||
try {
|
||||
file = new File(directory, fileName);
|
||||
OutputStream outputStream = new FileOutputStream(file);
|
||||
trackWriter.writeTrack(outputStream);
|
||||
trackExporter.writeTrack(outputStream);
|
||||
} catch (FileNotFoundException e) {
|
||||
Log.d(TAG, "File not found " + fileName, e);
|
||||
return false;
|
||||
}
|
||||
|
||||
if (trackWriter.wasSuccess()) {
|
||||
if (trackExporter.wasSuccess()) {
|
||||
savedPath = file.getAbsolutePath();
|
||||
} else {
|
||||
if (!file.delete()) {
|
||||
Log.w(TAG, "Failed to delete file " + file.getAbsolutePath());
|
||||
}
|
||||
}
|
||||
return trackWriter.wasSuccess();
|
||||
return trackExporter.wasSuccess();
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
+4
-4
@@ -38,7 +38,7 @@ import java.io.OutputStream;
|
||||
* @author Sandor Dornbush
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class TrackWriter {
|
||||
public class TrackExporter {
|
||||
|
||||
/**
|
||||
* Listener for when a track location is written.
|
||||
@@ -55,7 +55,7 @@ public class TrackWriter {
|
||||
public void onWrite(int number, int max);
|
||||
}
|
||||
|
||||
private final static String TAG = TrackWriter.class.getSimpleName();
|
||||
private final static String TAG = TrackExporter.class.getSimpleName();
|
||||
|
||||
private final MyTracksProviderUtils myTracksProviderUtils;
|
||||
private final Track[] tracks;
|
||||
@@ -74,13 +74,13 @@ public class TrackWriter {
|
||||
* @param trackFileFormat the track file format
|
||||
* @param onWriteListener the on write listener
|
||||
*/
|
||||
public TrackWriter(Context context, MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
|
||||
public TrackExporter(Context context, MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
|
||||
TrackFileFormat trackFileFormat, OnWriteListener onWriteListener) {
|
||||
this(myTracksProviderUtils, tracks, trackFileFormat.newFormatWriter(context), onWriteListener);
|
||||
}
|
||||
|
||||
@VisibleForTesting
|
||||
public TrackWriter(MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
|
||||
public TrackExporter(MyTracksProviderUtils myTracksProviderUtils, Track[] tracks,
|
||||
TrackFormatWriter trackFormatWriter, OnWriteListener onWriteListener) {
|
||||
this.myTracksProviderUtils = myTracksProviderUtils;
|
||||
this.tracks = tracks;
|
||||
@@ -21,7 +21,7 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.TracksColumns;
|
||||
import com.google.android.apps.mytracks.io.file.TrackFileFormat;
|
||||
import com.google.android.apps.mytracks.io.file.TrackWriter;
|
||||
import com.google.android.apps.mytracks.io.file.TrackExporter;
|
||||
import com.google.android.apps.mytracks.util.FileUtils;
|
||||
import com.google.android.apps.mytracks.util.PreferencesUtils;
|
||||
import com.google.android.maps.mytracks.R;
|
||||
@@ -441,11 +441,11 @@ public class SyncUtils {
|
||||
|
||||
java.io.File file = new java.io.File(directory,
|
||||
FileUtils.buildUniqueFileName(directory, track.getName(), trackFileFormat.getExtension()));
|
||||
TrackWriter trackWriter = new TrackWriter(
|
||||
TrackExporter trackExporter = new TrackExporter(
|
||||
context, myTracksProviderUtils, new Track[] {track}, trackFileFormat, null);
|
||||
|
||||
trackWriter.writeTrack(new FileOutputStream(file));
|
||||
if (trackWriter.wasSuccess()) {
|
||||
trackExporter.writeTrack(new FileOutputStream(file));
|
||||
if (trackExporter.wasSuccess()) {
|
||||
return file;
|
||||
}
|
||||
Log.d(TAG, "Unable to get file for track " + track.getName());
|
||||
|
||||
+11
-11
@@ -7,7 +7,7 @@ import com.google.android.apps.mytracks.content.MyTracksProviderUtils;
|
||||
import com.google.android.apps.mytracks.content.MyTracksProviderUtils.Factory;
|
||||
import com.google.android.apps.mytracks.content.Track;
|
||||
import com.google.android.apps.mytracks.content.Waypoint;
|
||||
import com.google.android.apps.mytracks.io.file.TrackWriter.OnWriteListener;
|
||||
import com.google.android.apps.mytracks.io.file.TrackExporter.OnWriteListener;
|
||||
import com.google.android.apps.mytracks.services.TrackRecordingServiceTest.MockContext;
|
||||
import com.google.android.apps.mytracks.testing.TestingProviderUtilsFactory;
|
||||
|
||||
@@ -25,11 +25,11 @@ import org.easymock.IArgumentMatcher;
|
||||
import org.easymock.IMocksControl;
|
||||
|
||||
/**
|
||||
* Tests for {@link TrackWriter}.
|
||||
* Tests for {@link TrackExporter}.
|
||||
*
|
||||
* @author Rodrigo Damazio
|
||||
*/
|
||||
public class TrackWriterTest extends AndroidTestCase {
|
||||
public class TrackExporterTest extends AndroidTestCase {
|
||||
|
||||
private static final long TRACK_ID = 1234567L;
|
||||
private static final String TRACK_NAME = "Swimming across the pacific";
|
||||
@@ -42,7 +42,7 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
private TrackFormatWriter trackFormatWriter;
|
||||
private Track track;
|
||||
private OutputStream outputStream;
|
||||
private TrackWriter trackWriter;
|
||||
private TrackExporter trackExporter;
|
||||
|
||||
@Override
|
||||
protected void setUp() throws Exception {
|
||||
@@ -76,7 +76,7 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
|
||||
}
|
||||
};
|
||||
trackWriter = new TrackWriter(myTracksProviderUtils, new Track[] {track}, trackFormatWriter, onWriteListener);
|
||||
trackExporter = new TrackExporter(myTracksProviderUtils, new Track[] {track}, trackFormatWriter, onWriteListener);
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -99,9 +99,9 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
trackFormatWriter.close();
|
||||
|
||||
mocksControl.replay();
|
||||
trackWriter.writeTrack(outputStream);
|
||||
trackExporter.writeTrack(outputStream);
|
||||
|
||||
assertTrue(trackWriter.wasSuccess());
|
||||
assertTrue(trackExporter.wasSuccess());
|
||||
mocksControl.verify();
|
||||
}
|
||||
|
||||
@@ -131,9 +131,9 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
trackFormatWriter.close();
|
||||
|
||||
mocksControl.replay();
|
||||
trackWriter.writeTrack(outputStream);
|
||||
trackExporter.writeTrack(outputStream);
|
||||
|
||||
assertTrue(trackWriter.wasSuccess());
|
||||
assertTrue(trackExporter.wasSuccess());
|
||||
mocksControl.verify();
|
||||
}
|
||||
|
||||
@@ -196,9 +196,9 @@ public class TrackWriterTest extends AndroidTestCase {
|
||||
trackFormatWriter.close();
|
||||
|
||||
mocksControl.replay();
|
||||
trackWriter.writeTrack(outputStream);
|
||||
trackExporter.writeTrack(outputStream);
|
||||
|
||||
assertTrue(trackWriter.wasSuccess());
|
||||
assertTrue(trackExporter.wasSuccess());
|
||||
mocksControl.verify();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user